mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-01 10:40:47 +03:00
refactor(jpeg): Split hal layer for jpeg
This commit is contained in:
@@ -1,117 +0,0 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
* NOTICE
|
||||
* The HAL is not public api, don't use in application code.
|
||||
* See readme.md in hal/include/hal/readme.md
|
||||
******************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include "hal/jpeg_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct jpeg_dev_t *jpeg_soc_handle_t; // JPEG SOC layer handle
|
||||
|
||||
/**
|
||||
* Context that should be maintained by both the driver and the HAL
|
||||
*/
|
||||
typedef struct {
|
||||
jpeg_soc_handle_t dev; // JPEG SOC layer handle (i.e. register base address)
|
||||
} jpeg_hal_context_t;
|
||||
|
||||
/**
|
||||
* @brief Initialize the JPEG codec HAL driver
|
||||
*
|
||||
* @param hal: JPEG codec HAL context
|
||||
*/
|
||||
void jpeg_hal_init(jpeg_hal_context_t *hal);
|
||||
|
||||
/**
|
||||
* @brief Deinitialize the JPEG codec HAL driver
|
||||
*
|
||||
* @param hal: JPEG codec HAL context
|
||||
*/
|
||||
void jpeg_hal_deinit(jpeg_hal_context_t *hal);
|
||||
|
||||
/**
|
||||
* @brief Function pointer typedef for configuring DHT tables in JPEG decoding.
|
||||
*
|
||||
* This function pointer typedef represents a callback function that can be used
|
||||
* to configure the DHT (Huffman) tables in the JPEG decoding process. It takes
|
||||
* as input a JPEG HAL context, as well as pointers to arrays representing the
|
||||
* minimum codes, bit lengths, and Huffman codes for the DHT tables.
|
||||
*
|
||||
* @param hal The JPEG HAL context.
|
||||
* @param huffbits Pointer to the array of bit lengths for the DHT tables.
|
||||
* @param huffcode Pointer to the array of Huffman codes for the DHT tables.
|
||||
*/
|
||||
typedef void (*jpeg_config_dht_table_t)(jpeg_hal_context_t *hal, uint8_t *huffbits, uint8_t *huffcode, uint32_t *tmp_huff);
|
||||
|
||||
/**
|
||||
* @brief Array of function pointers for configuring DHT tables in JPEG decoding.
|
||||
*
|
||||
* This two-dimensional array represents a collection of function pointers that
|
||||
* can be used to configure the DHT (Huffman) tables in the JPEG decoding process.
|
||||
*/
|
||||
extern jpeg_config_dht_table_t dht_func[DHT_TC_NUM][DHT_TH_NUM];
|
||||
|
||||
/**
|
||||
* Typedef for a function pointer to configure frame information in JPEG.
|
||||
*
|
||||
* This function is used to configure frame information in JPEG hardware.
|
||||
*
|
||||
* @param hw The JPEG SOC handle.
|
||||
* @param identifier The identifier of the frame.
|
||||
* @param horizontal_factor The horizontal factor for chroma subsampling.
|
||||
* @param vertical_factor The vertical factor for chroma subsampling.
|
||||
* @param qun_table_id The quantization table ID.
|
||||
*/
|
||||
typedef void (*jpeg_config_frame_info_t)(jpeg_soc_handle_t hw, uint8_t identifier, uint8_t horizontal_factor, uint8_t vertical_factor, uint8_t qun_table_id);
|
||||
|
||||
/**
|
||||
* Array of function pointers to configure frame information in JPEG.
|
||||
*
|
||||
* This array holds function pointers to configure frame information in JPEG hardware.
|
||||
* Each element corresponds to a specific component number.
|
||||
*/
|
||||
extern jpeg_config_frame_info_t sof_func[JPEG_COMPONENT_NUMBER_MAX];
|
||||
|
||||
/**
|
||||
* Typedef for a function pointer to configure quantization coefficients in JPEG.
|
||||
*
|
||||
* This function is used to configure quantization coefficients in JPEG hardware.
|
||||
*
|
||||
* @param hw The JPEG SOC handle.
|
||||
* @param quantization_table Pointer to the quantization table.
|
||||
*/
|
||||
typedef void (*jpeg_config_quantization_coefficient_t)(jpeg_soc_handle_t hw, uint32_t *quantization_table);
|
||||
|
||||
/**
|
||||
* Array of function pointers to configure quantization coefficients in JPEG.
|
||||
*
|
||||
* This array holds function pointers to configure quantization coefficients in JPEG hardware.
|
||||
* Each element corresponds to a specific component number.
|
||||
*/
|
||||
extern jpeg_config_quantization_coefficient_t dqt_func[JPEG_COMPONENT_NUMBER_MAX];
|
||||
|
||||
/**
|
||||
* Set the quantization coefficients for luminance and chrominance in the JPEG hardware accelerator context.
|
||||
*
|
||||
* @param hal Pointer to the JPEG hardware accelerator context.
|
||||
* @param lqnr Pointer to an array of luminance quantization coefficients.
|
||||
* @param cqnr Pointer to an array of chrominance quantization coefficients.
|
||||
*/
|
||||
void jpeg_hal_set_quantization_coefficient(jpeg_hal_context_t *hal, uint32_t *lqnr, uint32_t *cqnr);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -1,88 +0,0 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include "soc/soc_caps.h"
|
||||
#include "hal/color_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define JPEG_HUFFMAN_BITS_LEN_TABLE_LEN (16)
|
||||
#define JPEG_HUFFMAN_AC_VALUE_TABLE_LEN (256)
|
||||
#define JPEG_HUFFMAN_DC_VALUE_TABLE_LEN (16)
|
||||
#define JPEG_QUANTIZATION_TABLE_LEN (64)
|
||||
#define JPEG_COMPONENT_NUMBER_MAX (4)
|
||||
|
||||
#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.
|
||||
*/
|
||||
typedef enum {
|
||||
JPEG_CODEC_ENCODER, ///< Encode mode
|
||||
JPEG_CODEC_DECODER, ///< Decode mode
|
||||
} jpeg_codec_mode_t;
|
||||
|
||||
/**
|
||||
* @brief Structure for recording factor of component.
|
||||
*/
|
||||
typedef struct {
|
||||
uint32_t horizontal; ///< horizontal factor
|
||||
uint32_t vertical; ///< vertical factor
|
||||
} jpeg_component_factor_t;
|
||||
|
||||
/**
|
||||
* @brief Enum for JPEG sampling mode.
|
||||
*/
|
||||
typedef enum {
|
||||
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;
|
||||
|
||||
/**
|
||||
* @brief Structure for huffman information
|
||||
*/
|
||||
typedef union {
|
||||
struct {
|
||||
uint8_t id : 4; ///< Huffman table id
|
||||
uint8_t type : 4; ///< Huffman table type
|
||||
};
|
||||
uint8_t info; ///< Information of huffman table
|
||||
} jpeg_huffman_table_info_t;
|
||||
|
||||
/**
|
||||
* @brief Enumeration for jpeg decoder sample methods.
|
||||
*/
|
||||
typedef enum {
|
||||
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 = ESP_COLOR_FOURCC_BGR24, /*!< JPEG encoder source RGB888 */
|
||||
JPEG_ENC_SRC_YUV422 = ESP_COLOR_FOURCC_YVYU, /*!< JPEG encoder source YUV422 */
|
||||
JPEG_ENC_SRC_RGB565 = ESP_COLOR_FOURCC_RGB16, /*!< 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
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user