From 349f8de13ed4c7436d0fa55995b67c6ee12b59d1 Mon Sep 17 00:00:00 2001 From: Seungha Yang Date: Sat, 5 Nov 2022 02:47:54 +0900 Subject: [PATCH] d3d11decoder: Handle input caps change Update output caps if it's notified by baseclass Part-of: --- .../gst-plugins-bad/sys/d3d11/gstd3d11av1dec.cpp | 5 +++-- .../gst-plugins-bad/sys/d3d11/gstd3d11decoder.cpp | 13 ++++++++++++- .../gst-plugins-bad/sys/d3d11/gstd3d11decoder.h | 1 + .../gst-plugins-bad/sys/d3d11/gstd3d11h264dec.cpp | 3 ++- .../gst-plugins-bad/sys/d3d11/gstd3d11h265dec.cpp | 3 ++- .../gst-plugins-bad/sys/d3d11/gstd3d11mpeg2dec.cpp | 3 ++- .../gst-plugins-bad/sys/d3d11/gstd3d11vp8dec.cpp | 3 ++- .../gst-plugins-bad/sys/d3d11/gstd3d11vp9dec.cpp | 4 ++-- 8 files changed, 26 insertions(+), 9 deletions(-) diff --git a/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11av1dec.cpp b/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11av1dec.cpp index 7c3be5e79b..b178361640 100644 --- a/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11av1dec.cpp +++ b/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11av1dec.cpp @@ -1225,8 +1225,9 @@ gst_d3d11_av1_dec_output_picture (GstAV1Decoder * decoder, } if (!gst_d3d11_decoder_process_output (inner->d3d11_decoder, vdec, - picture->frame_hdr.render_width, picture->frame_hdr.render_height, - view_buffer, &frame->output_buffer)) { + picture->discont_state, picture->frame_hdr.render_width, + picture->frame_hdr.render_height, view_buffer, + &frame->output_buffer)) { GST_ERROR_OBJECT (self, "Failed to copy buffer"); goto error; } diff --git a/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11decoder.cpp b/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11decoder.cpp index 765172bf61..c9190726e5 100644 --- a/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11decoder.cpp +++ b/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11decoder.cpp @@ -1592,7 +1592,8 @@ gst_d3d11_decoder_crop_and_copy_buffer (GstD3D11Decoder * self, gboolean gst_d3d11_decoder_process_output (GstD3D11Decoder * decoder, - GstVideoDecoder * videodec, gint display_width, gint display_height, + GstVideoDecoder * videodec, GstVideoCodecState * input_state, + gint display_width, gint display_height, GstBuffer * decoder_buffer, GstBuffer ** output) { g_return_val_if_fail (GST_IS_D3D11_DECODER (decoder), FALSE); @@ -1600,6 +1601,11 @@ gst_d3d11_decoder_process_output (GstD3D11Decoder * decoder, g_return_val_if_fail (GST_IS_BUFFER (decoder_buffer), FALSE); g_return_val_if_fail (output != NULL, FALSE); + if (input_state) { + g_clear_pointer (&decoder->input_state, gst_video_codec_state_unref); + decoder->input_state = gst_video_codec_state_ref (input_state); + } + if (display_width != GST_VIDEO_INFO_WIDTH (&decoder->output_info) || display_height != GST_VIDEO_INFO_HEIGHT (&decoder->output_info)) { GST_INFO_OBJECT (videodec, "Frame size changed, do renegotiate"); @@ -1613,6 +1619,11 @@ gst_d3d11_decoder_process_output (GstD3D11Decoder * decoder, GST_ERROR_OBJECT (videodec, "Failed to re-negotiate with new frame size"); return FALSE; } + } else if (input_state) { + if (!gst_video_decoder_negotiate (videodec)) { + GST_ERROR_OBJECT (videodec, "Could not re-negotiate with updated state"); + return FALSE; + } } if (gst_d3d11_decoder_can_direct_render (decoder, videodec, decoder_buffer, diff --git a/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11decoder.h b/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11decoder.h index 8b2ceb6c15..d1e52b76e2 100644 --- a/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11decoder.h +++ b/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11decoder.h @@ -97,6 +97,7 @@ ID3D11VideoDecoderOutputView * gst_d3d11_decoder_get_output_view_from_buffer (Gs gboolean gst_d3d11_decoder_process_output (GstD3D11Decoder * decoder, GstVideoDecoder * videodec, + GstVideoCodecState * in_state, gint display_width, gint display_height, GstBuffer * decoder_buffer, diff --git a/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11h264dec.cpp b/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11h264dec.cpp index 100ead5db6..43499ad4ae 100644 --- a/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11h264dec.cpp +++ b/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11h264dec.cpp @@ -885,7 +885,8 @@ gst_d3d11_h264_dec_output_picture (GstH264Decoder * decoder, } if (!gst_d3d11_decoder_process_output (inner->d3d11_decoder, vdec, - inner->width, inner->height, view_buffer, &frame->output_buffer)) { + picture->discont_state, inner->width, inner->height, view_buffer, + &frame->output_buffer)) { GST_ERROR_OBJECT (self, "Failed to copy buffer"); goto error; } diff --git a/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11h265dec.cpp b/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11h265dec.cpp index 563fc66962..67c68979d2 100644 --- a/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11h265dec.cpp +++ b/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11h265dec.cpp @@ -933,7 +933,8 @@ gst_d3d11_h265_dec_output_picture (GstH265Decoder * decoder, } if (!gst_d3d11_decoder_process_output (inner->d3d11_decoder, vdec, - inner->width, inner->height, view_buffer, &frame->output_buffer)) { + picture->discont_state, inner->width, inner->height, view_buffer, + &frame->output_buffer)) { GST_ERROR_OBJECT (self, "Failed to copy buffer"); goto error; } diff --git a/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11mpeg2dec.cpp b/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11mpeg2dec.cpp index 55498534a0..54406f7d1a 100644 --- a/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11mpeg2dec.cpp +++ b/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11mpeg2dec.cpp @@ -747,7 +747,8 @@ gst_d3d11_mpeg2_dec_output_picture (GstMpeg2Decoder * decoder, } if (!gst_d3d11_decoder_process_output (inner->d3d11_decoder, vdec, - inner->width, inner->height, view_buffer, &frame->output_buffer)) { + picture->discont_state, inner->width, inner->height, view_buffer, + &frame->output_buffer)) { GST_ERROR_OBJECT (self, "Failed to copy buffer"); goto error; } diff --git a/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11vp8dec.cpp b/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11vp8dec.cpp index 5e1ddb4e48..d933b49168 100644 --- a/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11vp8dec.cpp +++ b/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11vp8dec.cpp @@ -645,7 +645,8 @@ gst_d3d11_vp8_dec_output_picture (GstVp8Decoder * decoder, } if (!gst_d3d11_decoder_process_output (inner->d3d11_decoder, vdec, - inner->width, inner->height, view_buffer, &frame->output_buffer)) { + picture->discont_state, inner->width, inner->height, view_buffer, + &frame->output_buffer)) { GST_ERROR_OBJECT (self, "Failed to copy buffer"); goto error; } diff --git a/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11vp9dec.cpp b/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11vp9dec.cpp index 52efa02065..444307a78c 100644 --- a/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11vp9dec.cpp +++ b/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11vp9dec.cpp @@ -781,8 +781,8 @@ gst_d3d11_vp9_dec_output_picture (GstVp9Decoder * decoder, } if (!gst_d3d11_decoder_process_output (inner->d3d11_decoder, vdec, - picture->frame_hdr.width, picture->frame_hdr.height, view_buffer, - &frame->output_buffer)) { + picture->discont_state, picture->frame_hdr.width, + picture->frame_hdr.height, view_buffer, &frame->output_buffer)) { GST_ERROR_OBJECT (self, "Failed to copy buffer"); goto error; }