vulkanh26xdec: fix discont state handling

It fixes a couple tests in fluster for H.265 decoding.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/9610>
This commit is contained in:
Víctor Manuel Jáquez Leal 2025-08-26 20:17:36 +02:00 committed by GStreamer Marge Bot
parent 90dc0f1313
commit 5e995b2b21
2 changed files with 27 additions and 10 deletions

View File

@ -108,6 +108,7 @@ struct _GstVulkanH264Decoder
VkChromaLocation xloc, yloc;
GstVideoCodecState *output_state;
GstVideoCodecState *input_state;
SPS std_sps;
PPS std_pps;
@ -232,8 +233,8 @@ gst_vulkan_h264_decoder_stop (GstVideoDecoder * decoder)
if (self->decoder)
gst_vulkan_decoder_stop (self->decoder);
if (self->output_state)
gst_video_codec_state_unref (self->output_state);
g_clear_pointer (&self->output_state, gst_video_codec_state_unref);
g_clear_pointer (&self->input_state, gst_video_codec_state_unref);
return GST_VIDEO_DECODER_CLASS (parent_class)->stop (decoder);
}
@ -300,7 +301,6 @@ static gboolean
gst_vulkan_h264_decoder_negotiate (GstVideoDecoder * decoder)
{
GstVulkanH264Decoder *self = GST_VULKAN_H264_DECODER (decoder);
GstH264Decoder *h264dec = GST_H264_DECODER (decoder);
VkVideoFormatPropertiesKHR format_prop;
GstVideoInterlaceMode interlace_mode;
GstVideoFormat format;
@ -327,7 +327,7 @@ gst_vulkan_h264_decoder_negotiate (GstVideoDecoder * decoder)
format = gst_vulkan_format_to_video_format (format_prop.format);
self->output_state = gst_video_decoder_set_interlaced_output_state (decoder,
format, interlace_mode, self->width, self->height, h264dec->input_state);
format, interlace_mode, self->width, self->height, self->input_state);
self->output_state->caps = gst_video_info_to_caps (&self->output_state->info);
gst_caps_set_features_simple (self->output_state->caps,
@ -642,6 +642,9 @@ gst_vulkan_h264_decoder_new_sequence (GstH264Decoder * decoder,
self->width = width;
self->height = height;
g_clear_pointer (&self->input_state, gst_video_codec_state_unref);
self->input_state = gst_video_codec_state_ref (decoder->input_state);
/* Ycbcr sampler */
{
VkSamplerYcbcrRange range;
@ -1335,13 +1338,18 @@ gst_vulkan_h264_decoder_output_picture (GstH264Decoder * decoder,
{
GstVideoDecoder *vdec = GST_VIDEO_DECODER (decoder);
GstVulkanH264Decoder *self = GST_VULKAN_H264_DECODER (decoder);
GstVideoCodecState *discont_state =
GST_CODEC_PICTURE (picture)->discont_state;
GST_TRACE_OBJECT (self, "Output picture");
GST_LOG_OBJECT (self,
"Outputting picture %p (poc %d)", picture, picture->pic_order_cnt);
if (GST_CODEC_PICTURE (picture)->discont_state) {
if (discont_state) {
g_clear_pointer (&self->input_state, gst_video_codec_state_unref);
self->input_state = gst_video_codec_state_ref (discont_state);
self->need_negotiation = TRUE;
if (!gst_video_decoder_negotiate (vdec)) {
gst_h264_picture_unref (picture);

View File

@ -128,6 +128,8 @@ struct _GstVulkanH265Decoder
VkChromaLocation xloc, yloc;
GstVideoCodecState *output_state;
GstVideoCodecState *input_state;
VPS std_vps;
SPS std_sps;
PPS std_pps;
@ -311,8 +313,8 @@ gst_vulkan_h265_decoder_stop (GstVideoDecoder * decoder)
if (self->decoder)
gst_vulkan_decoder_stop (self->decoder);
if (self->output_state)
gst_video_codec_state_unref (self->output_state);
g_clear_pointer (&self->output_state, gst_video_codec_state_unref);
g_clear_pointer (&self->input_state, gst_video_codec_state_unref);
return GST_VIDEO_DECODER_CLASS (parent_class)->stop (decoder);
}
@ -321,7 +323,6 @@ static gboolean
gst_vulkan_h265_decoder_negotiate (GstVideoDecoder * decoder)
{
GstVulkanH265Decoder *self = GST_VULKAN_H265_DECODER (decoder);
GstH265Decoder *h265dec = GST_H265_DECODER (decoder);
VkVideoFormatPropertiesKHR format_prop;
GstVideoFormat format;
@ -343,7 +344,7 @@ gst_vulkan_h265_decoder_negotiate (GstVideoDecoder * decoder)
format = gst_vulkan_format_to_video_format (format_prop.format);
self->output_state = gst_video_decoder_set_interlaced_output_state (decoder,
format, GST_VIDEO_INTERLACE_MODE_PROGRESSIVE, self->width, self->height,
h265dec->input_state);
self->input_state);
self->output_state->caps = gst_video_info_to_caps (&self->output_state->info);
gst_caps_set_features_simple (self->output_state->caps,
@ -582,6 +583,9 @@ gst_vulkan_h265_decoder_new_sequence (GstH265Decoder * decoder,
self->width = width;
self->height = height;
g_clear_pointer (&self->input_state, gst_video_codec_state_unref);
self->input_state = gst_video_codec_state_ref (decoder->input_state);
/* Ycbcr sampler */
{
VkSamplerYcbcrRange range;
@ -1654,13 +1658,18 @@ gst_vulkan_h265_decoder_output_picture (GstH265Decoder * decoder,
{
GstVideoDecoder *vdec = GST_VIDEO_DECODER (decoder);
GstVulkanH265Decoder *self = GST_VULKAN_H265_DECODER (decoder);
GstVideoCodecState *discont_state =
GST_CODEC_PICTURE (picture)->discont_state;
GST_TRACE_OBJECT (self, "Output picture");
GST_LOG_OBJECT (self,
"Outputting picture %p (poc %d)", picture, picture->pic_order_cnt);
if (GST_CODEC_PICTURE (picture)->discont_state) {
if (discont_state) {
g_clear_pointer (&self->input_state, gst_video_codec_state_unref);
self->input_state = gst_video_codec_state_ref (discont_state);
self->need_negotiation = TRUE;
if (!gst_video_decoder_negotiate (vdec)) {
gst_h265_picture_unref (picture);