mirror of
https://github.com/espressif/esp-idf.git
synced 2025-12-27 13:43:25 +00:00
Merge branch 'refactor/jpeg_fourcc' into 'master'
refactor(jpeg): Use fourcc for jpeg format Closes IDF-14231 See merge request espressif/esp-idf!42581
This commit is contained in:
@@ -19,12 +19,12 @@ extern "C" {
|
||||
* @brief Enumeration for jpeg output format.
|
||||
*/
|
||||
typedef enum {
|
||||
JPEG_DECODE_OUT_FORMAT_RGB888 = COLOR_TYPE_ID(COLOR_SPACE_RGB, COLOR_PIXEL_RGB888), /*!< output RGB888 format */
|
||||
JPEG_DECODE_OUT_FORMAT_RGB565 = COLOR_TYPE_ID(COLOR_SPACE_RGB, COLOR_PIXEL_RGB565), /*!< output RGB565 format */
|
||||
JPEG_DECODE_OUT_FORMAT_GRAY = COLOR_TYPE_ID(COLOR_SPACE_GRAY, COLOR_PIXEL_GRAY8), /*!< output the gray picture */
|
||||
JPEG_DECODE_OUT_FORMAT_YUV444 = COLOR_TYPE_ID(COLOR_SPACE_YUV, COLOR_PIXEL_YUV444), /*!< output yuv444 format */
|
||||
JPEG_DECODE_OUT_FORMAT_YUV422 = COLOR_TYPE_ID(COLOR_SPACE_YUV, COLOR_PIXEL_YUV422), /*!< output yuv422 format */
|
||||
JPEG_DECODE_OUT_FORMAT_YUV420 = COLOR_TYPE_ID(COLOR_SPACE_YUV, COLOR_PIXEL_YUV420), /*!< output yuv420 format */
|
||||
JPEG_DECODE_OUT_FORMAT_RGB888 = ESP_COLOR_FOURCC_RGB24, /*!< output RGB888 format */
|
||||
JPEG_DECODE_OUT_FORMAT_RGB565 = ESP_COLOR_FOURCC_RGB16_BE, /*!< output RGB565 format */
|
||||
JPEG_DECODE_OUT_FORMAT_GRAY = ESP_COLOR_FOURCC_GREY, /*!< output the gray picture */
|
||||
JPEG_DECODE_OUT_FORMAT_YUV444 = ESP_COLOR_FOURCC_YUV, /*!< output yuv444 format */
|
||||
JPEG_DECODE_OUT_FORMAT_YUV422 = ESP_COLOR_FOURCC_YVYU, /*!< output yuv422 format */
|
||||
JPEG_DECODE_OUT_FORMAT_YUV420 = ESP_COLOR_FOURCC_OUYY_EVYY, /*!< output yuv420 format */
|
||||
} jpeg_dec_output_format_t;
|
||||
|
||||
/**
|
||||
@@ -55,13 +55,13 @@ typedef enum {
|
||||
* @brief Enumeration for jpeg input format.
|
||||
*/
|
||||
typedef enum {
|
||||
JPEG_ENCODE_IN_FORMAT_RGB888 = COLOR_TYPE_ID(COLOR_SPACE_RGB, COLOR_PIXEL_RGB888), /*!< input RGB888 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_YUV422 = COLOR_TYPE_ID(COLOR_SPACE_YUV, COLOR_PIXEL_YUV422), /*!< input YUV422 format */
|
||||
JPEG_ENCODE_IN_FORMAT_RGB888 = ESP_COLOR_FOURCC_RGB24, /*!< input RGB888 format */
|
||||
JPEG_ENCODE_IN_FORMAT_RGB565 = ESP_COLOR_FOURCC_RGB16_BE, /*!< input RGB565 format */
|
||||
JPEG_ENCODE_IN_FORMAT_GRAY = ESP_COLOR_FOURCC_GREY, /*!< input GRAY format */
|
||||
JPEG_ENCODE_IN_FORMAT_YUV422 = ESP_COLOR_FOURCC_YVYU, /*!< 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 */
|
||||
JPEG_ENCODE_IN_FORMAT_YUV444 = ESP_COLOR_FOURCC_YUV, /*!< input YUV444 format */
|
||||
JPEG_ENCODE_IN_FORMAT_YUV420 = ESP_COLOR_FOURCC_OUYY_EVYY, /*!< input YUV420 format */
|
||||
#endif
|
||||
} jpeg_enc_input_format_t;
|
||||
|
||||
|
||||
@@ -390,9 +390,7 @@ static esp_err_t jpeg_dec_config_dma_descriptor(jpeg_decoder_handle_t decoder_en
|
||||
ESP_LOGD(TAG, "Config 2DDMA parameter start");
|
||||
|
||||
jpeg_dec_format_hb_t best_hb_idx = 0;
|
||||
color_space_pixel_format_t picture_format;
|
||||
picture_format.color_type_id = decoder_engine->output_format;
|
||||
decoder_engine->bit_per_pixel = color_hal_pixel_format_get_bit_depth(picture_format);
|
||||
decoder_engine->bit_per_pixel = color_hal_pixel_format_fourcc_get_bit_depth(decoder_engine->output_format);
|
||||
if (decoder_engine->no_color_conversion == false) {
|
||||
switch (decoder_engine->output_format) {
|
||||
case JPEG_DECODE_OUT_FORMAT_RGB888:
|
||||
@@ -441,7 +439,7 @@ static esp_err_t jpeg_dec_config_dma_descriptor(jpeg_decoder_handle_t decoder_en
|
||||
cfg_desc(decoder_engine, decoder_engine->txlink, JPEG_DMA2D_2D_DISABLE, DMA2D_DESCRIPTOR_BLOCK_RW_MODE_SINGLE, decoder_engine->header_info->buffer_left & JPEG_DMA2D_MAX_SIZE, decoder_engine->header_info->buffer_left & JPEG_DMA2D_MAX_SIZE, JPEG_DMA2D_EOF_NOT_LAST, 1, DMA2D_DESCRIPTOR_BUFFER_OWNER_DMA, (decoder_engine->header_info->buffer_left >> JPEG_DMA2D_1D_HIGH_14BIT), (decoder_engine->header_info->buffer_left >> JPEG_DMA2D_1D_HIGH_14BIT), decoder_engine->header_info->buffer_offset, NULL);
|
||||
|
||||
// Configure rx link descriptor
|
||||
cfg_desc(decoder_engine, decoder_engine->rxlink, JPEG_DMA2D_2D_ENABLE, DMA2D_DESCRIPTOR_BLOCK_RW_MODE_MULTIPLE, dma_vb, dma_hb, JPEG_DMA2D_EOF_NOT_LAST, dma2d_desc_pixel_format_to_pbyte_value(picture_format), DMA2D_DESCRIPTOR_BUFFER_OWNER_DMA, decoder_engine->header_info->process_v, decoder_engine->header_info->process_h, decoder_engine->decoded_buf, NULL);
|
||||
cfg_desc(decoder_engine, decoder_engine->rxlink, JPEG_DMA2D_2D_ENABLE, DMA2D_DESCRIPTOR_BLOCK_RW_MODE_MULTIPLE, dma_vb, dma_hb, JPEG_DMA2D_EOF_NOT_LAST, dma2d_desc_pixel_format_to_pbyte_value_fourcc(decoder_engine->output_format), DMA2D_DESCRIPTOR_BUFFER_OWNER_DMA, decoder_engine->header_info->process_v, decoder_engine->header_info->process_h, decoder_engine->decoded_buf, NULL);
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
@@ -165,8 +165,6 @@ esp_err_t jpeg_encoder_process(jpeg_encoder_handle_t encoder_engine, const jpeg_
|
||||
jpeg_enc_format_hb_t best_hb_idx = 0;
|
||||
|
||||
encoder_engine->picture_format = encode_cfg->src_type;
|
||||
color_space_pixel_format_t picture_format;
|
||||
picture_format.color_type_id = encoder_engine->picture_format;
|
||||
|
||||
switch (encode_cfg->src_type) {
|
||||
case JPEG_ENCODE_IN_FORMAT_RGB888:
|
||||
@@ -247,7 +245,7 @@ esp_err_t jpeg_encoder_process(jpeg_encoder_handle_t encoder_engine, const jpeg_
|
||||
|
||||
// 2D direction
|
||||
memset(encoder_engine->txlink, 0, sizeof(dma2d_descriptor_t));
|
||||
s_cfg_desc(encoder_engine, encoder_engine->txlink, JPEG_DMA2D_2D_ENABLE, DMA2D_DESCRIPTOR_BLOCK_RW_MODE_MULTIPLE, dma_vb, dma_hb, JPEG_DMA2D_EOF_NOT_LAST, dma2d_desc_pixel_format_to_pbyte_value(picture_format), DMA2D_DESCRIPTOR_BUFFER_OWNER_DMA, encoder_engine->header_info->origin_v, encoder_engine->header_info->origin_h, raw_buffer, NULL);
|
||||
s_cfg_desc(encoder_engine, encoder_engine->txlink, JPEG_DMA2D_2D_ENABLE, DMA2D_DESCRIPTOR_BLOCK_RW_MODE_MULTIPLE, dma_vb, dma_hb, JPEG_DMA2D_EOF_NOT_LAST, dma2d_desc_pixel_format_to_pbyte_value_fourcc(encoder_engine->picture_format), DMA2D_DESCRIPTOR_BUFFER_OWNER_DMA, encoder_engine->header_info->origin_v, encoder_engine->header_info->origin_h, raw_buffer, NULL);
|
||||
|
||||
ret = esp_cache_msync((void*)raw_buffer, inbuf_size, ESP_CACHE_MSYNC_FLAG_DIR_C2M | ESP_CACHE_MSYNC_FLAG_UNALIGNED);
|
||||
assert(ret == ESP_OK);
|
||||
@@ -512,10 +510,8 @@ static void s_cfg_desc(jpeg_encoder_handle_t encoder_engine, dma2d_descriptor_t
|
||||
static void s_jpeg_enc_config_picture_color_space(jpeg_encoder_handle_t encoder_engine)
|
||||
{
|
||||
jpeg_hal_context_t *hal = &encoder_engine->codec_base->hal;
|
||||
color_space_pixel_format_t picture_format;
|
||||
jpeg_ll_config_picture_pixel_format(hal->dev, encoder_engine->color_space);
|
||||
picture_format.color_type_id = encoder_engine->picture_format;
|
||||
encoder_engine->bytes_per_pixel = color_hal_pixel_format_get_bit_depth(picture_format);
|
||||
encoder_engine->bytes_per_pixel = color_hal_pixel_format_fourcc_get_bit_depth(encoder_engine->picture_format);
|
||||
if (encoder_engine->color_space == JPEG_ENC_SRC_GRAY) {
|
||||
encoder_engine->header_info->num_components = 1;
|
||||
} else {
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
@@ -42,3 +42,23 @@ uint32_t color_hal_pixel_format_get_bit_depth(color_space_pixel_format_t format)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t color_hal_pixel_format_fourcc_get_bit_depth(uint32_t four_character_code)
|
||||
{
|
||||
switch (four_character_code) {
|
||||
case ESP_COLOR_FOURCC_GREY:
|
||||
return 8;
|
||||
case ESP_COLOR_FOURCC_OUYY_EVYY:
|
||||
return 12;
|
||||
case ESP_COLOR_FOURCC_YVYU:
|
||||
case ESP_COLOR_FOURCC_RGB16_BE:
|
||||
return 16;
|
||||
case ESP_COLOR_FOURCC_RGB24:
|
||||
case ESP_COLOR_FOURCC_YUV:
|
||||
return 24;
|
||||
default:
|
||||
// Unknown color space pixel format, unknown bit depth
|
||||
HAL_ASSERT(false);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
@@ -22,6 +22,16 @@ extern "C" {
|
||||
*/
|
||||
uint32_t color_hal_pixel_format_get_bit_depth(color_space_pixel_format_t color_type_id);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Get the bit depth (bits/pixel) of each color space pixel format
|
||||
*
|
||||
* @param four_character_code Value constructed in four character code
|
||||
*
|
||||
* @return Number of bits per pixel
|
||||
*/
|
||||
uint32_t color_hal_pixel_format_fourcc_get_bit_depth(uint32_t four_character_code);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -13,109 +13,67 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/*---------------------------------------------------------------
|
||||
Color Space
|
||||
Four Character Code
|
||||
---------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief Color Space
|
||||
*
|
||||
* @note Save enum 0 for special purpose
|
||||
*/
|
||||
typedef enum {
|
||||
COLOR_SPACE_RAW = 1, ///< Color space raw
|
||||
COLOR_SPACE_RGB, ///< Color space rgb
|
||||
COLOR_SPACE_YUV, ///< Color space yuv
|
||||
COLOR_SPACE_GRAY, ///< Color space gray
|
||||
COLOR_SPACE_ARGB, ///< Color space argb
|
||||
COLOR_SPACE_ALPHA, ///< Color space alpha (A)
|
||||
COLOR_SPACE_CLUT, ///< Color look-up table (L)
|
||||
} color_space_t;
|
||||
|
||||
/*---------------------------------------------------------------
|
||||
Color Pixel Format
|
||||
---------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief Raw Format
|
||||
*/
|
||||
typedef enum {
|
||||
COLOR_PIXEL_RAW8, ///< 8 bits per pixel
|
||||
COLOR_PIXEL_RAW10, ///< 10 bits per pixel
|
||||
COLOR_PIXEL_RAW12, ///< 12 bits per pixel
|
||||
} color_pixel_raw_format_t;
|
||||
#define ESP_COLOR_FOURCC(a, b, c, d) ((uint32_t)(a) | ((uint32_t)(b) << 8) | ((uint32_t)(c) << 16) | ((uint32_t)(d) << 24))
|
||||
|
||||
/**
|
||||
* @brief RGB Format
|
||||
* RGB24
|
||||
* Memory Layout:
|
||||
* | bit7 - bit0 |
|
||||
* Byte 2: | B7 - B0 |
|
||||
* Byte 1: | G7 - G0 |
|
||||
* Byte 0: | R7 - R0 |
|
||||
*/
|
||||
typedef enum {
|
||||
COLOR_PIXEL_RGB888, ///< 24 bits, 8 bits per R/G/B value
|
||||
COLOR_PIXEL_RGB666, ///< 18 bits, 6 bits per R/G/B value
|
||||
COLOR_PIXEL_RGB565, ///< 16 bits, 5 bits per R/B value, 6 bits for G value
|
||||
} color_pixel_rgb_format_t;
|
||||
#define ESP_COLOR_FOURCC_RGB24 ESP_COLOR_FOURCC('R', 'G', 'B', '3') /* 24 bpp RGB-8-8-8 */
|
||||
|
||||
/**
|
||||
* @brief YUV Format
|
||||
* RGB565_BE
|
||||
* Memory Layout:
|
||||
* | bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 |
|
||||
* Byte 1: | G2 G1 G0 | B4 B3 B2 B1 B0 |
|
||||
* Byte 0: | R4 R3 R2 R1 R0 | G5 G4 G3 |
|
||||
*/
|
||||
typedef enum {
|
||||
COLOR_PIXEL_YUV444, ///< 24 bits, 8 bits per Y/U/V value
|
||||
COLOR_PIXEL_YUV422, ///< 16 bits, 8-bit Y per pixel, 8-bit U and V per two pixels
|
||||
COLOR_PIXEL_YUV420, ///< 12 bits, 8-bit Y per pixel, 8-bit U and V per four pixels
|
||||
COLOR_PIXEL_YUV411, ///< 12 bits, 8-bit Y per pixel, 8-bit U and V per four pixels
|
||||
} color_pixel_yuv_format_t;
|
||||
#define ESP_COLOR_FOURCC_RGB16_BE ESP_COLOR_FOURCC('R', 'G', 'B', 'B') /* 16 bpp RGB-5-6-5, big endian */
|
||||
|
||||
/**
|
||||
* @brief Gray Format
|
||||
* Grey8
|
||||
* Memory Layout:
|
||||
* | bit7 - bit0 |
|
||||
* Byte 0: | G7 - G0 |
|
||||
*/
|
||||
typedef enum {
|
||||
COLOR_PIXEL_GRAY4, ///< 4 bits, grayscale
|
||||
COLOR_PIXEL_GRAY8, ///< 8 bits, grayscale
|
||||
} color_pixel_gray_format_t;
|
||||
#define ESP_COLOR_FOURCC_GREY ESP_COLOR_FOURCC('G', 'R', 'E', 'Y') /* 8 bpp Greyscale */
|
||||
|
||||
/**
|
||||
* @brief ARGB Format
|
||||
* YUV444
|
||||
* Memory Layout:
|
||||
* +--+--+--+ +--+--+--+
|
||||
* |Y0|U0|V0| |Y1|U1|V1|
|
||||
* +--+--+--+ +--+--+--+
|
||||
*/
|
||||
typedef enum {
|
||||
COLOR_PIXEL_ARGB8888, ///< 32 bits, 8 bits per A(alpha)/R/G/B value
|
||||
} color_pixel_argb_format_t;
|
||||
#define ESP_COLOR_FOURCC_YUV ESP_COLOR_FOURCC('V', '3', '0', '8') /* 24 bpp, Y-U-V 4:4:4 */
|
||||
|
||||
/**
|
||||
* @brief Alpha(A) Format
|
||||
* YVYU422
|
||||
* Memory Layout:
|
||||
* +--+--+--+--+ +--+--+--+--+
|
||||
* |Y0|V0|Y1|U0| |Y2|V2|Y3|U2|
|
||||
* +--+--+--+--+ +--+--+--+--+
|
||||
*/
|
||||
typedef enum {
|
||||
COLOR_PIXEL_A4, ///< 4 bits, opacity only
|
||||
COLOR_PIXEL_A8, ///< 8 bits, opacity only
|
||||
} color_pixel_alpha_format_t;
|
||||
#define ESP_COLOR_FOURCC_YVYU ESP_COLOR_FOURCC('Y', 'V', 'Y', 'U') /* 16 bpp, YVYU 4:2:2 */
|
||||
|
||||
/**
|
||||
* @brief CLUT(L) Format
|
||||
* Espressif YUV420, U00 V10 shared Y00 Y01 Y10 Y11, U02 V12 shared Y02 Y03 Y12 Y13
|
||||
* Memory Layout:
|
||||
* +---+---+---+ +---+---+---+
|
||||
* Line1 |U00|Y00|Y01| |U02|Y02|Y03|
|
||||
* +---+---+---+ +---+---+---+
|
||||
* Line2 |V10|Y10|Y11| |V12|Y12|Y13|
|
||||
* +---+---+---+ +---+---+---+
|
||||
*/
|
||||
typedef enum {
|
||||
COLOR_PIXEL_L4, ///< 4 bits, color look-up table
|
||||
COLOR_PIXEL_L8, ///< 8 bits, color look-up table
|
||||
} color_pixel_clut_format_t;
|
||||
#define ESP_COLOR_FOURCC_OUYY_EVYY ESP_COLOR_FOURCC('O', 'U', 'E', 'V') /* 12 bpp, Espressif Y-U-V 4:2:0 */
|
||||
|
||||
/*---------------------------------------------------------------
|
||||
Color Space Pixel Struct Type
|
||||
---------------------------------------------------------------*/
|
||||
///< Bitwidth of the `color_space_pixel_format_t::color_space` field
|
||||
#define COLOR_SPACE_BITWIDTH 8
|
||||
///< Bitwidth of the `color_space_pixel_format_t::pixel_format` field
|
||||
#define COLOR_PIXEL_FORMAT_BITWIDTH 24
|
||||
///< Helper to get the color_space from a unique color type ID
|
||||
#define COLOR_SPACE_TYPE(color_type_id) (((color_type_id) >> COLOR_PIXEL_FORMAT_BITWIDTH) & ((1 << COLOR_SPACE_BITWIDTH) - 1))
|
||||
///< Helper to get the pixel_format from a unique color type ID
|
||||
#define COLOR_PIXEL_FORMAT(color_type_id) ((color_type_id) & ((1 << COLOR_PIXEL_FORMAT_BITWIDTH) - 1))
|
||||
///< Make a unique ID of a color based on the value of color space and pixel format
|
||||
#define COLOR_TYPE_ID(color_space, pixel_format) (((color_space) << COLOR_PIXEL_FORMAT_BITWIDTH) | (pixel_format))
|
||||
|
||||
/**
|
||||
* @brief Color Space Info Structure
|
||||
*/
|
||||
typedef union {
|
||||
struct {
|
||||
uint32_t pixel_format: COLOR_PIXEL_FORMAT_BITWIDTH; ///< Format of a certain color space type
|
||||
uint32_t color_space: COLOR_SPACE_BITWIDTH; ///< Color space type
|
||||
};
|
||||
uint32_t color_type_id; ///< Unique type of a certain color pixel format
|
||||
} color_space_pixel_format_t;
|
||||
|
||||
/*---------------------------------------------------------------
|
||||
Color Conversion
|
||||
@@ -247,6 +205,114 @@ typedef enum {
|
||||
COLOR_YUV422_PACK_ORDER_VYUY, /*!< VYUY */
|
||||
} color_yuv422_pack_order_t;
|
||||
|
||||
///< The following values are deprecated, please use the FOURCC values instead, IDF-14284
|
||||
|
||||
/*---------------------------------------------------------------
|
||||
Color Space
|
||||
---------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief Color Space
|
||||
*
|
||||
* @note Save enum 0 for special purpose
|
||||
*/
|
||||
typedef enum {
|
||||
COLOR_SPACE_RAW = 1, ///< Color space raw
|
||||
COLOR_SPACE_RGB, ///< Color space rgb
|
||||
COLOR_SPACE_YUV, ///< Color space yuv
|
||||
COLOR_SPACE_GRAY, ///< Color space gray
|
||||
COLOR_SPACE_ARGB, ///< Color space argb
|
||||
COLOR_SPACE_ALPHA, ///< Color space alpha (A)
|
||||
COLOR_SPACE_CLUT, ///< Color look-up table (L)
|
||||
} color_space_t;
|
||||
|
||||
/*---------------------------------------------------------------
|
||||
Color Pixel Format
|
||||
---------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief Raw Format
|
||||
*/
|
||||
typedef enum {
|
||||
COLOR_PIXEL_RAW8, ///< 8 bits per pixel
|
||||
COLOR_PIXEL_RAW10, ///< 10 bits per pixel
|
||||
COLOR_PIXEL_RAW12, ///< 12 bits per pixel
|
||||
} color_pixel_raw_format_t;
|
||||
|
||||
/**
|
||||
* @brief RGB Format
|
||||
*/
|
||||
typedef enum {
|
||||
COLOR_PIXEL_RGB888, ///< 24 bits, 8 bits per R/G/B value
|
||||
COLOR_PIXEL_RGB666, ///< 18 bits, 6 bits per R/G/B value
|
||||
COLOR_PIXEL_RGB565, ///< 16 bits, 5 bits per R/B value, 6 bits for G value
|
||||
} color_pixel_rgb_format_t;
|
||||
|
||||
/**
|
||||
* @brief YUV Format
|
||||
*/
|
||||
typedef enum {
|
||||
COLOR_PIXEL_YUV444, ///< 24 bits, 8 bits per Y/U/V value
|
||||
COLOR_PIXEL_YUV422, ///< 16 bits, 8-bit Y per pixel, 8-bit U and V per two pixels
|
||||
COLOR_PIXEL_YUV420, ///< 12 bits, 8-bit Y per pixel, 8-bit U and V per four pixels
|
||||
COLOR_PIXEL_YUV411, ///< 12 bits, 8-bit Y per pixel, 8-bit U and V per four pixels
|
||||
} color_pixel_yuv_format_t;
|
||||
|
||||
/**
|
||||
* @brief Gray Format
|
||||
*/
|
||||
typedef enum {
|
||||
COLOR_PIXEL_GRAY4, ///< 4 bits, grayscale
|
||||
COLOR_PIXEL_GRAY8, ///< 8 bits, grayscale
|
||||
} color_pixel_gray_format_t;
|
||||
|
||||
/**
|
||||
* @brief ARGB Format
|
||||
*/
|
||||
typedef enum {
|
||||
COLOR_PIXEL_ARGB8888, ///< 32 bits, 8 bits per A(alpha)/R/G/B value
|
||||
} color_pixel_argb_format_t;
|
||||
|
||||
/**
|
||||
* @brief Alpha(A) Format
|
||||
*/
|
||||
typedef enum {
|
||||
COLOR_PIXEL_A4, ///< 4 bits, opacity only
|
||||
COLOR_PIXEL_A8, ///< 8 bits, opacity only
|
||||
} color_pixel_alpha_format_t;
|
||||
|
||||
/**
|
||||
* @brief CLUT(L) Format
|
||||
*/
|
||||
typedef enum {
|
||||
COLOR_PIXEL_L4, ///< 4 bits, color look-up table
|
||||
COLOR_PIXEL_L8, ///< 8 bits, color look-up table
|
||||
} color_pixel_clut_format_t;
|
||||
|
||||
/*---------------------------------------------------------------
|
||||
Color Space Pixel Struct Type
|
||||
---------------------------------------------------------------*/
|
||||
///< Bitwidth of the `color_space_pixel_format_t::color_space` field
|
||||
#define COLOR_SPACE_BITWIDTH 8
|
||||
///< Bitwidth of the `color_space_pixel_format_t::pixel_format` field
|
||||
#define COLOR_PIXEL_FORMAT_BITWIDTH 24
|
||||
///< Helper to get the color_space from a unique color type ID
|
||||
#define COLOR_SPACE_TYPE(color_type_id) (((color_type_id) >> COLOR_PIXEL_FORMAT_BITWIDTH) & ((1 << COLOR_SPACE_BITWIDTH) - 1))
|
||||
///< Helper to get the pixel_format from a unique color type ID
|
||||
#define COLOR_PIXEL_FORMAT(color_type_id) ((color_type_id) & ((1 << COLOR_PIXEL_FORMAT_BITWIDTH) - 1))
|
||||
///< Make a unique ID of a color based on the value of color space and pixel format
|
||||
#define COLOR_TYPE_ID(color_space, pixel_format) (((color_space) << COLOR_PIXEL_FORMAT_BITWIDTH) | (pixel_format))
|
||||
|
||||
/**
|
||||
* @brief Color Space Info Structure
|
||||
*/
|
||||
typedef union {
|
||||
struct {
|
||||
uint32_t pixel_format: COLOR_PIXEL_FORMAT_BITWIDTH; ///< Format of a certain color space type
|
||||
uint32_t color_space: COLOR_SPACE_BITWIDTH; ///< Color space type
|
||||
};
|
||||
uint32_t color_type_id; ///< Unique type of a certain color pixel format
|
||||
} color_space_pixel_format_t;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -97,6 +97,28 @@ static inline uint32_t dma2d_desc_pixel_format_to_pbyte_value(color_space_pixel_
|
||||
}
|
||||
}
|
||||
|
||||
// Helper function to convert pixel format to 2D-DMA descriptor pbyte value
|
||||
static inline uint32_t dma2d_desc_pixel_format_to_pbyte_value_fourcc(uint32_t four_character_code)
|
||||
{
|
||||
switch (color_hal_pixel_format_fourcc_get_bit_depth(four_character_code)) {
|
||||
case 4:
|
||||
return DMA2D_DESCRIPTOR_PBYTE_0B5_PER_PIXEL;
|
||||
case 8:
|
||||
return DMA2D_DESCRIPTOR_PBYTE_1B0_PER_PIXEL;
|
||||
case 12:
|
||||
return DMA2D_DESCRIPTOR_PBYTE_1B5_PER_PIXEL;
|
||||
case 16:
|
||||
return DMA2D_DESCRIPTOR_PBYTE_2B0_PER_PIXEL;
|
||||
case 24:
|
||||
return DMA2D_DESCRIPTOR_PBYTE_3B0_PER_PIXEL;
|
||||
case 32:
|
||||
return DMA2D_DESCRIPTOR_PBYTE_4B0_PER_PIXEL;
|
||||
default:
|
||||
// Unsupported bit depth
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enumeration of peripherals which have the 2D-DMA capability
|
||||
*/
|
||||
|
||||
@@ -45,9 +45,9 @@ typedef struct {
|
||||
* @brief Enum for JPEG sampling mode.
|
||||
*/
|
||||
typedef enum {
|
||||
JPEG_SAMPLE_MODE_YUV444 = COLOR_TYPE_ID(COLOR_SPACE_YUV, COLOR_PIXEL_YUV444), ///< sample in YUV444
|
||||
JPEG_SAMPLE_MODE_YUV422 = COLOR_TYPE_ID(COLOR_SPACE_YUV, COLOR_PIXEL_YUV422), ///< sample in YUV422
|
||||
JPEG_SAMPLE_MODE_YUV420 = COLOR_TYPE_ID(COLOR_SPACE_YUV, COLOR_PIXEL_YUV420), ///< sample in YUV420
|
||||
JPEG_SAMPLE_MODE_YUV444 = ESP_COLOR_FOURCC_YUV, ///< sample in YUV444
|
||||
JPEG_SAMPLE_MODE_YUV422 = ESP_COLOR_FOURCC_YVYU, ///< sample in YUV422
|
||||
JPEG_SAMPLE_MODE_YUV420 = ESP_COLOR_FOURCC_OUYY_EVYY, ///< sample in YUV420
|
||||
} jpeg_sample_mode_t;
|
||||
|
||||
/**
|
||||
@@ -65,22 +65,22 @@ typedef union {
|
||||
* @brief Enumeration for jpeg decoder sample methods.
|
||||
*/
|
||||
typedef enum {
|
||||
JPEG_DOWN_SAMPLING_YUV444 = COLOR_TYPE_ID(COLOR_SPACE_YUV, COLOR_PIXEL_YUV444), /*!< Sample by YUV444 */
|
||||
JPEG_DOWN_SAMPLING_YUV422 = COLOR_TYPE_ID(COLOR_SPACE_YUV, COLOR_PIXEL_YUV422), /*!< Sample by YUV422 */
|
||||
JPEG_DOWN_SAMPLING_YUV420 = COLOR_TYPE_ID(COLOR_SPACE_YUV, COLOR_PIXEL_YUV420), /*!< Sample by YUV420 */
|
||||
JPEG_DOWN_SAMPLING_GRAY = COLOR_TYPE_ID(COLOR_SPACE_GRAY, COLOR_PIXEL_GRAY8), /*!< Sample the gray picture */
|
||||
JPEG_DOWN_SAMPLING_YUV444 = ESP_COLOR_FOURCC_YUV, /*!< Sample by YUV444 */
|
||||
JPEG_DOWN_SAMPLING_YUV422 = ESP_COLOR_FOURCC_YVYU, /*!< Sample by YUV422 */
|
||||
JPEG_DOWN_SAMPLING_YUV420 = ESP_COLOR_FOURCC_OUYY_EVYY, /*!< Sample by YUV420 */
|
||||
JPEG_DOWN_SAMPLING_GRAY = ESP_COLOR_FOURCC_GREY, /*!< Sample the gray picture */
|
||||
} jpeg_down_sampling_type_t;
|
||||
|
||||
/**
|
||||
* @brief JPEG encoder source formats.
|
||||
*/
|
||||
typedef enum {
|
||||
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_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_RGB888 = ESP_COLOR_FOURCC_RGB24, /*!< JPEG encoder source RGB888 */
|
||||
JPEG_ENC_SRC_YUV422 = ESP_COLOR_FOURCC_YVYU, /*!< JPEG encoder source YUV422 */
|
||||
JPEG_ENC_SRC_RGB565 = ESP_COLOR_FOURCC_RGB16_BE, /*!< JPEG encoder source RGB565 */
|
||||
JPEG_ENC_SRC_YUV444 = ESP_COLOR_FOURCC_YUV, /*!< JPEG encoder source YUV444 */
|
||||
JPEG_ENC_SRC_YUV420 = ESP_COLOR_FOURCC_OUYY_EVYY, /*!< JPEG encoder source YUV420 */
|
||||
JPEG_ENC_SRC_GRAY = ESP_COLOR_FOURCC_GREY, /*!< JPEG encoder source GRAY */
|
||||
} jpeg_enc_src_type_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
Reference in New Issue
Block a user