| #ifndef SAMPLES_RISP4ML_ISP_STAGES_DOWNSCALE_H_ |
| #define SAMPLES_RISP4ML_ISP_STAGES_DOWNSCALE_H_ |
| |
| #include "samples/risp4ml/common/image.h" |
| |
| #ifdef __cplusplus |
| extern "C" { |
| #endif // __cplusplus |
| |
| typedef struct { |
| bool enable; |
| // scale_precision is the number of fractional bits used for scale factors and |
| // initial offsets |
| uint32_t scale_precision; |
| // interpolate_precision is the number of fractional bits used for |
| // interpolation weights |
| uint32_t interpolate_precision; |
| // interpolate_shift is the shift for pixel value before interpolation to |
| // avoid rounding error. |
| uint32_t interpolate_shift; |
| uint32_t scale_fixed_one; |
| uint32_t scale_fraction_mask; |
| uint32_t weight_shift; |
| |
| // hor_scale_factor and ver_scale_factor are the downscaling ratios between |
| // input size and output size |
| // Example: Running the scaler on 4x4 image with hor_scale=2 and ver_scale=2 |
| // will result in 2x2 image |
| // TODO(b/179302796): convert scaling factors to be floats. |
| // Use FloatToFixedPoint() to facilitate this. |
| uint32_t hor_scale_factor; |
| uint32_t ver_scale_factor; |
| |
| // hor_initial_offset and ver_initial_offset are the offset of the first |
| // output pixel from the first input pixel in each direction respectively |
| uint32_t ver_initial_offset; |
| uint32_t hor_initial_offset; |
| } DownscaleParams; |
| |
| void set_downscale_param(DownscaleParams* params); |
| |
| void set_downscale_factor(Image* input, ImageU8* output); |
| |
| void downscale_process(Image* input, ImageU8* output); |
| |
| #ifdef __cplusplus |
| } // extern "C" |
| #endif // __cplusplus |
| |
| #endif // SAMPLES_RISP4ML_ISP_STAGES_DOWNSCALE_H_ |