From 6aa3d4900d2464eac830d031da2af26b2713a590 Mon Sep 17 00:00:00 2001 From: "C.S.M" Date: Wed, 17 Dec 2025 10:45:33 +0800 Subject: [PATCH] fix(jpeg): Fix jpeg color space check --- components/esp_driver_jpeg/jpeg_decode.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/components/esp_driver_jpeg/jpeg_decode.c b/components/esp_driver_jpeg/jpeg_decode.c index 3692331dfa..2673c3a307 100644 --- a/components/esp_driver_jpeg/jpeg_decode.c +++ b/components/esp_driver_jpeg/jpeg_decode.c @@ -603,7 +603,7 @@ static bool jpeg_dec_transaction_on_picked(uint32_t channel_num, const dma2d_tra static esp_err_t jpeg_color_space_support_check(jpeg_decoder_handle_t decoder_engine) { -#if !(CONFIG_ESP_REV_MIN_FULL < 300 && SOC_IS(ESP32P4)) // Invisible for unsupported chips +#if (CONFIG_ESP_REV_MIN_FULL < 300 && SOC_IS(ESP32P4)) // For P4 less than 3.0 if (decoder_engine->sample_method == JPEG_DOWN_SAMPLING_YUV444) { if (decoder_engine->output_format == JPEG_DECODE_OUT_FORMAT_YUV422 || decoder_engine->output_format == JPEG_DECODE_OUT_FORMAT_YUV420) { ESP_LOGE(TAG, "Detected YUV444 but want to convert to YUV422/YUV420, which is not supported"); @@ -621,9 +621,11 @@ static esp_err_t jpeg_color_space_support_check(jpeg_decoder_handle_t decoder_en } } #else - if (decoder_engine->sample_method != JPEG_DOWN_SAMPLING_YUV422) { - ESP_LOGE(TAG, "Detected YUV444/YUV420 but want to convert to YUV422, which is not supported"); - return ESP_ERR_INVALID_ARG; + if (decoder_engine->sample_method == JPEG_DOWN_SAMPLING_YUV420 || decoder_engine->sample_method == JPEG_DOWN_SAMPLING_YUV444) { + if (decoder_engine->output_format == JPEG_DECODE_OUT_FORMAT_YUV422) { + ESP_LOGE(TAG, "Detected YUV444/YUV420 but want to convert to YUV422, which is not supported"); + return ESP_ERR_INVALID_ARG; + } } #endif return ESP_OK;