main44old.m
上传用户:cxsjwj
上传日期:2022-08-09
资源大小:34k
文件大小:4k
源码类别:

matlab例程

开发平台:

Matlab

  1. clc
  2. tic
  3. aviobj = avifile('2.avi','fps',25,'COMPRESSION','None');
  4. %motion Vectors
  5. motionVect=zeros(2,256);
  6. fid=fopen('Qtable2.txt','r');
  7. %array is quantization matrix
  8. array=fscanf(fid,'%e',[8,inf]);
  9. %array=2*array;
  10. i = 0;
  11. %flag to tell if B frame was predicted from I or P frame flag=1 P frame
  12. %flag=0 I frame
  13. flag=2;
  14. %GOP is of 10 pictures IBBPBBPBBI
  15. mov=aviread('news.avi');
  16. movinfo=aviinfo('news.avi');
  17. noframe=movinfo.NumFrames;
  18. %mbSize macroblock size used for motion estimation
  19. mbSize = 8;
  20. %p for search area
  21. p = 7;
  22. global I1 I1d P4d P7d I10d B2d B3d B5d B6d B8d B9d 
  23. array=array;
  24. for i=85:10:95
  25.     i
  26.     framedata=aviread('news.avi',i);
  27.     I1=frame2im(framedata);
  28.     
  29.     if resize==1
  30.     I1=imresize(I1,[long,wide]);
  31.     end
  32.     
  33.     
  34.     I1=I1(:,:,1);
  35.     main441
  36.     layer1
  37.     
  38.     framedata=aviread('news.avi',i);
  39.     I1=frame2im(framedata);
  40.     if resize==1
  41.     I1=imresize(I1,[long,wide]);
  42.     end
  43.     
  44.     I1=I1(:,:,2);
  45.     main442
  46.     layer2
  47.     
  48.     framedata=aviread('news.avi',i);
  49.     I1=frame2im(framedata);
  50.     if resize==1
  51.     I1=imresize(I1,[long,wide]);
  52.     end
  53.     
  54.     I1=I1(:,:,3);
  55.     main443
  56.     layer3
  57. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  58.         
  59.     
  60.         if i==1
  61.                 imshow(uint8(I1d1))
  62.                 aviobj = addframe(aviobj,getframe);
  63.                 clf;
  64.                 
  65.                 imshow(uint8(B2d1))
  66.                 aviobj = addframe(aviobj,getframe);
  67.                 clf;
  68.                 
  69.                 imshow(uint8(B3d1))
  70.                 aviobj = addframe(aviobj,getframe);
  71.                 clf;
  72.                 
  73.                 imshow(uint8(P4d1))
  74.                 aviobj = addframe(aviobj,getframe);
  75.                 clf;
  76.                 
  77.                 imshow(uint8(B5d1))
  78.                 aviobj = addframe(aviobj,getframe);
  79.                 clf;
  80.                 
  81.                 imshow(uint8(B6d1))
  82.                 aviobj = addframe(aviobj,getframe);
  83.                 clf;
  84.                 
  85.                 imshow(uint8(P7d1))
  86.                 aviobj = addframe(aviobj,getframe);
  87.                 clf;
  88.                 
  89.                 imshow(uint8(B8d1))
  90.                 aviobj = addframe(aviobj,getframe);
  91.                 clf;
  92.                 
  93.                 imshow(uint8(B9d1))
  94.                 aviobj = addframe(aviobj,getframe);
  95.                 clf;
  96.                 
  97.                 imshow(uint8(I10d1))
  98.                 aviobj = addframe(aviobj,getframe); 
  99.                 clf;
  100.             else
  101.                 
  102.                 imshow(uint8(B2d1))
  103.                 aviobj = addframe(aviobj,getframe);
  104.                 clf;
  105.                 
  106.                 imshow(uint8(B3d1))
  107.                 aviobj = addframe(aviobj,getframe);
  108.                 clf;
  109.                 
  110.                 imshow(uint8(P4d1))
  111.                 aviobj = addframe(aviobj,getframe);
  112.                 clf;
  113.                 
  114.                 imshow(uint8(B5d1))
  115.                 aviobj = addframe(aviobj,getframe);
  116.                 clf;
  117.                 
  118.                 imshow(uint8(B6d1))
  119.                 aviobj = addframe(aviobj,getframe);
  120.                 clf;
  121.                 
  122.                 imshow(uint8(P7d1))
  123.                 aviobj = addframe(aviobj,getframe);
  124.                 clf;
  125.                 
  126.                 imshow(uint8(B8d1))
  127.                 aviobj = addframe(aviobj,getframe);
  128.                 clf;
  129.                 
  130.                 imshow(uint8(B9d1))
  131.                 aviobj = addframe(aviobj,getframe);
  132.                 clf;
  133.                 
  134.                 imshow(uint8(I10d1))
  135.                 aviobj = addframe(aviobj,getframe);
  136.                 clf;
  137.         end
  138.             framedata=aviread('news.avi',i+9);
  139.             I10=frame2im(framedata);
  140.             %I10=imresize(I10,[128 128]);
  141.       
  142.             
  143.                       
  144.             
  145. end
  146. aviobj = close(aviobj);
  147. toc