From 8b8708f9464a6bed38b5ccf24eb09279df2697e9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=ADctor=20Manuel=20J=C3=A1quez=20Leal?= Date: Thu, 9 Apr 2015 19:09:17 +0200 Subject: [PATCH] videodecoder: handle buffer's flags at offset For reverse playback it is important to handle correctly the frame sync points, which is set when the input buffer doesn't have the DELTA_UNIT flag. This is handled correctly when decoder is packetized, but when it is not the frame's sync point is not copied, and the reverse playback never decodes frame batches. The current patch adds the buffer's flags to the Timestamp list, where the timestamp and duration of the input buffers are hold. --- gst-libs/gst/video/gstvideodecoder.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/gst-libs/gst/video/gstvideodecoder.c b/gst-libs/gst/video/gstvideodecoder.c index 3dd82f0..da00a8b 100644 --- a/gst-libs/gst/video/gstvideodecoder.c +++ b/gst-libs/gst/video/gstvideodecoder.c @@ -216,7 +216,7 @@ * gather queue: 9 8 7 * D * - * Whe buffer 4 is received (with a DISCONT), we flush the gather queue like + * When buffer 4 is received (with a DISCONT), we flush the gather queue like * this: * * while (gather) @@ -1975,6 +1975,7 @@ struct _Timestamp GstClockTime pts; GstClockTime dts; GstClockTime duration; + guint flags; }; static void @@ -2001,6 +2002,7 @@ gst_video_decoder_add_timestamp (GstVideoDecoder * decoder, GstBuffer * buffer) ts->pts = GST_BUFFER_PTS (buffer); ts->dts = GST_BUFFER_DTS (buffer); ts->duration = GST_BUFFER_DURATION (buffer); + ts->flags = GST_BUFFER_FLAGS (buffer); priv->timestamps = g_list_append (priv->timestamps, ts); } @@ -2008,7 +2010,7 @@ gst_video_decoder_add_timestamp (GstVideoDecoder * decoder, GstBuffer * buffer) static void gst_video_decoder_get_timestamp_at_offset (GstVideoDecoder * decoder, guint64 offset, GstClockTime * pts, GstClockTime * dts, - GstClockTime * duration) + GstClockTime * duration, guint * flags) { #ifndef GST_DISABLE_GST_DEBUG guint64 got_offset = 0; @@ -2019,6 +2021,7 @@ gst_video_decoder_get_timestamp_at_offset (GstVideoDecoder * *pts = GST_CLOCK_TIME_NONE; *dts = GST_CLOCK_TIME_NONE; *duration = GST_CLOCK_TIME_NONE; + *flags = 0; g = decoder->priv->timestamps; while (g) { @@ -2030,6 +2033,7 @@ gst_video_decoder_get_timestamp_at_offset (GstVideoDecoder * *pts = ts->pts; *dts = ts->dts; *duration = ts->duration; + *flags = ts->flags; g = g->next; decoder->priv->timestamps = g_list_remove (decoder->priv->timestamps, ts); timestamp_free (ts); @@ -3355,6 +3359,7 @@ gst_video_decoder_have_frame (GstVideoDecoder * decoder) GstBuffer *buffer; int n_available; GstClockTime pts, dts, duration; + guint flags; GstFlowReturn ret = GST_FLOW_OK; GST_LOG_OBJECT (decoder, "have_frame"); @@ -3371,11 +3376,16 @@ gst_video_decoder_have_frame (GstVideoDecoder * decoder) priv->current_frame->input_buffer = buffer; gst_video_decoder_get_timestamp_at_offset (decoder, - priv->frame_offset, &pts, &dts, &duration); + priv->frame_offset, &pts, &dts, &duration, &flags); GST_BUFFER_PTS (buffer) = pts; GST_BUFFER_DTS (buffer) = dts; GST_BUFFER_DURATION (buffer) = duration; + GST_BUFFER_FLAGS (buffer) = flags; + + if (!GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_DELTA_UNIT)) { + GST_VIDEO_CODEC_FRAME_SET_SYNC_POINT (priv->current_frame); + } GST_LOG_OBJECT (decoder, "collected frame size %d, " "PTS %" GST_TIME_FORMAT ", DTS %" GST_TIME_FORMAT ", dur %" -- 2.7.4