avviddec: drain frames until libav doesn't have more data
authorIBM Thinklab <oblong@wall-center.(none)>
Thu, 11 Sep 2014 23:37:33 +0000 (19:37 -0400)
committerSebastian Dröge <sebastian@centricular.com>
Fri, 12 Sep 2014 13:26:21 +0000 (16:26 +0300)
We use have_data (that comes from libav), instead of only trying 10 times,
to know if there are more frames available. The old code was machine
dependant as different amount of frames could be decoded by different
type of (more powerful) machines, and 10 times was not always sufficient.

https://bugzilla.gnome.org/show_bug.cgi?id=736515

ext/libav/gstavviddec.c

index a93f3d4..a9645f2 100644 (file)
@@ -1438,7 +1438,7 @@ gst_ffmpegviddec_drain (GstFFMpegVidDec * ffmpegdec)
   oclass = (GstFFMpegVidDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
 
   if (oclass->in_plugin->capabilities & CODEC_CAP_DELAY) {
-    gint have_data, len, try = 0;
+    gint have_data, len;
 
     GST_LOG_OBJECT (ffmpegdec,
         "codec has delay capabilities, calling until ffmpeg has drained everything");
@@ -1448,9 +1448,7 @@ gst_ffmpegviddec_drain (GstFFMpegVidDec * ffmpegdec)
 
       len = gst_ffmpegviddec_frame (ffmpegdec, NULL, 0, &have_data, NULL, &ret);
 
-      if (len < 0 || have_data == 0)
-        break;
-    } while (try++ < 10);
+    } while (len >= 0 && have_data == 1);
     avcodec_flush_buffers (ffmpegdec->context);
   }
 }