From 0e4c520cf3a7829d4238e4a0a745988cd1825000 Mon Sep 17 00:00:00 2001 From: Seungha Yang Date: Sat, 5 Nov 2022 21:06:39 +0900 Subject: [PATCH] nvdecoder: Handle input caps change Update output caps if it's notified by baseclass Part-of: --- subprojects/gst-plugins-bad/sys/nvcodec/gstnvav1dec.c | 4 ++-- subprojects/gst-plugins-bad/sys/nvcodec/gstnvdecoder.c | 10 +++++++++- subprojects/gst-plugins-bad/sys/nvcodec/gstnvdecoder.h | 1 + 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 | 4 ++-- subprojects/gst-plugins-bad/sys/nvcodec/gstnvvp9dec.c | 4 ++-- 7 files changed, 20 insertions(+), 11 deletions(-) diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvav1dec.c b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvav1dec.c index d200cfe0fa..31e23ebcff 100644 --- a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvav1dec.c +++ b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvav1dec.c @@ -863,8 +863,8 @@ gst_nv_av1_dec_output_picture (GstAV1Decoder * decoder, goto error; } - if (!gst_nv_decoder_finish_frame (self->decoder, vdec, decoder_frame, - &frame->output_buffer)) { + if (!gst_nv_decoder_finish_frame (self->decoder, vdec, picture->discont_state, + decoder_frame, &frame->output_buffer)) { GST_ERROR_OBJECT (self, "Failed to handle output picture"); goto error; } diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvdecoder.c b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvdecoder.c index 6284e2a90d..d39938c1c0 100644 --- a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvdecoder.c +++ b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvdecoder.c @@ -819,7 +819,8 @@ done: gboolean gst_nv_decoder_finish_frame (GstNvDecoder * decoder, GstVideoDecoder * videodec, - GstNvDecoderFrame * frame, GstBuffer ** buffer) + GstVideoCodecState * input_state, GstNvDecoderFrame * frame, + GstBuffer ** buffer) { GstBuffer *outbuf = NULL; gboolean ret = FALSE; @@ -829,6 +830,13 @@ gst_nv_decoder_finish_frame (GstNvDecoder * decoder, GstVideoDecoder * videodec, g_return_val_if_fail (frame != NULL, GST_FLOW_ERROR); g_return_val_if_fail (buffer != NULL, GST_FLOW_ERROR); + if (input_state) { + if (!gst_nv_decoder_negotiate (decoder, videodec, input_state)) { + GST_ERROR_OBJECT (videodec, "Couldn't re-negotiate with updated state"); + return FALSE; + } + } + outbuf = gst_video_decoder_allocate_output_buffer (videodec); if (!outbuf) { GST_ERROR_OBJECT (videodec, "Couldn't allocate output buffer"); diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvdecoder.h b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvdecoder.h index 64758af91e..b30ceafec9 100644 --- a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvdecoder.h +++ b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvdecoder.h @@ -80,6 +80,7 @@ gboolean gst_nv_decoder_decode_picture (GstNvDecoder * decoder, gboolean gst_nv_decoder_finish_frame (GstNvDecoder * decoder, GstVideoDecoder * videodec, + GstVideoCodecState * input_state, GstNvDecoderFrame *frame, GstBuffer ** buffer); diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvh264dec.c b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvh264dec.c index 4e92702fde..f34da14420 100644 --- a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvh264dec.c +++ b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvh264dec.c @@ -578,8 +578,8 @@ gst_nv_h264_dec_output_picture (GstH264Decoder * decoder, goto error; } - if (!gst_nv_decoder_finish_frame (self->decoder, vdec, decoder_frame, - &frame->output_buffer)) { + if (!gst_nv_decoder_finish_frame (self->decoder, vdec, picture->discont_state, + decoder_frame, &frame->output_buffer)) { GST_ERROR_OBJECT (self, "Failed to handle output picture"); goto error; } diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvh265dec.c b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvh265dec.c index 9e5f2d4500..918f13ccf4 100644 --- a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvh265dec.c +++ b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvh265dec.c @@ -508,8 +508,8 @@ gst_nv_h265_dec_output_picture (GstH265Decoder * decoder, goto error; } - if (!gst_nv_decoder_finish_frame (self->decoder, vdec, decoder_frame, - &frame->output_buffer)) { + if (!gst_nv_decoder_finish_frame (self->decoder, vdec, picture->discont_state, + decoder_frame, &frame->output_buffer)) { GST_ERROR_OBJECT (self, "Failed to handle output picture"); goto error; } diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvvp8dec.c b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvvp8dec.c index 9db15bb302..f4a8ed4f62 100644 --- a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvvp8dec.c +++ b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvvp8dec.c @@ -478,8 +478,8 @@ gst_nv_vp8_dec_output_picture (GstVp8Decoder * decoder, goto error; } - if (!gst_nv_decoder_finish_frame (self->decoder, vdec, decoder_frame, - &frame->output_buffer)) { + if (!gst_nv_decoder_finish_frame (self->decoder, vdec, picture->discont_state, + decoder_frame, &frame->output_buffer)) { GST_ERROR_OBJECT (self, "Failed to handle output picture"); goto error; } diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvvp9dec.c b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvvp9dec.c index 009adac922..75bb956db2 100644 --- a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvvp9dec.c +++ b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvvp9dec.c @@ -573,8 +573,8 @@ gst_nv_vp9_dec_output_picture (GstVp9Decoder * decoder, goto error; } - if (!gst_nv_decoder_finish_frame (self->decoder, vdec, decoder_frame, - &frame->output_buffer)) { + if (!gst_nv_decoder_finish_frame (self->decoder, vdec, picture->discont_state, + decoder_frame, &frame->output_buffer)) { GST_ERROR_OBJECT (self, "Failed to handle output picture"); goto error; }