From 3730ea33660a56537998e8e061d91f4b4b4b18ef Mon Sep 17 00:00:00 2001 From: Seungha Yang Date: Thu, 4 Mar 2021 17:42:28 +0900 Subject: [PATCH] d3d11h264dec: Keep track of actually configured DPB size ... instead of the largest we ever seen. Note that d3d11h264dec element holds previously configured DPB size for later decoder object re-open decision. This is to fix below case: 1) Initial SPS, required DPB size is 6 - decoder object is opened with DPB size 6 - max_dpb_size is now 6 2) SPS update with resolution change, required DPB size is 1 - decoder object is re-opened with DPB size 1 - max_dpb_size should be updated to 1, but it didn't happen (BUG) 3) SPS update without resolution change, only required DPB size is updated to 6 - decoder object should be re-opened but didn't happen because we didn't update max_dpb_size at 2). Part-of: --- sys/d3d11/gstd3d11h264dec.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sys/d3d11/gstd3d11h264dec.c b/sys/d3d11/gstd3d11h264dec.c index 104a5f13d4..138dcbec04 100644 --- a/sys/d3d11/gstd3d11h264dec.c +++ b/sys/d3d11/gstd3d11h264dec.c @@ -470,7 +470,6 @@ gst_d3d11_h264_dec_new_sequence (GstH264Decoder * decoder, 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); - self->max_dpb_size = max_dpb_size; modified = TRUE; } @@ -501,6 +500,12 @@ gst_d3d11_h264_dec_new_sequence (GstH264Decoder * decoder, gst_video_info_set_format (&info, self->out_format, self->width, self->height); + /* Store configured DPB size here. Then, it will be referenced later + * to decide whether we need to re-open decoder object or not. + * For instance, if every configuration is same apart from DPB size and + * new DPB size is decreased, we can reuse existing decoder object. + */ + self->max_dpb_size = max_dpb_size; gst_d3d11_decoder_reset (self->d3d11_decoder); if (!gst_d3d11_decoder_open (self->d3d11_decoder, GST_D3D11_CODEC_H264, &info, self->coded_width, self->coded_height,