mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-05 09:00:54 +00:00
Revert "jpegdec: only allow conversions from RGB"
This reverts commit2aa2477208
. The commit is completely wrong, libjpeg-turbo is perfectly capable of decoding I420 (YUV) to RGB. The test case provided alongside the aforementioned commit passes without this revert because it decodes image of JCS_YCrCb color space, so the new `if (clrspc == JCS_RGB)` condition is false on that image, and the libjpeg-turbo decoding does not get used. The real bug is hidden by that commit. The real problem is in the call order of gst_jpeg_dec_prepare_decode() and gst_jpeg_dec_negotiate(). The gst_jpeg_dec_prepare_decode() calls jpeg_start_decompress() which sets up internal state of the libjpeg, however, neither cinfo.out_color_space nor cinfo.raw_data_out are set correctly yet. Those two are set up in gst_jpeg_dec_negotiate() which is called a bit later. Therefore, the real fix is the set up cinfo.out_color_space and cinfo.raw_data_out before calling jpeg_start_decompress(). This is however a separate patch. Fixes:2aa2477208
("jpegdec: only allow conversions from RGB") Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1716>
This commit is contained in:
parent
a66c03c287
commit
b0ad4d3aee
1 changed files with 5 additions and 9 deletions
|
@ -1071,9 +1071,8 @@ gst_jpeg_dec_negotiate (GstJpegDec * dec, gint width, gint height, gint clrspc,
|
|||
peerformat = gst_structure_get_string (peerstruct, "format");
|
||||
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) {
|
||||
case GST_VIDEO_FORMAT_RGB:
|
||||
case GST_VIDEO_FORMAT_RGBx:
|
||||
case GST_VIDEO_FORMAT_xRGB:
|
||||
case GST_VIDEO_FORMAT_RGBA:
|
||||
|
@ -1083,14 +1082,11 @@ gst_jpeg_dec_negotiate (GstJpegDec * dec, gint width, gint height, gint clrspc,
|
|||
case GST_VIDEO_FORMAT_xBGR:
|
||||
case GST_VIDEO_FORMAT_BGRA:
|
||||
case GST_VIDEO_FORMAT_ABGR:
|
||||
if (clrspc == JCS_RGB) {
|
||||
/* RGB -> other RGB formats */
|
||||
clrspc = JCS_RGB;
|
||||
format = peerfmt;
|
||||
dec->format_convert = TRUE;
|
||||
dec->libjpeg_ext_format = gst_fmt_to_jpeg_turbo_ext_fmt (peerfmt);
|
||||
}
|
||||
break;
|
||||
/* TODO: implement conversion from/to other supported colorspaces */
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue