diff libmpcodecs/dec_video.c @ 31953:2b390c08ed07

Improve correct-pts with PAFF streams. Patch by P«”sztor Szil«”rd, bartosteka freemail hu
author cehoyos
date Mon, 30 Aug 2010 23:24:56 +0000
parents 6e0b5a97e00f
children 96559880e475
line wrap: on
line diff
--- a/libmpcodecs/dec_video.c	Mon Aug 30 16:48:52 2010 +0000
+++ b/libmpcodecs/dec_video.c	Mon Aug 30 23:24:56 2010 +0000
@@ -394,8 +394,21 @@
     unsigned int t = GetTimer();
     unsigned int t2;
     double tt;
+    int delay;
+    int got_picture = 1;
 
-    if (correct_pts && pts != MP_NOPTS_VALUE) {
+    mpi = mpvdec->decode(sh_video, start, in_size, drop_frame);
+
+    //------------------------ frame decoded. --------------------
+
+    if (mpi && mpi->type == MP_IMGTYPE_INCOMPLETE) {
+	got_picture = 0;
+	mpi = NULL;
+    }
+
+    delay = get_current_video_decoder_lag(sh_video);
+    if (correct_pts && pts != MP_NOPTS_VALUE
+        && (got_picture || sh_video->num_buffered_pts < delay)) {
         if (sh_video->num_buffered_pts ==
             sizeof(sh_video->buffered_pts) / sizeof(double))
             mp_msg(MSGT_DECVIDEO, MSGL_ERR, "Too many buffered pts\n");
@@ -411,10 +424,6 @@
         }
     }
 
-    mpi = mpvdec->decode(sh_video, start, in_size, drop_frame);
-
-    //------------------------ frame decoded. --------------------
-
 #if HAVE_MMX
     // some codecs are broken, and doesn't restore MMX state :(
     // it happens usually with broken/damaged files.
@@ -439,7 +448,6 @@
         mpi->fields &= ~MP_IMGFIELD_TOP_FIRST;
 
     if (correct_pts) {
-        int delay = get_current_video_decoder_lag(sh_video);
         if (sh_video->num_buffered_pts) {
             sh_video->num_buffered_pts--;
             sh_video->pts = sh_video->buffered_pts[sh_video->num_buffered_pts];