[x264-devel] commit: Fix lavf input with delayed frames (golgol7777 )

git at videolan.org git at videolan.org
Mon Aug 16 12:07:22 CEST 2010


x264 | branch: stable | golgol7777 <golgol7777 at gmail.com> | Sat Aug  7 23:01:46 2010 -0700| [003a7f2864190774f9ccf78168ff58a442fae627] | committer: Jason Garrett-Glaser 

Fix lavf input with delayed frames

> http://git.videolan.org/gitweb.cgi/x264.git/?a=commit;h=003a7f2864190774f9ccf78168ff58a442fae627
---

 input/lavf.c |   19 ++++++++++++-------
 1 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/input/lavf.c b/input/lavf.c
index 52e890c..cadfd35 100644
--- a/input/lavf.c
+++ b/input/lavf.c
@@ -64,20 +64,25 @@ static int read_frame_internal( cli_pic_t *p_pic, lavf_hnd_t *h, int i_frame, vi
     while( i_frame >= h->next_frame )
     {
         int finished = 0;
-        while( !finished && av_read_frame( h->lavf, pkt ) >= 0 )
+        int ret = 0;
+        do
+        {
+            ret = av_read_frame( h->lavf, pkt );
+
             if( pkt->stream_index == h->stream_id )
             {
+                if( ret < 0 )
+                    pkt->size = 0;
+
                 c->reordered_opaque = pkt->pts;
                 if( avcodec_decode_video2( c, &frame, &finished, pkt ) < 0 )
                     x264_cli_log( "lavf", X264_LOG_WARNING, "video decoding failed on frame %d\n", h->next_frame );
             }
+        } while( !finished && ret >= 0 );
+
         if( !finished )
-        {
-            if( avcodec_decode_video2( c, &frame, &finished, pkt ) < 0 )
-                x264_cli_log( "lavf", X264_LOG_WARNING, "video decoding failed on frame %d\n", h->next_frame );
-            if( !finished )
-                return -1;
-        }
+            return -1;
+
         h->next_frame++;
     }
 



More information about the x264-devel mailing list