From ac5976960448a65e516934a0d538ea2abcc321ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Fri, 20 Aug 2010 12:03:44 +0200 Subject: [PATCH] videorate: Mark duplicated frames with the GAP flag We currently don't use the GAP flag for video and the docs say that this is for buffers, that have been created to fill a gap and contains neutral data. For video this is the previous frame. This information can be used by encoders to encode the duplicated frames more efficiently. See bug #627459. --- gst/videorate/gstvideorate.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/gst/videorate/gstvideorate.c b/gst/videorate/gstvideorate.c index 8b68dc5adc..f21b3afe29 100644 --- a/gst/videorate/gstvideorate.c +++ b/gst/videorate/gstvideorate.c @@ -439,7 +439,7 @@ gst_video_rate_init (GstVideoRate * videorate, GstVideoRateClass * klass) /* flush the oldest buffer */ static GstFlowReturn -gst_video_rate_flush_prev (GstVideoRate * videorate) +gst_video_rate_flush_prev (GstVideoRate * videorate, gboolean duplicate) { GstFlowReturn res; GstBuffer *outbuf; @@ -461,6 +461,11 @@ gst_video_rate_flush_prev (GstVideoRate * videorate) } else GST_BUFFER_FLAG_UNSET (outbuf, GST_BUFFER_FLAG_DISCONT); + if (duplicate) + GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_GAP); + else + GST_BUFFER_FLAG_UNSET (outbuf, GST_BUFFER_FLAG_GAP); + /* this is the timestamp we put on the buffer */ push_ts = videorate->next_ts; @@ -546,7 +551,7 @@ gst_video_rate_event (GstPad * pad, GstEvent * event) videorate->next_ts - videorate->segment.accum < videorate->segment.stop) || count < 1)) { - gst_video_rate_flush_prev (videorate); + gst_video_rate_flush_prev (videorate, count > 0); count++; } if (count > 1) { @@ -575,7 +580,7 @@ gst_video_rate_event (GstPad * pad, GstEvent * event) case GST_EVENT_EOS: /* flush last queued frame */ GST_DEBUG_OBJECT (videorate, "Got EOS"); - gst_video_rate_flush_prev (videorate); + gst_video_rate_flush_prev (videorate, FALSE); break; case GST_EVENT_FLUSH_STOP: /* also resets the segment */ @@ -771,7 +776,9 @@ gst_video_rate_chain (GstPad * pad, GstBuffer * buffer) count++; /* on error the _flush function posted a warning already */ - if ((res = gst_video_rate_flush_prev (videorate)) != GST_FLOW_OK) { + if ((res = + gst_video_rate_flush_prev (videorate, + count > 1)) != GST_FLOW_OK) { gst_buffer_unref (buffer); goto done; }