]> git.sesse.net Git - x264/blobdiff - input/lavf.c
Fix regression in checkasm in r1666
[x264] / input / lavf.c
index 52e890c5f817fb509b2e144e973d2766336617d6..56bfa29ca3d0d80a6543a713307fa60df725f20c 100644 (file)
@@ -1,7 +1,7 @@
 /*****************************************************************************
- * lavf.c: x264 libavformat input module
+ * lavf.c: libavformat input
  *****************************************************************************
- * Copyright (C) 2009 x264 project
+ * Copyright (C) 2009-2010 x264 project
  *
  * Authors: Mike Gurlitz <mike.gurlitz@gmail.com>
  *          Steven Walters <kemuri9@gmail.com>
@@ -19,6 +19,9 @@
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111, USA.
+ *
+ * This program is also available under a commercial proprietary license.
+ * For more information, contact us at licensing@x264.com.
  *****************************************************************************/
 
 #include "input.h"
@@ -64,20 +67,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++;
     }