theoradec: Don't overwrite width/height of the input state

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6203>
This commit is contained in:
Sebastian Dröge 2024-02-23 13:14:18 +02:00 committed by GStreamer Marge Bot
parent ee06666507
commit be4388c249

View file

@ -398,9 +398,7 @@ theora_handle_type_packet (GstTheoraDec * dec)
GstFlowReturn ret = GST_FLOW_OK; GstFlowReturn ret = GST_FLOW_OK;
GstVideoCodecState *state; GstVideoCodecState *state;
GstVideoFormat fmt; GstVideoFormat fmt;
GstVideoInfo *info; gint width, height;
info = &dec->input_state->info;
GST_DEBUG_OBJECT (dec, "fps %d/%d, PAR %d/%d", GST_DEBUG_OBJECT (dec, "fps %d/%d, PAR %d/%d",
dec->info.fps_numerator, dec->info.fps_denominator, dec->info.fps_numerator, dec->info.fps_denominator,
@ -410,8 +408,8 @@ theora_handle_type_packet (GstTheoraDec * dec)
* the info.aspect_* values reflect PAR; * the info.aspect_* values reflect PAR;
* 0:x and x:0 are allowed and can be interpreted as 1:1. * 0:x and x:0 are allowed and can be interpreted as 1:1.
*/ */
par_num = GST_VIDEO_INFO_PAR_N (info); par_num = GST_VIDEO_INFO_PAR_N (&dec->input_state->info);
par_den = GST_VIDEO_INFO_PAR_D (info); par_den = GST_VIDEO_INFO_PAR_D (&dec->input_state->info);
/* If we have a default PAR, see if the decoder specified a different one */ /* If we have a default PAR, see if the decoder specified a different one */
if (par_num == 1 && par_den == 1 && if (par_num == 1 && par_den == 1 &&
@ -445,23 +443,23 @@ theora_handle_type_packet (GstTheoraDec * dec)
goto unsupported_format; goto unsupported_format;
} }
GST_VIDEO_INFO_WIDTH (info) = dec->info.pic_width; width = dec->info.pic_width;
GST_VIDEO_INFO_HEIGHT (info) = dec->info.pic_height; height = dec->info.pic_height;
/* Ensure correct offsets in chroma for formats that need it /* Ensure correct offsets in chroma for formats that need it
* by rounding the offset. libtheora will add proper pixels, * by rounding the offset. libtheora will add proper pixels,
* so no need to handle them ourselves. */ * so no need to handle them ourselves. */
if (dec->info.pic_x & 1 && dec->info.pixel_fmt != TH_PF_444) { if (dec->info.pic_x & 1 && dec->info.pixel_fmt != TH_PF_444) {
GST_VIDEO_INFO_WIDTH (info)++; width++;
} }
if (dec->info.pic_y & 1 && dec->info.pixel_fmt == TH_PF_420) { if (dec->info.pic_y & 1 && dec->info.pixel_fmt == TH_PF_420) {
GST_VIDEO_INFO_HEIGHT (info)++; height++;
} }
GST_DEBUG_OBJECT (dec, "after fixup frame dimension %dx%d, offset %d:%d", GST_DEBUG_OBJECT (dec, "after fixup frame dimension %dx%d, offset %d:%d",
info->width, info->height, dec->info.pic_x, dec->info.pic_y); width, height, dec->info.pic_x, dec->info.pic_y);
if (info->width == 0 || info->height == 0) if (width == 0 || height == 0)
goto invalid_dimensions; goto invalid_dimensions;
/* done */ /* done */
@ -491,7 +489,7 @@ theora_handle_type_packet (GstTheoraDec * dec)
/* Create the output state */ /* Create the output state */
dec->output_state = state = dec->output_state = state =
gst_video_decoder_set_output_state (GST_VIDEO_DECODER (dec), fmt, gst_video_decoder_set_output_state (GST_VIDEO_DECODER (dec), fmt,
info->width, info->height, dec->input_state); width, height, dec->input_state);
/* FIXME : Do we still need to set fps/par now that we pass the reference input stream ? */ /* FIXME : Do we still need to set fps/par now that we pass the reference input stream ? */
state->info.fps_n = dec->info.fps_numerator; state->info.fps_n = dec->info.fps_numerator;
@ -542,7 +540,7 @@ not_negotiated:
invalid_dimensions: invalid_dimensions:
{ {
GST_ERROR_OBJECT (dec, "Invalid dimensions (width:%d, height:%d)", GST_ERROR_OBJECT (dec, "Invalid dimensions (width:%d, height:%d)",
info->width, info->height); width, height);
return GST_FLOW_ERROR; return GST_FLOW_ERROR;
} }
} }