Merge branch 'feat/jpeg_eco5' into 'master'

feat(jpeg): Add yuv444 yuv420 format support for encoder on esp32p4 eco5

Closes IDF-13532

See merge request espressif/esp-idf!41768
This commit is contained in:
C.S.M
2025-09-12 20:13:07 +08:00
8 changed files with 69 additions and 1488 deletions

View File

@@ -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 * SPDX-License-Identifier: Apache-2.0
*/ */
@@ -8,6 +8,8 @@
#include <stdint.h> #include <stdint.h>
#include "hal/color_types.h" #include "hal/color_types.h"
#include "sdkconfig.h"
#include "soc/soc_caps.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@@ -57,6 +59,10 @@ typedef enum {
JPEG_ENCODE_IN_FORMAT_RGB565 = COLOR_TYPE_ID(COLOR_SPACE_RGB, COLOR_PIXEL_RGB565), /*!< input RGB565 format */ JPEG_ENCODE_IN_FORMAT_RGB565 = COLOR_TYPE_ID(COLOR_SPACE_RGB, COLOR_PIXEL_RGB565), /*!< input RGB565 format */
JPEG_ENCODE_IN_FORMAT_GRAY = COLOR_TYPE_ID(COLOR_SPACE_GRAY, COLOR_PIXEL_GRAY8), /*!< input GRAY format */ JPEG_ENCODE_IN_FORMAT_GRAY = COLOR_TYPE_ID(COLOR_SPACE_GRAY, COLOR_PIXEL_GRAY8), /*!< input GRAY format */
JPEG_ENCODE_IN_FORMAT_YUV422 = COLOR_TYPE_ID(COLOR_SPACE_YUV, COLOR_PIXEL_YUV422), /*!< input YUV422 format */ JPEG_ENCODE_IN_FORMAT_YUV422 = COLOR_TYPE_ID(COLOR_SPACE_YUV, COLOR_PIXEL_YUV422), /*!< input YUV422 format */
#if !(CONFIG_ESP_REV_MIN_FULL < 300 && SOC_IS(ESP32P4)) // Invisible for unsupported chips
JPEG_ENCODE_IN_FORMAT_YUV444 = COLOR_TYPE_ID(COLOR_SPACE_YUV, COLOR_PIXEL_YUV444), /*!< input YUV444 format */
JPEG_ENCODE_IN_FORMAT_YUV420 = COLOR_TYPE_ID(COLOR_SPACE_YUV, COLOR_PIXEL_YUV420), /*!< input YUV420 format */
#endif
} jpeg_enc_input_format_t; } jpeg_enc_input_format_t;
/** /**

View File

@@ -185,6 +185,16 @@ esp_err_t jpeg_encoder_process(jpeg_encoder_handle_t encoder_engine, const jpeg_
encoder_engine->color_space = JPEG_ENC_SRC_YUV422; encoder_engine->color_space = JPEG_ENC_SRC_YUV422;
best_hb_idx = JPEG_ENC_SRC_YUV422_HB; best_hb_idx = JPEG_ENC_SRC_YUV422_HB;
break; break;
#if !(CONFIG_ESP_REV_MIN_FULL < 300 && SOC_IS(ESP32P4))
case JPEG_ENCODE_IN_FORMAT_YUV444:
encoder_engine->color_space = JPEG_ENC_SRC_YUV444;
best_hb_idx = JPEG_ENC_SRC_YUV444_HB;
break;
case JPEG_ENCODE_IN_FORMAT_YUV420:
encoder_engine->color_space = JPEG_ENC_SRC_YUV420;
best_hb_idx = JPEG_ENC_SRC_YUV420_HB;
break;
#endif
default: default:
ESP_LOGE(TAG, "wrong, we don't support encode from such format."); ESP_LOGE(TAG, "wrong, we don't support encode from such format.");
ret = ESP_ERR_NOT_SUPPORTED; ret = ESP_ERR_NOT_SUPPORTED;

View File

@@ -57,7 +57,9 @@ const uint32_t enc_hb_tbl[JPEG_ENC_BEST_HB_MAX][JPEG_DOWN_SAMPLING_NUM] = {
{40, 32, 32, 0}, {40, 32, 32, 0},
{0, 64, 0, 0}, {0, 64, 0, 0},
{64, 64, 48, 0}, {64, 64, 48, 0},
{0, 0, 0, 128} {0, 0, 0, 128},
{40, 0, 0, 0},
{0, 0, 48, 0},
}; };
/** /**

View File

@@ -133,6 +133,8 @@ typedef enum {
JPEG_ENC_SRC_YUV422_HB = 1, // Input YUV422 format JPEG_ENC_SRC_YUV422_HB = 1, // Input YUV422 format
JPEG_ENC_SRC_RGB565_HB = 2, // Input RGB565 format JPEG_ENC_SRC_RGB565_HB = 2, // Input RGB565 format
JPEG_ENC_SRC_GRAY_HB = 3, // Input GRAY format JPEG_ENC_SRC_GRAY_HB = 3, // Input GRAY format
JPEG_ENC_SRC_YUV444_HB = 4, // Input YUV444 format
JPEG_ENC_SRC_YUV420_HB = 5, // Input YUV420 format
JPEG_ENC_BEST_HB_MAX, JPEG_ENC_BEST_HB_MAX,
} jpeg_enc_format_hb_t; } jpeg_enc_format_hb_t;

View File

@@ -14,6 +14,7 @@
#include "soc/jpeg_struct.h" #include "soc/jpeg_struct.h"
#include "hal/jpeg_types.h" #include "hal/jpeg_types.h"
#include "soc/hp_sys_clkrst_struct.h" #include "soc/hp_sys_clkrst_struct.h"
#include "hal/config.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@@ -641,6 +642,11 @@ static inline uint32_t jpeg_ll_get_intr_status(jpeg_dev_t *hw)
static inline void jpeg_ll_config_picture_pixel_format(jpeg_dev_t *hw, jpeg_enc_src_type_t pixel_format) static inline void jpeg_ll_config_picture_pixel_format(jpeg_dev_t *hw, jpeg_enc_src_type_t pixel_format)
{ {
uint8_t cs = 0; uint8_t cs = 0;
#if HAL_CONFIG(CHIP_SUPPORT_MIN_REV) >= 300
uint8_t ecs = 0;
// Default, we disable extend color space
hw->extd_config.extd_color_space_en = 0;
#endif
switch (pixel_format) { switch (pixel_format) {
case JPEG_ENC_SRC_RGB888: case JPEG_ENC_SRC_RGB888:
cs = 0; cs = 0;
@@ -654,10 +660,23 @@ static inline void jpeg_ll_config_picture_pixel_format(jpeg_dev_t *hw, jpeg_enc_
case JPEG_ENC_SRC_GRAY: case JPEG_ENC_SRC_GRAY:
cs = 3; cs = 3;
break; break;
#if HAL_CONFIG(CHIP_SUPPORT_MIN_REV) >= 300
case JPEG_ENC_SRC_YUV444:
hw->extd_config.extd_color_space_en = 1;
ecs = 0;
break;
case JPEG_ENC_SRC_YUV420:
hw->extd_config.extd_color_space_en = 1;
ecs = 1;
break;
#endif
default: default:
abort(); abort();
} }
hw->config.color_space = cs; hw->config.color_space = cs;
#if HAL_CONFIG(CHIP_SUPPORT_MIN_REV) >= 300
hw->extd_config.extd_color_space = ecs;
#endif
} }
#ifdef __cplusplus #ifdef __cplusplus

View File

@@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
@@ -78,6 +78,8 @@ typedef enum {
JPEG_ENC_SRC_RGB888 = COLOR_TYPE_ID(COLOR_SPACE_RGB, COLOR_PIXEL_RGB888), /*!< JPEG encoder source RGB888 */ JPEG_ENC_SRC_RGB888 = COLOR_TYPE_ID(COLOR_SPACE_RGB, COLOR_PIXEL_RGB888), /*!< JPEG encoder source RGB888 */
JPEG_ENC_SRC_YUV422 = COLOR_TYPE_ID(COLOR_SPACE_YUV, COLOR_PIXEL_YUV422), /*!< JPEG encoder source YUV422 */ JPEG_ENC_SRC_YUV422 = COLOR_TYPE_ID(COLOR_SPACE_YUV, COLOR_PIXEL_YUV422), /*!< JPEG encoder source YUV422 */
JPEG_ENC_SRC_RGB565 = COLOR_TYPE_ID(COLOR_SPACE_RGB, COLOR_PIXEL_RGB565), /*!< JPEG encoder source RGB565 */ JPEG_ENC_SRC_RGB565 = COLOR_TYPE_ID(COLOR_SPACE_RGB, COLOR_PIXEL_RGB565), /*!< JPEG encoder source RGB565 */
JPEG_ENC_SRC_YUV444 = COLOR_TYPE_ID(COLOR_SPACE_YUV, COLOR_PIXEL_YUV444), /*!< JPEG encoder source YUV444 */
JPEG_ENC_SRC_YUV420 = COLOR_TYPE_ID(COLOR_SPACE_YUV, COLOR_PIXEL_YUV420), /*!< JPEG encoder source YUV420 */
JPEG_ENC_SRC_GRAY = COLOR_TYPE_ID(COLOR_SPACE_GRAY, COLOR_PIXEL_GRAY8), /*!< JPEG encoder source GRAY */ JPEG_ENC_SRC_GRAY = COLOR_TYPE_ID(COLOR_SPACE_GRAY, COLOR_PIXEL_GRAY8), /*!< JPEG encoder source GRAY */
} jpeg_enc_src_type_t; } jpeg_enc_src_type_t;

File diff suppressed because it is too large Load Diff

View File

@@ -164,6 +164,29 @@ typedef union {
uint32_t val; uint32_t val;
} jpeg_pic_size_reg_t; } jpeg_pic_size_reg_t;
/** Type of extd_config register
* Control and configuration registers
*/
typedef union {
struct {
/** extd_color_space_en : R/W; bitpos: [0]; default: 0;
* Configure whether to extend picture's color space
* 0:disable
* 1:enable
*/
uint32_t extd_color_space_en:1;
/** extd_color_space : R/W; bitpos: [1]; default: 0;
* Configure extended picture's color space. Valid when JPEG_EXTD_COLOR_SPACE_EN
* configured to 1
* 0:yuv444
* 1:yuv420
*/
uint32_t extd_color_space:1;
uint32_t reserved_2:30;
};
uint32_t val;
} jpeg_extd_config_reg_t;
/** Type of t0qnr register /** Type of t0qnr register
* Control and configuration registers * Control and configuration registers
*/ */
@@ -1390,7 +1413,7 @@ typedef union {
*/ */
typedef union { typedef union {
struct { struct {
/** jpeg_ver : R/W; bitpos: [27:0]; default: 34673040; /** jpeg_ver : R/W; bitpos: [27:0]; default: 37823072;
* Reserved * Reserved
*/ */
uint32_t jpeg_ver:28; uint32_t jpeg_ver:28;
@@ -1404,7 +1427,7 @@ typedef struct jpeg_dev_t {
volatile jpeg_config_reg_t config; volatile jpeg_config_reg_t config;
volatile jpeg_dqt_info_reg_t dqt_info; volatile jpeg_dqt_info_reg_t dqt_info;
volatile jpeg_pic_size_reg_t pic_size; volatile jpeg_pic_size_reg_t pic_size;
uint32_t reserved_00c; volatile jpeg_extd_config_reg_t extd_config;
volatile jpeg_t0qnr_reg_t t0qnr; volatile jpeg_t0qnr_reg_t t0qnr;
volatile jpeg_t1qnr_reg_t t1qnr; volatile jpeg_t1qnr_reg_t t1qnr;
volatile jpeg_t2qnr_reg_t t2qnr; volatile jpeg_t2qnr_reg_t t2qnr;