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.
This commit is contained in:
Sebastian Dröge 2010-08-20 12:03:44 +02:00
parent cd5527fa4e
commit ac59769604

View file

@ -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;
}