vaapipostproc: don't crash with dynamic framerate (0/1).
authorGwenole Beauchesne <gwenole.beauchesne@intel.com>
Thu, 19 Jun 2014 11:35:23 +0000 (13:35 +0200)
committerGwenole Beauchesne <gwenole.beauchesne@intel.com>
Thu, 19 Jun 2014 12:51:01 +0000 (14:51 +0200)
Avoid reaching an assert if dynamic framerates (0/1) are used. One
way to solve this problem is to just stick field_duration to zero.
However, this means that, in presence of interlaced streams, the
very first field will never be displayed if precise presentation
timestamps are honoured.

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

gst/vaapi/gstvaapipostproc.c

index 73e1ea3..aa0cb98 100644 (file)
@@ -522,7 +522,8 @@ gst_vaapipostproc_process_vpp(GstBaseTransform *trans, GstBuffer *inbuf,
         /* Reset deinterlacing state when there is a discontinuity */
         if (prev_buf && (prev_pts = GST_BUFFER_TIMESTAMP(prev_buf)) != pts) {
             const GstClockTimeDiff pts_diff = GST_CLOCK_DIFF(prev_pts, pts);
-            if (pts_diff < 0 || pts_diff > postproc->field_duration * 2)
+            if (pts_diff < 0 || (postproc->field_duration > 0 &&
+                    pts_diff > postproc->field_duration * 2))
                 ds_reset(ds);
         }
     }
@@ -823,9 +824,9 @@ gst_vaapipostproc_update_sink_caps(GstVaapiPostproc *postproc, GstCaps *caps,
     deinterlace = is_deinterlace_enabled(postproc, &vi);
     if (deinterlace)
         postproc->flags |= GST_VAAPI_POSTPROC_FLAG_DEINTERLACE;
-    postproc->field_duration = gst_util_uint64_scale(
-        GST_SECOND, GST_VIDEO_INFO_FPS_D(&vi),
-        (1 + deinterlace) * GST_VIDEO_INFO_FPS_N(&vi));
+    postproc->field_duration = GST_VIDEO_INFO_FPS_N(&vi) > 0 ?
+        gst_util_uint64_scale(GST_SECOND, GST_VIDEO_INFO_FPS_D(&vi),
+            (1 + deinterlace) * GST_VIDEO_INFO_FPS_N(&vi)) : 0;
 
     postproc->is_raw_yuv = GST_VIDEO_INFO_IS_YUV(&vi);
     return TRUE;