summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Schmidt <jan@centricular.com>2017-04-08 01:21:23 +1000
committerJan Schmidt <jan@centricular.com>2017-04-12 10:43:49 +1000
commitbae56fe0c2ca8212e5c3c8e5312e8b95d22c7b41 (patch)
tree999aabef1d7a7ea99a6f35fd2b5081062f4a566a
parenta7a9b33ad9a8aa4366f33b2284638142ac5a9298 (diff)
h264 decoder: Implement reset() for faster flush
Implement a custom reset() function for faster flushes that just clear the reference pictures but don't reallocate the DPB or clear out SPS/PPS https://bugzilla.gnome.org/show_bug.cgi?id=781142
-rw-r--r--gst-libs/gst/vaapi/gstvaapidecoder_h264.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/gst-libs/gst/vaapi/gstvaapidecoder_h264.c b/gst-libs/gst/vaapi/gstvaapidecoder_h264.c
index f87ac308..b97c5506 100644
--- a/gst-libs/gst/vaapi/gstvaapidecoder_h264.c
+++ b/gst-libs/gst/vaapi/gstvaapidecoder_h264.c
@@ -1258,6 +1258,37 @@ gst_vaapi_decoder_h264_create (GstVaapiDecoder * base_decoder)
return TRUE;
}
+/* Limited reset can just needs to get the decoder
+ * ready to process fresh data after a flush.
+ * Preserves the existing DPB allocation and any SPS/PPS */
+static GstVaapiDecoderStatus
+gst_vaapi_decoder_h264_reset (GstVaapiDecoder * base_decoder)
+{
+ GstVaapiDecoderH264 *const decoder =
+ GST_VAAPI_DECODER_H264_CAST (base_decoder);
+ GstVaapiDecoderH264Private *const priv = &decoder->priv;
+
+ gst_vaapi_decoder_h264_close (decoder);
+ priv->is_opened = FALSE;
+
+ priv->dpb_size = 0;
+
+ g_free (priv->prev_ref_frames);
+ priv->prev_ref_frames = NULL;
+ g_free (priv->prev_frames);
+ priv->prev_frames = NULL;
+ priv->prev_frames_alloc = 0;
+
+ priv->profile = GST_VAAPI_PROFILE_UNKNOWN;
+ priv->entrypoint = GST_VAAPI_ENTRYPOINT_VLD;
+ priv->chroma_type = GST_VAAPI_CHROMA_TYPE_YUV420;
+ priv->prev_pic_structure = GST_VAAPI_PICTURE_STRUCTURE_FRAME;
+ priv->progressive_sequence = TRUE;
+ priv->top_field_first = FALSE;
+
+ return GST_VAAPI_DECODER_STATUS_SUCCESS;
+}
+
/* Activates the supplied PPS */
static GstH264PPS *
ensure_pps (GstVaapiDecoderH264 * decoder, GstH264PPS * pps)
@@ -4658,6 +4689,7 @@ gst_vaapi_decoder_h264_class_init (GstVaapiDecoderH264Class * klass)
decoder_class->create = gst_vaapi_decoder_h264_create;
decoder_class->destroy = gst_vaapi_decoder_h264_destroy;
+ decoder_class->reset = gst_vaapi_decoder_h264_reset;
decoder_class->parse = gst_vaapi_decoder_h264_parse;
decoder_class->decode = gst_vaapi_decoder_h264_decode;
decoder_class->start_frame = gst_vaapi_decoder_h264_start_frame;