From b4c19a96b71cd6205a9ac955d9d963cd4dd19996 Mon Sep 17 00:00:00 2001 From: Seungha Yang Date: Sat, 5 Nov 2022 21:00:43 +0900 Subject: [PATCH] nvdecoder: Don't hold decoder output state It's not referenced by this implementation Part-of: --- subprojects/gst-plugins-bad/sys/nvcodec/gstnvav1dec.c | 6 +----- subprojects/gst-plugins-bad/sys/nvcodec/gstnvdecoder.c | 9 +++------ subprojects/gst-plugins-bad/sys/nvcodec/gstnvdecoder.h | 3 +-- subprojects/gst-plugins-bad/sys/nvcodec/gstnvh264dec.c | 6 +----- subprojects/gst-plugins-bad/sys/nvcodec/gstnvh265dec.c | 6 +----- subprojects/gst-plugins-bad/sys/nvcodec/gstnvvp8dec.c | 6 +----- subprojects/gst-plugins-bad/sys/nvcodec/gstnvvp9dec.c | 6 +----- 7 files changed, 9 insertions(+), 33 deletions(-) diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvav1dec.c b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvav1dec.c index bf717ecf98..d200cfe0fa 100644 --- a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvav1dec.c +++ b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvav1dec.c @@ -50,8 +50,6 @@ typedef struct _GstNvAV1Dec { GstAV1Decoder parent; - GstVideoCodecState *output_state; - GstCudaContext *context; GstNvDecoder *decoder; @@ -266,7 +264,6 @@ gst_nv_av1_dec_close (GstVideoDecoder * decoder) { GstNvAV1Dec *self = GST_NV_AV1_DEC (decoder); - g_clear_pointer (&self->output_state, gst_video_codec_state_unref); gst_clear_object (&self->decoder); gst_clear_object (&self->context); @@ -292,8 +289,7 @@ gst_nv_av1_dec_negotiate (GstVideoDecoder * decoder) GST_DEBUG_OBJECT (self, "negotiate"); - gst_nv_decoder_negotiate (self->decoder, decoder, av1dec->input_state, - &self->output_state); + gst_nv_decoder_negotiate (self->decoder, decoder, av1dec->input_state); return GST_VIDEO_DECODER_CLASS (parent_class)->negotiate (decoder); } diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvdecoder.c b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvdecoder.c index bbffc7b12e..6284e2a90d 100644 --- a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvdecoder.c +++ b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvdecoder.c @@ -1454,8 +1454,7 @@ gst_nv_decoder_ensure_gl_context (GstNvDecoder * decoder, GstElement * videodec) gboolean gst_nv_decoder_negotiate (GstNvDecoder * decoder, - GstVideoDecoder * videodec, GstVideoCodecState * input_state, - GstVideoCodecState ** output_state) + GstVideoDecoder * videodec, GstVideoCodecState * input_state) { GstVideoCodecState *state; GstVideoInfo *info; @@ -1463,7 +1462,6 @@ gst_nv_decoder_negotiate (GstNvDecoder * decoder, g_return_val_if_fail (GST_IS_NV_DECODER (decoder), FALSE); g_return_val_if_fail (GST_IS_VIDEO_DECODER (videodec), FALSE); g_return_val_if_fail (input_state != NULL, FALSE); - g_return_val_if_fail (output_state != NULL, FALSE); if (!decoder->configured) { GST_ERROR_OBJECT (videodec, "Should configure decoder first"); @@ -1476,9 +1474,8 @@ gst_nv_decoder_negotiate (GstNvDecoder * decoder, GST_VIDEO_INFO_WIDTH (info), GST_VIDEO_INFO_HEIGHT (info), input_state); state->caps = gst_video_info_to_caps (&state->info); - if (*output_state) - gst_video_codec_state_unref (*output_state); - *output_state = state; + /* decoder baseclass will hold other reference to output state */ + gst_video_codec_state_unref (state); decoder->output_type = GST_NV_DECODER_OUTPUT_TYPE_SYSTEM; diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvdecoder.h b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvdecoder.h index 635b301192..64758af91e 100644 --- a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvdecoder.h +++ b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvdecoder.h @@ -102,8 +102,7 @@ gboolean gst_nv_decoder_handle_context_query (GstNvDecoder * decoder, gboolean gst_nv_decoder_negotiate (GstNvDecoder * decoder, GstVideoDecoder * videodec, - GstVideoCodecState * input_state, - GstVideoCodecState ** output_state); + GstVideoCodecState * input_state); gboolean gst_nv_decoder_decide_allocation (GstNvDecoder * decoder, GstVideoDecoder * videodec, diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvh264dec.c b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvh264dec.c index 61e9296c84..4e92702fde 100644 --- a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvh264dec.c +++ b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvh264dec.c @@ -103,8 +103,6 @@ typedef struct _GstNvH264Dec { GstH264Decoder parent; - GstVideoCodecState *output_state; - GstCudaContext *context; GstNvDecoder *decoder; CUVIDPICPARAMS params; @@ -354,7 +352,6 @@ gst_nv_h264_dec_close (GstVideoDecoder * decoder) { GstNvH264Dec *self = GST_NV_H264_DEC (decoder); - g_clear_pointer (&self->output_state, gst_video_codec_state_unref); gst_clear_object (&self->decoder); gst_clear_object (&self->context); @@ -375,8 +372,7 @@ gst_nv_h264_dec_negotiate (GstVideoDecoder * decoder) GST_DEBUG_OBJECT (self, "negotiate"); - gst_nv_decoder_negotiate (self->decoder, decoder, h264dec->input_state, - &self->output_state); + gst_nv_decoder_negotiate (self->decoder, decoder, h264dec->input_state); /* TODO: add support D3D11 memory */ diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvh265dec.c b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvh265dec.c index 0bba5b33da..9e5f2d4500 100644 --- a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvh265dec.c +++ b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvh265dec.c @@ -102,8 +102,6 @@ typedef struct _GstNvH265Dec { GstH265Decoder parent; - GstVideoCodecState *output_state; - GstCudaContext *context; GstNvDecoder *decoder; CUVIDPICPARAMS params; @@ -311,7 +309,6 @@ gst_nv_h265_dec_close (GstVideoDecoder * decoder) { GstNvH265Dec *self = GST_NV_H265_DEC (decoder); - g_clear_pointer (&self->output_state, gst_video_codec_state_unref); gst_clear_object (&self->decoder); gst_clear_object (&self->context); @@ -332,8 +329,7 @@ gst_nv_h265_dec_negotiate (GstVideoDecoder * decoder) GST_DEBUG_OBJECT (self, "negotiate"); - gst_nv_decoder_negotiate (self->decoder, decoder, h265dec->input_state, - &self->output_state); + gst_nv_decoder_negotiate (self->decoder, decoder, h265dec->input_state); /* TODO: add support D3D11 memory */ diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvvp8dec.c b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvvp8dec.c index 520c1697f1..9db15bb302 100644 --- a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvvp8dec.c +++ b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvvp8dec.c @@ -50,8 +50,6 @@ typedef struct _GstNvVp8Dec { GstVp8Decoder parent; - GstVideoCodecState *output_state; - GstCudaContext *context; GstNvDecoder *decoder; CUVIDPICPARAMS params; @@ -235,7 +233,6 @@ gst_nv_vp8_dec_close (GstVideoDecoder * decoder) { GstNvVp8Dec *self = GST_NV_VP8_DEC (decoder); - g_clear_pointer (&self->output_state, gst_video_codec_state_unref); gst_clear_object (&self->decoder); gst_clear_object (&self->context); @@ -250,8 +247,7 @@ gst_nv_vp8_dec_negotiate (GstVideoDecoder * decoder) GST_DEBUG_OBJECT (self, "negotiate"); - gst_nv_decoder_negotiate (self->decoder, decoder, vp8dec->input_state, - &self->output_state); + gst_nv_decoder_negotiate (self->decoder, decoder, vp8dec->input_state); /* TODO: add support D3D11 memory */ diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvvp9dec.c b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvvp9dec.c index c21fbd351b..009adac922 100644 --- a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvvp9dec.c +++ b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvvp9dec.c @@ -50,8 +50,6 @@ typedef struct _GstNvVp9Dec { GstVp9Decoder parent; - GstVideoCodecState *output_state; - GstCudaContext *context; GstNvDecoder *decoder; CUVIDPICPARAMS params; @@ -245,7 +243,6 @@ gst_nv_vp9_dec_close (GstVideoDecoder * decoder) { GstNvVp9Dec *self = GST_NV_VP9_DEC (decoder); - g_clear_pointer (&self->output_state, gst_video_codec_state_unref); gst_clear_object (&self->decoder); gst_clear_object (&self->context); @@ -260,8 +257,7 @@ gst_nv_vp9_dec_negotiate (GstVideoDecoder * decoder) GST_DEBUG_OBJECT (self, "negotiate"); - gst_nv_decoder_negotiate (self->decoder, decoder, vp9dec->input_state, - &self->output_state); + gst_nv_decoder_negotiate (self->decoder, decoder, vp9dec->input_state); /* TODO: add support D3D11 memory */