From 9da6da20e788a96070d9193fa431a5b4f92a1cc2 Mon Sep 17 00:00:00 2001 From: Seungha Yang Date: Sun, 7 Mar 2021 16:47:07 +0900 Subject: [PATCH] nvh264sldec: Reopen decoder object if larger DPB size is required Equivalent to the d3d11h264dec fix https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1839 Part-of: --- sys/nvcodec/gstnvh264dec.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/sys/nvcodec/gstnvh264dec.c b/sys/nvcodec/gstnvh264dec.c index 1b7bbd81e6..7d8f7ff15a 100644 --- a/sys/nvcodec/gstnvh264dec.c +++ b/sys/nvcodec/gstnvh264dec.c @@ -112,6 +112,7 @@ struct _GstNvH264Dec guint coded_width, coded_height; guint bitdepth; guint chroma_format_idc; + gint max_dpb_size; GstVideoFormat out_format; /* For OpenGL interop. */ @@ -237,6 +238,20 @@ gst_nv_h264_dec_set_context (GstElement * element, GstContext * context) GST_ELEMENT_CLASS (parent_class)->set_context (element, context); } +/* Clear all codec specific (e.g., SPS) data */ +static void +gst_d3d11_h264_dec_reset (GstNvH264Dec * self) +{ + self->width = 0; + self->height = 0; + self->coded_width = 0; + self->coded_height = 0; + self->bitdepth = 0; + self->chroma_format_idc = 0; + self->out_format = GST_VIDEO_FORMAT_UNKNOWN; + self->max_dpb_size = 0; +} + static gboolean gst_nv_h264_dec_open (GstVideoDecoder * decoder) { @@ -250,6 +265,8 @@ gst_nv_h264_dec_open (GstVideoDecoder * decoder) return FALSE; } + gst_d3d11_h264_dec_reset (self); + return TRUE; } @@ -367,6 +384,12 @@ gst_nv_h264_dec_new_sequence (GstH264Decoder * decoder, const GstH264SPS * sps, modified = TRUE; } + if (self->max_dpb_size < max_dpb_size) { + GST_INFO_OBJECT (self, "Requires larger DPB size (%d -> %d)", + self->max_dpb_size, max_dpb_size); + modified = TRUE; + } + if (modified || !self->decoder) { GstVideoInfo info; @@ -396,6 +419,7 @@ gst_nv_h264_dec_new_sequence (GstH264Decoder * decoder, const GstH264SPS * sps, gst_video_info_set_format (&info, self->out_format, self->width, self->height); + self->max_dpb_size = max_dpb_size; /* FIXME: add support cudaVideoCodec_H264_SVC and cudaVideoCodec_H264_MVC */ self->decoder = gst_nv_decoder_new (self->context, cudaVideoCodec_H264, &info,