Revert "jpegdec: only allow conversions from RGB"
authorMarek Vasut <marex@denx.de>
Fri, 11 Feb 2022 22:29:27 +0000 (23:29 +0100)
committerMarek Vasut <marex@denx.de>
Sun, 13 Feb 2022 13:46:31 +0000 (14:46 +0100)
commit9a029f016d727d6cf57c324c725e1561cf49d510
tree95e8f898194693eac2a42b91a8652f7bd7c6313d
parent1eed9de0bb786d2270c7caac32df8c1cadcc32f5
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: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1687>
subprojects/gst-plugins-good/ext/jpeg/gstjpegdec.c