mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 06:54:49 +00:00
jpegdec: Directly error out on negotiation failures
Thanks to Antonio Morales for finding and reporting the issue. Fixes GHSL-2024-247 Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/3862 Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8040>
This commit is contained in:
parent
5093691ef2
commit
3cdf206f4f
1 changed files with 17 additions and 5 deletions
|
@ -1068,13 +1068,14 @@ gst_jpeg_turbo_parse_ext_fmt_convert (GstJpegDec * dec, gint * clrspc)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void
|
static gboolean
|
||||||
gst_jpeg_dec_negotiate (GstJpegDec * dec, gint width, gint height, gint clrspc,
|
gst_jpeg_dec_negotiate (GstJpegDec * dec, gint width, gint height, gint clrspc,
|
||||||
gboolean interlaced)
|
gboolean interlaced)
|
||||||
{
|
{
|
||||||
GstVideoCodecState *outstate;
|
GstVideoCodecState *outstate;
|
||||||
GstVideoInfo *info;
|
GstVideoInfo *info;
|
||||||
GstVideoFormat format;
|
GstVideoFormat format;
|
||||||
|
gboolean res;
|
||||||
|
|
||||||
#ifdef JCS_EXTENSIONS
|
#ifdef JCS_EXTENSIONS
|
||||||
if (dec->format_convert) {
|
if (dec->format_convert) {
|
||||||
|
@ -1104,7 +1105,7 @@ gst_jpeg_dec_negotiate (GstJpegDec * dec, gint width, gint height, gint clrspc,
|
||||||
height == GST_VIDEO_INFO_HEIGHT (info) &&
|
height == GST_VIDEO_INFO_HEIGHT (info) &&
|
||||||
format == GST_VIDEO_INFO_FORMAT (info)) {
|
format == GST_VIDEO_INFO_FORMAT (info)) {
|
||||||
gst_video_codec_state_unref (outstate);
|
gst_video_codec_state_unref (outstate);
|
||||||
return;
|
return TRUE;
|
||||||
}
|
}
|
||||||
gst_video_codec_state_unref (outstate);
|
gst_video_codec_state_unref (outstate);
|
||||||
}
|
}
|
||||||
|
@ -1118,6 +1119,8 @@ gst_jpeg_dec_negotiate (GstJpegDec * dec, gint width, gint height, gint clrspc,
|
||||||
outstate =
|
outstate =
|
||||||
gst_video_decoder_set_output_state (GST_VIDEO_DECODER (dec), format,
|
gst_video_decoder_set_output_state (GST_VIDEO_DECODER (dec), format,
|
||||||
width, height, dec->input_state);
|
width, height, dec->input_state);
|
||||||
|
if (!outstate)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
switch (clrspc) {
|
switch (clrspc) {
|
||||||
case JCS_RGB:
|
case JCS_RGB:
|
||||||
|
@ -1142,10 +1145,12 @@ gst_jpeg_dec_negotiate (GstJpegDec * dec, gint width, gint height, gint clrspc,
|
||||||
|
|
||||||
gst_video_codec_state_unref (outstate);
|
gst_video_codec_state_unref (outstate);
|
||||||
|
|
||||||
gst_video_decoder_negotiate (GST_VIDEO_DECODER (dec));
|
res = gst_video_decoder_negotiate (GST_VIDEO_DECODER (dec));
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (dec, "max_v_samp_factor=%d", dec->cinfo.max_v_samp_factor);
|
GST_DEBUG_OBJECT (dec, "max_v_samp_factor=%d", dec->cinfo.max_v_samp_factor);
|
||||||
GST_DEBUG_OBJECT (dec, "max_h_samp_factor=%d", dec->cinfo.max_h_samp_factor);
|
GST_DEBUG_OBJECT (dec, "max_h_samp_factor=%d", dec->cinfo.max_h_samp_factor);
|
||||||
|
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstFlowReturn
|
static GstFlowReturn
|
||||||
|
@ -1425,8 +1430,9 @@ gst_jpeg_dec_handle_frame (GstVideoDecoder * bdec, GstVideoCodecFrame * frame)
|
||||||
num_fields = 1;
|
num_fields = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_jpeg_dec_negotiate (dec, width, output_height,
|
if (!gst_jpeg_dec_negotiate (dec, width, output_height,
|
||||||
dec->cinfo.jpeg_color_space, num_fields == 2);
|
dec->cinfo.jpeg_color_space, num_fields == 2))
|
||||||
|
goto negotiation_failed;
|
||||||
|
|
||||||
state = gst_video_decoder_get_output_state (bdec);
|
state = gst_video_decoder_get_output_state (bdec);
|
||||||
ret = gst_video_decoder_allocate_output_frame (bdec, frame);
|
ret = gst_video_decoder_allocate_output_frame (bdec, frame);
|
||||||
|
@ -1558,6 +1564,12 @@ map_failed:
|
||||||
ret = GST_FLOW_ERROR;
|
ret = GST_FLOW_ERROR;
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
negotiation_failed:
|
||||||
|
{
|
||||||
|
GST_ELEMENT_ERROR (dec, CORE, NEGOTIATION, (NULL), ("failed to negotiate"));
|
||||||
|
ret = GST_FLOW_NOT_NEGOTIATED;
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
decode_error:
|
decode_error:
|
||||||
{
|
{
|
||||||
gchar err_msg[JMSG_LENGTH_MAX];
|
gchar err_msg[JMSG_LENGTH_MAX];
|
||||||
|
|
Loading…
Reference in a new issue