intervideosrc: Set the GAP flag on repeated buffers

videorate does the same and it allows optimizations downstream.
This commit is contained in:
Sebastian Dröge 2014-11-11 11:15:35 +01:00
parent 3d1cd1011b
commit ce6222f8d4

View file

@ -308,6 +308,7 @@ gst_inter_video_src_create (GstBaseSrc * src, guint64 offset, guint size,
GstInterVideoSrc *intervideosrc = GST_INTER_VIDEO_SRC (src); GstInterVideoSrc *intervideosrc = GST_INTER_VIDEO_SRC (src);
GstCaps *caps; GstCaps *caps;
GstBuffer *buffer; GstBuffer *buffer;
gboolean is_gap = FALSE;
GST_DEBUG_OBJECT (intervideosrc, "create"); GST_DEBUG_OBJECT (intervideosrc, "create");
@ -337,8 +338,18 @@ gst_inter_video_src_create (GstBaseSrc * src, guint64 offset, guint size,
} }
if (intervideosrc->surface->video_buffer) { if (intervideosrc->surface->video_buffer) {
buffer = gst_buffer_ref (intervideosrc->surface->video_buffer); buffer = gst_buffer_ref (intervideosrc->surface->video_buffer);
/* Repeated buffer? */
if (intervideosrc->surface->video_buffer_count > 0)
is_gap = TRUE;
intervideosrc->surface->video_buffer_count++; intervideosrc->surface->video_buffer_count++;
if (intervideosrc->surface->video_buffer_count >= 30) { if (intervideosrc->surface->video_buffer_count >= 30) {
/* The first black buffer is not a GAP anymore but
* the following are */
if (intervideosrc->surface->video_buffer_count == 30)
is_gap = FALSE;
gst_buffer_unref (intervideosrc->surface->video_buffer); gst_buffer_unref (intervideosrc->surface->video_buffer);
intervideosrc->surface->video_buffer = NULL; intervideosrc->surface->video_buffer = NULL;
} }
@ -413,6 +424,9 @@ gst_inter_video_src_create (GstBaseSrc * src, guint64 offset, guint size,
buffer = gst_buffer_make_writable (buffer); buffer = gst_buffer_make_writable (buffer);
if (is_gap)
GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_FLAG_GAP);
GST_BUFFER_PTS (buffer) = intervideosrc->timestamp_offset + GST_BUFFER_PTS (buffer) = intervideosrc->timestamp_offset +
gst_util_uint64_scale (GST_SECOND * intervideosrc->n_frames, gst_util_uint64_scale (GST_SECOND * intervideosrc->n_frames,
GST_VIDEO_INFO_FPS_D (&intervideosrc->info), GST_VIDEO_INFO_FPS_D (&intervideosrc->info),