diff --git a/components/esp_driver_jpeg/include/driver/jpeg_decode.h b/components/esp_driver_jpeg/include/driver/jpeg_decode.h index 0d2d818ac3..4266c9290b 100644 --- a/components/esp_driver_jpeg/include/driver/jpeg_decode.h +++ b/components/esp_driver_jpeg/include/driver/jpeg_decode.h @@ -9,6 +9,7 @@ #include #include "esp_err.h" #include "jpeg_types.h" +#include "hal/jpeg_types.h" #ifdef __cplusplus extern "C" { @@ -19,7 +20,7 @@ extern "C" { */ typedef struct { jpeg_dec_output_format_t output_format; /*!< JPEG decoder output format */ - jpeg_dec_rgb_element_order_t rgb_order; /*!< JPEG decoder output order */ + jpeg_dec_rgb_element_order_t rgb_order; /*!< JPEG decoder output order */ jpeg_yuv_rgb_conv_std_t conv_std; /*!< JPEG decoder yuv->rgb standard */ } jpeg_decode_cfg_t; @@ -37,6 +38,7 @@ typedef struct { typedef struct { uint32_t width; /*!< Number of pixels in the horizontal direction */ uint32_t height; /*!< Number of pixels in the vertical direction */ + jpeg_down_sampling_type_t sample_method; /*!< compressed JPEG picture sampling method */ } jpeg_decode_picture_info_t; /** diff --git a/components/esp_driver_jpeg/include/driver/jpeg_types.h b/components/esp_driver_jpeg/include/driver/jpeg_types.h index f9fa8dcd07..08ab102951 100644 --- a/components/esp_driver_jpeg/include/driver/jpeg_types.h +++ b/components/esp_driver_jpeg/include/driver/jpeg_types.h @@ -20,6 +20,9 @@ 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_dec_output_format_t; /** @@ -53,6 +56,7 @@ 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_enc_input_format_t; /** diff --git a/components/esp_driver_jpeg/jpeg_decode.c b/components/esp_driver_jpeg/jpeg_decode.c index d06fa13e1f..422c2afd2b 100644 --- a/components/esp_driver_jpeg/jpeg_decode.c +++ b/components/esp_driver_jpeg/jpeg_decode.c @@ -144,6 +144,7 @@ esp_err_t jpeg_decoder_get_info(const uint8_t *in_buf, uint32_t inbuf_len, jpeg_ uint16_t width = 0; uint8_t thischar = 0; uint8_t lastchar = 0; + uint8_t hivi = 0; while (header_info->buffer_left) { lastchar = thischar; @@ -155,6 +156,10 @@ esp_err_t jpeg_decoder_get_info(const uint8_t *in_buf, uint32_t inbuf_len, jpeg_ jpeg_get_bytes(header_info, 1); height = jpeg_get_bytes(header_info, 2); width = jpeg_get_bytes(header_info, 2); + + jpeg_get_bytes(header_info, 1); + jpeg_get_bytes(header_info, 1); + hivi = jpeg_get_bytes(header_info, 1); break; } // This function only used for get width and height. So only read SOF marker is enough. @@ -167,6 +172,21 @@ esp_err_t jpeg_decoder_get_info(const uint8_t *in_buf, uint32_t inbuf_len, jpeg_ picture_info->height = height; picture_info->width = width; + switch (hivi) { + case 0x11: + picture_info->sample_method = JPEG_DOWN_SAMPLING_YUV444; + break; + case 0x21: + picture_info->sample_method = JPEG_DOWN_SAMPLING_YUV422; + break; + case 0x22: + picture_info->sample_method = JPEG_DOWN_SAMPLING_YUV420; + break; + default: + ESP_LOGE(TAG, "Sampling factor cannot be recognized"); + return ESP_ERR_INVALID_STATE; + } + free(header_info); return ESP_OK; } @@ -195,14 +215,13 @@ esp_err_t jpeg_decoder_process(jpeg_decoder_handle_t decoder_engine, const jpeg_ decoder_engine->output_format = decode_cfg->output_format; decoder_engine->rgb_order = decode_cfg->rgb_order; decoder_engine->conv_std = decode_cfg->conv_std; - decoder_engine->decoded_buf = decode_outbuf; ESP_GOTO_ON_ERROR(jpeg_parse_marker(decoder_engine, bit_stream, stream_size), err, TAG, "jpeg parse marker failed"); ESP_GOTO_ON_ERROR(jpeg_parse_header_info_to_hw(decoder_engine), err, TAG, "write header info to hw failed"); ESP_GOTO_ON_ERROR(jpeg_dec_config_dma_descriptor(decoder_engine), err, TAG, "config dma descriptor failed"); - *out_size = decoder_engine->header_info->process_h * decoder_engine->header_info->process_v * decoder_engine->pixel; + *out_size = decoder_engine->header_info->process_h * decoder_engine->header_info->process_v * decoder_engine->bit_per_pixel / 8; ESP_GOTO_ON_FALSE((*out_size <= outbuf_size), ESP_ERR_INVALID_ARG, err, TAG, "Given buffer size % " PRId32 " is smaller than actual jpeg decode output size % " PRId32 "the height and width of output picture size will be adjusted to 16 bytes aligned automatically", outbuf_size, *out_size); dma2d_trans_config_t trans_desc = { @@ -222,8 +241,8 @@ esp_err_t jpeg_decoder_process(jpeg_decoder_handle_t decoder_engine, const jpeg_ // Blocking for JPEG decode transaction finishes. while (1) { jpeg_dma2d_dec_evt_t jpeg_dma2d_event; - BaseType_t ret = xQueueReceive(decoder_engine->evt_queue, &jpeg_dma2d_event, decoder_engine->timeout_tick); - ESP_GOTO_ON_FALSE(ret == pdTRUE, ESP_ERR_TIMEOUT, err, TAG, "jpeg-dma2d handle jpeg decode timeout, please check `timeout_ms` "); + BaseType_t ret_val = xQueueReceive(decoder_engine->evt_queue, &jpeg_dma2d_event, decoder_engine->timeout_tick); + ESP_GOTO_ON_FALSE(ret_val == pdTRUE, ESP_ERR_TIMEOUT, err, TAG, "jpeg-dma2d handle jpeg decode timeout, please check `timeout_ms` "); // Dealing with JPEG event if (jpeg_dma2d_event.jpgd_status != 0) { @@ -328,23 +347,49 @@ static esp_err_t jpeg_dec_config_dma_descriptor(jpeg_decoder_handle_t decoder_en 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->pixel = color_hal_pixel_format_get_bit_depth(picture_format) / 8; - switch (decoder_engine->output_format) { - case JPEG_DECODE_OUT_FORMAT_RGB888: - best_hb_idx = JPEG_DEC_RGB888_HB; + decoder_engine->bit_per_pixel = color_hal_pixel_format_get_bit_depth(picture_format); + if (decoder_engine->no_color_conversion == false) { + switch (decoder_engine->output_format) { + case JPEG_DECODE_OUT_FORMAT_RGB888: + best_hb_idx = JPEG_DEC_RGB888_HB; + break; + case JPEG_DECODE_OUT_FORMAT_RGB565: + best_hb_idx = JPEG_DEC_RGB565_HB; + break; + case JPEG_DECODE_OUT_FORMAT_GRAY: + best_hb_idx = JPEG_DEC_GRAY_HB; + break; + case JPEG_DECODE_OUT_FORMAT_YUV444: + best_hb_idx = JPEG_DEC_YUV444_HB; + break; + default: + ESP_LOGE(TAG, "wrong, we don't support decode to such format."); + return ESP_ERR_NOT_SUPPORTED; + } + } else { + best_hb_idx = JPEG_DEC_DIRECT_OUTPUT_HB; + } + + uint8_t sample_method_idx = 0; + switch (decoder_engine->sample_method) { + case JPEG_DOWN_SAMPLING_YUV444: + sample_method_idx = 0; break; - case JPEG_DECODE_OUT_FORMAT_RGB565: - best_hb_idx = JPEG_DEC_RGB565_HB; + case JPEG_DOWN_SAMPLING_YUV422: + sample_method_idx = 1; break; - case JPEG_DECODE_OUT_FORMAT_GRAY: - best_hb_idx = JPEG_DEC_GRAY_HB; + case JPEG_DOWN_SAMPLING_YUV420: + sample_method_idx = 2; + break; + case JPEG_DOWN_SAMPLING_GRAY: + sample_method_idx = 3; break; default: - ESP_LOGE(TAG, "wrong, we don't support decode to such format."); + ESP_LOGE(TAG, "wrong, we don't support such sampling mode."); return ESP_ERR_NOT_SUPPORTED; } - uint32_t dma_hb = dec_hb_tbl[decoder_engine->sample_method][best_hb_idx]; + uint32_t dma_hb = dec_hb_tbl[sample_method_idx][best_hb_idx]; uint32_t dma_vb = decoder_engine->header_info->mcuy; // Configure tx link descriptor @@ -375,7 +420,6 @@ static void jpeg_dec_config_dma_csc(jpeg_decoder_handle_t decoder_engine, dma2d_ dma2d_scramble_order_t post_scramble = DMA2D_SCRAMBLE_ORDER_BYTE2_1_0; dma2d_csc_rx_option_t rx_csc_option = DMA2D_CSC_RX_NONE; - // Config output Endians if (decoder_engine->rgb_order == JPEG_DEC_RGB_ELEMENT_ORDER_RGB) { if (decoder_engine->output_format == JPEG_DECODE_OUT_FORMAT_RGB565) { @@ -398,7 +442,13 @@ static void jpeg_dec_config_dma_csc(jpeg_decoder_handle_t decoder_engine, dma2d_ } else if (decoder_engine->conv_std == JPEG_YUV_RGB_CONV_STD_BT709) { rx_csc_option = DMA2D_CSC_RX_YUV420_TO_RGB888_709; } - } else if (decoder_engine->output_format == JPEG_DECODE_OUT_FORMAT_GRAY) { + } else if (decoder_engine->output_format == JPEG_DECODE_OUT_FORMAT_YUV444) { + if (decoder_engine->sample_method == JPEG_DOWN_SAMPLING_YUV422) { + rx_csc_option = DMA2D_CSC_RX_YUV422_TO_YUV444; + } else if (decoder_engine->sample_method == JPEG_DOWN_SAMPLING_YUV420) { + rx_csc_option = DMA2D_CSC_RX_YUV420_TO_YUV444; + } + } else { rx_csc_option = DMA2D_CSC_RX_NONE; } @@ -493,6 +543,27 @@ static bool jpeg_dec_transaction_on_picked(uint32_t channel_num, const dma2d_tra return false; } +static esp_err_t jpeg_color_space_support_check(jpeg_decoder_handle_t decoder_engine) +{ + 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"); + return ESP_ERR_INVALID_ARG; + } + } else if (decoder_engine->sample_method == JPEG_DOWN_SAMPLING_YUV422) { + if (decoder_engine->output_format == JPEG_DECODE_OUT_FORMAT_YUV420) { + ESP_LOGE(TAG, "Detected YUV422 but want to convert to YUV420, which is not supported"); + return ESP_ERR_INVALID_ARG; + } + } else if (decoder_engine->sample_method == JPEG_DOWN_SAMPLING_YUV420) { + if (decoder_engine->output_format == JPEG_DECODE_OUT_FORMAT_YUV422) { + ESP_LOGE(TAG, "Detected YUV420 but want to convert to YUV422, which is not supported"); + return ESP_ERR_INVALID_ARG; + } + } + return ESP_OK; +} + static esp_err_t jpeg_parse_header_info_to_hw(jpeg_decoder_handle_t decoder_engine) { ESP_RETURN_ON_FALSE(decoder_engine, ESP_ERR_INVALID_ARG, TAG, "jpeg decode handle is null"); @@ -534,6 +605,12 @@ static esp_err_t jpeg_parse_header_info_to_hw(jpeg_decoder_handle_t decoder_engi decoder_engine->sample_method = JPEG_DOWN_SAMPLING_GRAY; } + ESP_RETURN_ON_ERROR(jpeg_color_space_support_check(decoder_engine), TAG, "jpeg decoder not support the combination of output format and down sampling format"); + + if ((uint32_t)decoder_engine->sample_method == (uint32_t)decoder_engine->output_format) { + decoder_engine->no_color_conversion = true; + } + // Write DHT information dht_func[0][0](hal, header_info->huffbits[0][0], header_info->huffcode[0][0], header_info->tmp_huff); dht_func[0][1](hal, header_info->huffbits[0][1], header_info->huffcode[0][1], header_info->tmp_huff); diff --git a/components/esp_driver_jpeg/jpeg_encode.c b/components/esp_driver_jpeg/jpeg_encode.c index 9b5d260baf..976a2a6d54 100644 --- a/components/esp_driver_jpeg/jpeg_encode.c +++ b/components/esp_driver_jpeg/jpeg_encode.c @@ -142,6 +142,9 @@ esp_err_t jpeg_encoder_process(jpeg_encoder_handle_t encoder_engine, const jpeg_ ESP_RETURN_ON_FALSE(encode_inbuf, ESP_ERR_INVALID_ARG, TAG, "jpeg encode picture buffer is null"); ESP_RETURN_ON_FALSE(out_size, ESP_ERR_INVALID_ARG, TAG, "jpeg encode picture out_size is null"); ESP_RETURN_ON_FALSE(((uintptr_t)bit_stream % cache_hal_get_cache_line_size(CACHE_LL_LEVEL_EXT_MEM, CACHE_TYPE_DATA)) == 0, ESP_ERR_INVALID_ARG, TAG, "jpeg encode bit stream is not aligned, please use jpeg_alloc_encoder_mem to malloc your buffer"); + if (encode_cfg->src_type == JPEG_ENCODE_IN_FORMAT_YUV422) { + ESP_RETURN_ON_FALSE(encode_cfg->sub_sample == JPEG_DOWN_SAMPLING_YUV422, ESP_ERR_INVALID_ARG, TAG, "Sub sampling is not supported under this source type"); + } esp_err_t ret = ESP_OK; @@ -176,6 +179,10 @@ esp_err_t jpeg_encoder_process(jpeg_encoder_handle_t encoder_engine, const jpeg_ encoder_engine->color_space = JPEG_ENC_SRC_GRAY; best_hb_idx = JPEG_ENC_SRC_GRAY_HB; break; + case JPEG_ENCODE_IN_FORMAT_YUV422: + encoder_engine->color_space = JPEG_ENC_SRC_YUV422; + best_hb_idx = JPEG_ENC_SRC_YUV422_HB; + break; default: ESP_LOGE(TAG, "wrong, we don't support encode from such format."); ret = ESP_ERR_NOT_SUPPORTED; @@ -198,7 +205,26 @@ esp_err_t jpeg_encoder_process(jpeg_encoder_handle_t encoder_engine, const jpeg_ ESP_GOTO_ON_ERROR(s_jpeg_set_header_info(encoder_engine), err, TAG, "set header failed"); jpeg_hal_set_quantization_coefficient(hal, encoder_engine->header_info->m_quantization_tables[0], encoder_engine->header_info->m_quantization_tables[1]); - uint32_t dma_hb = enc_hb_tbl[best_hb_idx][encoder_engine->header_info->sub_sample]; + uint8_t sample_method_idx = 0; + switch (encoder_engine->header_info->sub_sample) { + case JPEG_DOWN_SAMPLING_YUV444: + sample_method_idx = 0; + break; + case JPEG_DOWN_SAMPLING_YUV422: + sample_method_idx = 1; + break; + case JPEG_DOWN_SAMPLING_YUV420: + sample_method_idx = 2; + break; + case JPEG_DOWN_SAMPLING_GRAY: + sample_method_idx = 3; + break; + default: + ESP_LOGE(TAG, "wrong, we don't support such sampling mode."); + return ESP_ERR_NOT_SUPPORTED; + } + + uint32_t dma_hb = enc_hb_tbl[best_hb_idx][sample_method_idx]; uint32_t dma_vb = encoder_engine->mcuy; ESP_GOTO_ON_FALSE((encoder_engine->header_info->header_len % cache_hal_get_cache_line_size(CACHE_LL_LEVEL_EXT_MEM, CACHE_TYPE_DATA)) == 0, ESP_ERR_INVALID_STATE, err, TAG, "The header is not cache line aligned, please check"); diff --git a/components/esp_driver_jpeg/jpeg_param.c b/components/esp_driver_jpeg/jpeg_param.c index 59bf6bb547..eb09925dd5 100644 --- a/components/esp_driver_jpeg/jpeg_param.c +++ b/components/esp_driver_jpeg/jpeg_param.c @@ -39,7 +39,7 @@ const uint8_t zigzag_arr[64] = { * decompression. It is used to decode the Huffman-coded symbols in the compressed * data stream during the decoding process. */ -const uint32_t dec_hb_tbl[JPEG_DOWN_SAMPLING_MAX][JPEG_DEC_BEST_HB_MAX] = { +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}, @@ -53,7 +53,7 @@ const uint32_t dec_hb_tbl[JPEG_DOWN_SAMPLING_MAX][JPEG_DEC_BEST_HB_MAX] = { * compression. It is used to decode the Huffman-coded symbols in the compressed * data stream during the encoding process. */ -const uint32_t enc_hb_tbl[JPEG_ENC_BEST_HB_MAX][JPEG_DOWN_SAMPLING_MAX] = { +const uint32_t enc_hb_tbl[JPEG_ENC_BEST_HB_MAX][JPEG_DOWN_SAMPLING_NUM] = { {40, 32, 32, 0}, {0, 64, 0, 0}, {64, 64, 48, 0}, diff --git a/components/esp_driver_jpeg/jpeg_private.h b/components/esp_driver_jpeg/jpeg_private.h index 2154de0f38..01a489f930 100644 --- a/components/esp_driver_jpeg/jpeg_private.h +++ b/components/esp_driver_jpeg/jpeg_private.h @@ -56,9 +56,8 @@ struct jpeg_codec_t { }; typedef enum { - // TODO: Support DR and YUV444 on decoder. - //JPEG_DEC_DR_HB = 0, /*!< Direct output */ - //JPEG_DEC_YUV444_HB = 1, /*!< output YUV444 format */ + JPEG_DEC_DIRECT_OUTPUT_HB = 0, /*!< Direct output */ + JPEG_DEC_YUV444_HB = 1, /*!< output YUV444 format */ 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 */ @@ -96,9 +95,10 @@ struct jpeg_decoder_t { jpeg_dec_header_info_t *header_info; // Pointer to current picture information jpeg_down_sampling_type_t sample_method; // method of sampling the JPEG picture. jpeg_dec_output_format_t output_format; // picture output format. - jpeg_dec_rgb_element_order_t rgb_order; // RGB pixel order + jpeg_dec_rgb_element_order_t rgb_order; // RGB pixel order jpeg_yuv_rgb_conv_std_t conv_std; // YUV RGB conversion standard - uint8_t pixel; // size per pixel + bool no_color_conversion; // No color conversion, directly output based on compressed format + uint8_t bit_per_pixel; // bit size per pixel QueueHandle_t evt_queue; // jpeg event from 2DDMA and JPEG engine uint8_t *decoded_buf; // pointer to the rx buffer. uint32_t total_size; // jpeg picture origin size (in bytes) @@ -127,8 +127,7 @@ typedef struct { typedef enum { JPEG_ENC_SRC_RGB888_HB = 0, // Input RGB888 format - // TODO: Support encoder source format for yuv422 - // 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_GRAY_HB = 3, // Input GRAY format JPEG_ENC_BEST_HB_MAX, diff --git a/components/esp_driver_jpeg/private/jpeg_param.h b/components/esp_driver_jpeg/private/jpeg_param.h index 4e1c2fc56c..abe66ff0e9 100644 --- a/components/esp_driver_jpeg/private/jpeg_param.h +++ b/components/esp_driver_jpeg/private/jpeg_param.h @@ -36,7 +36,7 @@ extern const uint8_t zigzag_arr[64]; * decompression. It is used to decode the Huffman-coded symbols in the compressed * data stream during the decoding process. */ -extern const uint32_t dec_hb_tbl[JPEG_DOWN_SAMPLING_MAX][JPEG_DEC_BEST_HB_MAX]; +extern const uint32_t dec_hb_tbl[JPEG_DOWN_SAMPLING_NUM][JPEG_DEC_BEST_HB_MAX]; /** * @brief DMA2D best hb value table for JPEG compression. @@ -45,7 +45,7 @@ extern const uint32_t dec_hb_tbl[JPEG_DOWN_SAMPLING_MAX][JPEG_DEC_BEST_HB_MAX]; * compression. It is used to decode the Huffman-coded symbols in the compressed * data stream during the encoding process. */ -extern const uint32_t enc_hb_tbl[JPEG_ENC_BEST_HB_MAX][JPEG_DOWN_SAMPLING_MAX]; +extern const uint32_t enc_hb_tbl[JPEG_ENC_BEST_HB_MAX][JPEG_DOWN_SAMPLING_NUM]; /** * @brief Setup the standard Huffman tables (JPEG standard sections K.3.3) diff --git a/components/hal/include/hal/jpeg_types.h b/components/hal/include/hal/jpeg_types.h index f81ff82df8..a8a833cdf9 100644 --- a/components/hal/include/hal/jpeg_types.h +++ b/components/hal/include/hal/jpeg_types.h @@ -23,6 +23,7 @@ extern "C" { #define DHT_TC_NUM (2) /// Table type #define DHT_TH_NUM (2) /// Huffman table destination identifier +#define JPEG_DOWN_SAMPLING_NUM (4) // The number of down sampling methods /** * @brief Enum for JPEG codec working mode. @@ -44,9 +45,9 @@ typedef struct { * @brief Enum for JPEG sampling mode. */ typedef enum { - JPEG_SAMPLE_MODE_YUV444 = COLOR_PIXEL_YUV444, ///< sample in YUV444 - JPEG_SAMPLE_MODE_YUV422 = COLOR_PIXEL_YUV422, ///< sample in YUV422 - JPEG_SAMPLE_MODE_YUV420 = COLOR_PIXEL_YUV420, ///< sample in YUV420 + 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_t; /** @@ -64,11 +65,10 @@ typedef union { * @brief Enumeration for jpeg decoder sample methods. */ typedef enum { - JPEG_DOWN_SAMPLING_YUV444 = 0, /*!< Sample by YUV444 */ - JPEG_DOWN_SAMPLING_YUV422 = 1, /*!< Sample by YUV422 */ - JPEG_DOWN_SAMPLING_YUV420 = 2, /*!< Sample by YUV420 */ - JPEG_DOWN_SAMPLING_GRAY = 3, /*!< Sample the gray picture */ - JPEG_DOWN_SAMPLING_MAX, /*!< Max value of sample enumeration */ + 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_type_t; /** diff --git a/examples/peripherals/jpeg/jpeg_decode/open_raw_picture.py b/examples/peripherals/jpeg/jpeg_decode/open_raw_picture.py index e92fe0973d..afb243db1d 100644 --- a/examples/peripherals/jpeg/jpeg_decode/open_raw_picture.py +++ b/examples/peripherals/jpeg/jpeg_decode/open_raw_picture.py @@ -168,7 +168,7 @@ def main(): # type: () -> None height = args.height width = args.width - data = open_picture('/media/simon/USB STICK/420.YUV') + data = open_picture(args.pic_path) if (args.pic_type == 'rgb565'): picture_show_rgb565(data, height, width) elif (args.pic_type == 'rgb888'):