From: Marek Vasut Date: Fri, 11 Feb 2022 22:29:27 +0000 (+0100) Subject: Revert "jpegdec: only allow conversions from RGB" X-Git-Tag: 1.22.0~2443 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9a029f016d727d6cf57c324c725e1561cf49d510;p=platform%2Fupstream%2Fgstreamer.git Revert "jpegdec: only allow conversions from RGB" This reverts commit 2aa2477208c029b0e1b8232d69f4f99a3bf1d473. 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: --- diff --git a/subprojects/gst-plugins-good/ext/jpeg/gstjpegdec.c b/subprojects/gst-plugins-good/ext/jpeg/gstjpegdec.c index 3b66e26..db81b41 100644 --- a/subprojects/gst-plugins-good/ext/jpeg/gstjpegdec.c +++ b/subprojects/gst-plugins-good/ext/jpeg/gstjpegdec.c @@ -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 */ - format = peerfmt; - dec->format_convert = TRUE; - dec->libjpeg_ext_format = gst_fmt_to_jpeg_turbo_ext_fmt (peerfmt); - } + 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; }