Merge branch 'feature/support_isp_awb_v5.3' into 'release/v5.3'

feat(isp): Support ISP Auto White Balance (AWB) (v5.3)

See merge request espressif/esp-idf!31605
This commit is contained in:
morris
2024-07-25 17:02:22 +08:00
18 changed files with 1306 additions and 59 deletions
+33
View File
@@ -7,6 +7,7 @@
#pragma once
#include <stdint.h>
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
@@ -148,6 +149,38 @@ static inline uint32_t hal_utils_calc_lcm(uint32_t a, uint32_t b)
return (a * b / hal_utils_gcd(a, b));
}
/**
* @brief Fixed-point data configuration
*
*/
typedef struct {
uint32_t int_bit; /*!< Integer bit of the fixed point */
uint32_t frac_bit; /*!< Fractional bit of the fixed point */
bool saturation; /*!< Whether to limit the value to the maximum when fixed-point data overflow.
* When set true, the value will be limited to the maximum when the float type data is out of range.
* When set false, the function will return false when the float type data is out of range.
*/
} hal_utils_fixed_point_t;
/**
* @brief Convert the float type to fixed point type
* @note The supported data format:
* - [input] float (IEEE 754):
* sign(1bit) + exponent(8bit) + mantissa(23bit) (32 bit in total)
* - [output] fixed-point:
* sign(1bit) + integer(int_bit) + fraction(frac_bit) (less or equal to 32 bit)
*
* @param[in] flt IEEE 754 float type data
* @param[in] fp_cfg Fixed-point data configuration
* @param[out] fp_out The output fixed-point data
* @return
* 0: Success
* -1: Fixed point data overflow, `fp_out` will still be assigned
* -2: Float is NaN
* -3: Invalid configuration
*/
int hal_utils_float_to_fixed_point_32b(float flt, const hal_utils_fixed_point_t *fp_cfg, uint32_t *fp_out);
#ifdef __cplusplus
}
#endif
+51 -1
View File
@@ -13,7 +13,9 @@
#pragma once
#include <stdint.h>
#include <stdbool.h>
#include "hal/isp_types.h"
#include "hal/hal_utils.h"
#ifdef __cplusplus
extern "C" {
@@ -60,7 +62,7 @@ void isp_hal_init(isp_hal_context_t *hal, int isp_id);
*
* @param[in] hal Context of the HAL layer
* @param[in] window_id Window ID
* @param[in] window Window info, see `isp_af_window_t`
* @param[in] window Window info, see `isp_window_t`
*/
void isp_hal_af_window_config(const isp_hal_context_t *hal, int window_id, const isp_window_t *window);
@@ -86,6 +88,54 @@ uint32_t isp_hal_check_clear_intr_event(const isp_hal_context_t *hal, uint32_t m
*/
void isp_hal_bf_config(isp_hal_context_t *hal, isp_hal_bf_cfg_t *config);
/*---------------------------------------------------------------
AWB
---------------------------------------------------------------*/
/**
* @brief Set the window of the AWB
*
* @param[in] hal Context of the HAL layer
* @param[in] win Pointer to the window of the AWB
* @return
* - true Set success
* - false Invalid arg
*/
bool isp_hal_awb_set_window_range(const isp_hal_context_t *hal, const isp_window_t *win);
/**
* @brief Set the luminance range of the white patch
*
* @param[in] hal Context of the HAL layer
* @param[in] lum_min Minimum luminance
* @param[in] lum_max Maximum luminance
* @return
* - true Set success
* - false Invalid arg
*/
bool isp_hal_awb_set_luminance_range(const isp_hal_context_t *hal, uint32_t lum_min, uint32_t lum_max);
/**
* @brief Set the R/G ratio of the white patch
*
* @param[in] hal Context of the HAL layer
* @param[in] rg_ratio_range Range of Red to Green ratio
* @return
* - true Set success
* - false Invalid arg
*/
bool isp_hal_awb_set_rg_ratio_range(const isp_hal_context_t *hal, float rg_min, float rg_max);
/**
* @brief Set the B/R ratio of the white patch
*
* @param[in] hal Context of the HAL layer
* @param[in] bg_ratio_range Range of Blue to Green ratio
* @return
* - true Set success
* - false Invalid arg
*/
bool isp_hal_awb_set_bg_ratio_range(const isp_hal_context_t *hal, float bg_min, float bg_max);
#ifdef __cplusplus
}
#endif
+14 -8
View File
@@ -81,14 +81,6 @@ typedef enum {
#define ISP_AF_WINDOW_NUM 0
#endif
/**
* @brief ISP AF result
*/
typedef struct {
int definition[ISP_AF_WINDOW_NUM]; ///< Definition, it refers how clear and sharp an image is
int luminance[ISP_AF_WINDOW_NUM]; ///< Luminance, it refers how luminant an image is
} isp_af_result_t;
/*---------------------------------------------------------------
BF
---------------------------------------------------------------*/
@@ -108,6 +100,20 @@ typedef enum {
ISP_BF_EDGE_PADDING_MODE_CUSTOM_DATA, ///< Fill BF edge padding data with custom pixel data
} isp_bf_edge_padding_mode_t;
/*---------------------------------------------------------------
AWB
---------------------------------------------------------------*/
/**
* @brief ISP AWB sample point in the ISP pipeline
*
*/
typedef enum {
ISP_AWB_SAMPLE_POINT_BEFORE_CCM, ///< Sample AWB data before CCM (Color Correction Matrix)
ISP_AWB_SAMPLE_POINT_AFTER_CCM, ///< Sample AWB data after CCM (Color Correction Matrix)
} isp_awb_sample_point_t;
#ifdef __cplusplus
}
#endif