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

matlab例程

开发平台:

Matlab

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