From 0847b3888d42b3680c43d06cba84d69e67fb3c3b Mon Sep 17 00:00:00 2001 From: Sreerenj Balachandran Date: Thu, 24 Jan 2013 00:49:17 +0200 Subject: [PATCH] vaapidecode: add support for post-seek semantics reset. Implement GstVideoDecoder::reset() as a destruction of the VA decoder and the creation of a new VA decoder. Signed-off-by: Gwenole Beauchesne --- gst/vaapi/gstvaapidecode.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/gst/vaapi/gstvaapidecode.c b/gst/vaapi/gstvaapidecode.c index 45f1b8e741..c7a353bac0 100644 --- a/gst/vaapi/gstvaapidecode.c +++ b/gst/vaapi/gstvaapidecode.c @@ -391,12 +391,18 @@ gst_vaapidecode_destroy(GstVaapiDecode *decode) } static gboolean -gst_vaapidecode_reset(GstVaapiDecode *decode, GstCaps *caps) +gst_vaapidecode_reset_full(GstVaapiDecode *decode, GstCaps *caps, gboolean hard) { GstVaapiCodec codec; + /* Reset timers if hard reset was requested (e.g. seek) */ + if (hard) { + decode->render_time_base = 0; + decode->last_buffer_time = 0; + } + /* Only reset decoder if codec type changed */ - if (decode->decoder && decode->decoder_caps) { + else if (decode->decoder && decode->decoder_caps) { if (gst_caps_is_always_compatible(caps, decode->decoder_caps)) return TRUE; codec = gst_vaapi_codec_from_caps(caps); @@ -480,6 +486,14 @@ gst_vaapidecode_close(GstVideoDecoder *vdec) return TRUE; } +static gboolean +gst_vaapidecode_reset(GstVideoDecoder *vdec, gboolean hard) +{ + GstVaapiDecode * const decode = GST_VAAPIDECODE(vdec); + + return gst_vaapidecode_reset_full(decode, decode->sinkpad_caps, hard); +} + static gboolean gst_vaapidecode_set_format(GstVideoDecoder *vdec, GstVideoCodecState *state) { @@ -489,7 +503,7 @@ gst_vaapidecode_set_format(GstVideoDecoder *vdec, GstVideoCodecState *state) return FALSE; if (!gst_vaapidecode_update_src_caps(decode, state)) return FALSE; - if (!gst_vaapidecode_reset(decode, decode->sinkpad_caps)) + if (!gst_vaapidecode_reset_full(decode, decode->sinkpad_caps, FALSE)) return FALSE; return TRUE; } @@ -549,6 +563,7 @@ gst_vaapidecode_class_init(GstVaapiDecodeClass *klass) vdec_class->open = GST_DEBUG_FUNCPTR(gst_vaapidecode_open); vdec_class->close = GST_DEBUG_FUNCPTR(gst_vaapidecode_close); vdec_class->set_format = GST_DEBUG_FUNCPTR(gst_vaapidecode_set_format); + vdec_class->reset = GST_DEBUG_FUNCPTR(gst_vaapidecode_reset); vdec_class->parse = GST_DEBUG_FUNCPTR(gst_vaapidecode_parse); vdec_class->handle_frame = GST_DEBUG_FUNCPTR(gst_vaapidecode_handle_frame); vdec_class->finish = GST_DEBUG_FUNCPTR(gst_vaapidecode_finish);