[xiph-commits] r10219 - trunk/ffmpeg2theora

j at svn.xiph.org j at svn.xiph.org
Thu Oct 20 19:11:26 PDT 2005


Author: j
Date: 2005-10-20 19:11:21 -0700 (Thu, 20 Oct 2005)
New Revision: 10219

Modified:
   trunk/ffmpeg2theora/ffmpeg2theora.c
Log:
patch from Glenn Maynard <glenn (at) zewt.org>:
 - When at e_o_s, call avcodec_decode_video even when we have no more data to
   give it (len == 0), to flush any buffered frames.  Fixes dropped B-frames
   at the end of MPEG files.

 - Don't output frames when !got_picture.  Fixes a blank (green) frame being
   output to the beginning of the file when encoding from an MPEG with
   B-frames.

 - Break out of the avcodec_decode_video loop when it doesn't have us any
   more frames available (!got_picture), not when at e_o_s.  It may
   have more than one frame buffered, so we should only stop when it
   stops giving us data.



Modified: trunk/ffmpeg2theora/ffmpeg2theora.c
===================================================================
--- trunk/ffmpeg2theora/ffmpeg2theora.c	2005-10-21 01:51:38 UTC (rev 10218)
+++ trunk/ffmpeg2theora/ffmpeg2theora.c	2005-10-21 02:11:21 UTC (rev 10219)
@@ -518,9 +518,8 @@
                 }
                 while(e_o_s || len > 0){
                     int dups = 0;
-                    if(len >0 &&
-                        (len1 = avcodec_decode_video(vstream->codec,
-                                        frame, &got_picture, ptr, len))>0) {
+                    len1 = avcodec_decode_video(vstream->codec, frame, &got_picture, ptr, len);
+                    if(len1>=0) {
                                         
                         if(got_picture){
                             // this is disabled by default since it does not work
@@ -597,11 +596,11 @@
                     yuv.u = output_resized->data[1];
                     yuv.v = output_resized->data[2];
 
-                    do {                        
+                    if(got_picture) do {                        
                         oggmux_add_video(&info, &yuv ,e_o_s);
                         this->frame_count++;
                     } while(dups--);
-                    if(e_o_s){
+                    if(!got_picture){
                         break;
                     }
                 }



More information about the commits mailing list