mirror of
https://github.com/espressif/esp-idf.git
synced 2026-01-19 08:35:36 +00:00
feat(jpeg_decoder): Add decode to yuv420 since esp32p4 version3
This commit is contained in:
@@ -382,6 +382,11 @@ static esp_err_t jpeg_dec_config_dma_descriptor(jpeg_decoder_handle_t decoder_en
|
||||
case JPEG_DECODE_OUT_FORMAT_YUV444:
|
||||
best_hb_idx = JPEG_DEC_YUV444_HB;
|
||||
break;
|
||||
#if !(CONFIG_ESP_REV_MIN_FULL < 300 && CONFIG_IDF_TARGET_ESP32P4) // Invisible for unsupported chips
|
||||
case JPEG_DECODE_OUT_FORMAT_YUV420:
|
||||
best_hb_idx = JPEG_DEC_YUV420_HB;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
ESP_LOGE(TAG, "wrong, we don't support decode to such format.");
|
||||
return ESP_ERR_NOT_SUPPORTED;
|
||||
@@ -468,7 +473,17 @@ static void jpeg_dec_config_dma_csc(jpeg_decoder_handle_t decoder_engine, dma2d_
|
||||
} else if (decoder_engine->sample_method == JPEG_DOWN_SAMPLING_YUV420) {
|
||||
rx_csc_option = DMA2D_CSC_RX_YUV420_TO_YUV444;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
#if !(CONFIG_ESP_REV_MIN_FULL < 300 && CONFIG_IDF_TARGET_ESP32P4) // Invisible for unsupported chips
|
||||
else if (decoder_engine->output_format == JPEG_DECODE_OUT_FORMAT_YUV420) {
|
||||
if (decoder_engine->sample_method == JPEG_DOWN_SAMPLING_YUV422) {
|
||||
rx_csc_option = DMA2D_CSC_RX_YUV422_TO_YUV420;
|
||||
} else if (decoder_engine->sample_method == JPEG_DOWN_SAMPLING_YUV444) {
|
||||
rx_csc_option = DMA2D_CSC_RX_YUV444_TO_YUV420;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
else {
|
||||
rx_csc_option = DMA2D_CSC_RX_NONE;
|
||||
}
|
||||
|
||||
@@ -565,6 +580,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 && CONFIG_IDF_TARGET_ESP32P4) // Invisible for unsupported chips
|
||||
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");
|
||||
@@ -581,6 +597,12 @@ static esp_err_t jpeg_color_space_support_check(jpeg_decoder_handle_t decoder_en
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
}
|
||||
#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;
|
||||
}
|
||||
#endif
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -40,10 +40,10 @@ const uint8_t zigzag_arr[64] = {
|
||||
* data stream during the decoding process.
|
||||
*/
|
||||
const uint32_t dec_hb_tbl[JPEG_DOWN_SAMPLING_NUM][JPEG_DEC_BEST_HB_MAX] = {
|
||||
{40, 40, 40, 32, 0},
|
||||
{64, 32, 32, 64, 0},
|
||||
{48, 32, 32, 48, 0},
|
||||
{96, 0, 0, 0, 96},
|
||||
{40, 40, 40, 32, 0, 32},
|
||||
{64, 32, 32, 64, 0, 32},
|
||||
{48, 32, 32, 48, 0, 48},
|
||||
{96, 0, 0, 0, 96, 0},
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -61,6 +61,7 @@ typedef enum {
|
||||
JPEG_DEC_RGB888_HB = 2, /*!< output RGB888 format */
|
||||
JPEG_DEC_RGB565_HB = 3, /*!< output RGB565 format */
|
||||
JPEG_DEC_GRAY_HB = 4, /*!< output the gray picture */
|
||||
JPEG_DEC_YUV420_HB = 5, /*!< output YUV420 format */
|
||||
JPEG_DEC_BEST_HB_MAX, /*!< Max value of output formats */
|
||||
} jpeg_dec_format_hb_t;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user