mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-18 22:36:33 +00:00
jpegdec: only allow conversions from RGB
libjpeg-turbo only supports converting from RGB to other RGB formats. Fix runtime error when trying to convert from a YUV format for example. Fix #916 Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1421>
This commit is contained in:
parent
26169cee0e
commit
2aa2477208
1 changed files with 9 additions and 5 deletions
|
@ -1071,8 +1071,9 @@ gst_jpeg_dec_negotiate (GstJpegDec * dec, gint width, gint height, gint clrspc,
|
||||||
peerformat = gst_structure_get_string (peerstruct, "format");
|
peerformat = gst_structure_get_string (peerstruct, "format");
|
||||||
peerfmt = gst_video_format_from_string (peerformat);
|
peerfmt = gst_video_format_from_string (peerformat);
|
||||||
|
|
||||||
|
/* libjpeg-turbo only supports some colorspace conversions, see
|
||||||
|
* https://raw.githubusercontent.com/libjpeg-turbo/libjpeg-turbo/main/libjpeg.txt */
|
||||||
switch (peerfmt) {
|
switch (peerfmt) {
|
||||||
case GST_VIDEO_FORMAT_RGB:
|
|
||||||
case GST_VIDEO_FORMAT_RGBx:
|
case GST_VIDEO_FORMAT_RGBx:
|
||||||
case GST_VIDEO_FORMAT_xRGB:
|
case GST_VIDEO_FORMAT_xRGB:
|
||||||
case GST_VIDEO_FORMAT_RGBA:
|
case GST_VIDEO_FORMAT_RGBA:
|
||||||
|
@ -1082,11 +1083,14 @@ gst_jpeg_dec_negotiate (GstJpegDec * dec, gint width, gint height, gint clrspc,
|
||||||
case GST_VIDEO_FORMAT_xBGR:
|
case GST_VIDEO_FORMAT_xBGR:
|
||||||
case GST_VIDEO_FORMAT_BGRA:
|
case GST_VIDEO_FORMAT_BGRA:
|
||||||
case GST_VIDEO_FORMAT_ABGR:
|
case GST_VIDEO_FORMAT_ABGR:
|
||||||
clrspc = JCS_RGB;
|
if (clrspc == JCS_RGB) {
|
||||||
format = peerfmt;
|
/* RGB -> other RGB formats */
|
||||||
dec->format_convert = TRUE;
|
format = peerfmt;
|
||||||
dec->libjpeg_ext_format = gst_fmt_to_jpeg_turbo_ext_fmt (peerfmt);
|
dec->format_convert = TRUE;
|
||||||
|
dec->libjpeg_ext_format = gst_fmt_to_jpeg_turbo_ext_fmt (peerfmt);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
/* TODO: implement conversion from/to other supported colorspaces */
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue