From 29aab904a8ed78dd75bcb912759f3ce25b98ab0a Mon Sep 17 00:00:00 2001 From: Seungha Yang Date: Mon, 2 May 2022 22:46:06 +0900 Subject: [PATCH] nvdecoder: Handle DPB size margin in a single place ... instead of each subclass Part-of: --- subprojects/gst-plugins-bad/sys/nvcodec/gstnvdecoder.c | 3 +++ subprojects/gst-plugins-bad/sys/nvcodec/gstnvh264dec.c | 4 +--- subprojects/gst-plugins-bad/sys/nvcodec/gstnvh265dec.c | 4 +--- subprojects/gst-plugins-bad/sys/nvcodec/gstnvvp8dec.c | 6 +----- subprojects/gst-plugins-bad/sys/nvcodec/gstnvvp9dec.c | 7 +------ 5 files changed, 7 insertions(+), 17 deletions(-) diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvdecoder.c b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvdecoder.c index 0ebeb01f0a..cf1436da39 100644 --- a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvdecoder.c +++ b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvdecoder.c @@ -276,6 +276,9 @@ gst_nv_decoder_configure (GstNvDecoder * decoder, cudaVideoCodec codec, format = GST_VIDEO_INFO_FORMAT (info); + /* Additional 2 frame margin */ + pool_size += 2; + /* FIXME: check aligned resolution or actual coded resolution */ create_info.ulWidth = GST_VIDEO_INFO_WIDTH (&decoder->coded_info); create_info.ulHeight = GST_VIDEO_INFO_HEIGHT (&decoder->coded_info); diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvh264dec.c b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvh264dec.c index 8b37b6f2ad..1d3edc1a73 100644 --- a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvh264dec.c +++ b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvh264dec.c @@ -447,9 +447,7 @@ gst_nv_h264_dec_new_sequence (GstH264Decoder * decoder, const GstH264SPS * sps, /* FIXME: add support cudaVideoCodec_H264_SVC and cudaVideoCodec_H264_MVC */ if (!gst_nv_decoder_configure (self->decoder, cudaVideoCodec_H264, &info, self->coded_width, self->coded_height, - self->bitdepth, - /* Additional 4 buffers for render delay */ - max_dpb_size + 4)) { + self->bitdepth, max_dpb_size)) { GST_ERROR_OBJECT (self, "Failed to configure decoder"); return GST_FLOW_NOT_NEGOTIATED; } diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvh265dec.c b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvh265dec.c index d6c3d56b60..4fce77bbb6 100644 --- a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvh265dec.c +++ b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvh265dec.c @@ -399,9 +399,7 @@ gst_nv_h265_dec_new_sequence (GstH265Decoder * decoder, const GstH265SPS * sps, if (!gst_nv_decoder_configure (self->decoder, cudaVideoCodec_HEVC, &info, self->coded_width, self->coded_height, - self->bitdepth, - /* Additional 2 buffers for margin */ - max_dpb_size + 2)) { + self->bitdepth, max_dpb_size)) { GST_ERROR_OBJECT (self, "Failed to configure decoder"); return GST_FLOW_NOT_NEGOTIATED; } diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvvp8dec.c b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvvp8dec.c index d11fc8d512..0f05b08bc9 100644 --- a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvvp8dec.c +++ b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvvp8dec.c @@ -31,9 +31,6 @@ GST_DEBUG_CATEGORY_STATIC (gst_nv_vp8_dec_debug); #define GST_CAT_DEFAULT gst_nv_vp8_dec_debug -/* reference list 4 + 2 margin */ -#define NUM_OUTPUT_VIEW 6 - struct _GstNvVp8Dec { GstVp8Decoder parent; @@ -259,8 +256,7 @@ gst_nv_vp8_dec_new_sequence (GstVp8Decoder * decoder, if (!gst_nv_decoder_configure (self->decoder, cudaVideoCodec_VP8, &info, self->width, self->height, 8, - /* +4 for render delay */ - NUM_OUTPUT_VIEW + 4)) { + max_dpb_size)) { GST_ERROR_OBJECT (self, "Failed to configure decoder"); return GST_FLOW_NOT_NEGOTIATED; } diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvvp9dec.c b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvvp9dec.c index 6967859786..d1724578b8 100644 --- a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvvp9dec.c +++ b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvvp9dec.c @@ -31,9 +31,6 @@ GST_DEBUG_CATEGORY_STATIC (gst_nv_vp9_dec_debug); #define GST_CAT_DEFAULT gst_nv_vp9_dec_debug -/* reference list 8 + 2 margin */ -#define NUM_OUTPUT_VIEW 10 - struct _GstNvVp9Dec { GstVp9Decoder parent; @@ -272,9 +269,7 @@ gst_nv_vp9_dec_new_sequence (GstVp9Decoder * decoder, gst_video_info_set_format (&info, out_format, self->width, self->height); if (!gst_nv_decoder_configure (self->decoder, cudaVideoCodec_VP9, &info, self->width, self->height, - frame_hdr->bit_depth, - /* +4 for render delay */ - NUM_OUTPUT_VIEW + 4)) { + frame_hdr->bit_depth, max_dpb_size)) { GST_ERROR_OBJECT (self, "Failed to configure decoder"); return GST_FLOW_NOT_NEGOTIATED; } -- 2.34.1