1 /* SPDX-License-Identifier: Apache-2.0 OR MIT */ 2 /* 3 * Copyright (c) 2016 Rockchip Electronics Co., Ltd. 4 */ 5 6 #ifndef __RC_BASE_H__ 7 #define __RC_BASE_H__ 8 9 #include "mpp_list.h" 10 #include "mpp_enc_cfg.h" 11 #include "mpp_rc.h" 12 13 /* 14 * mpp rate control contain common caculation methd 15 */ 16 17 /* 18 * 1. MppData - data statistic struct 19 * size - max valid data number 20 * pos_pw - current data preset write position 21 * pos_w - current data write position 22 * pos_r - current data read position 23 * val - buffer array pointer 24 * 25 * When statistic length is less than 8 use direct save mode which will move 26 * all the data on each update. 27 * When statistic length is larger than 8 use loop save mode which will 28 * cyclically reuse the data position. 29 */ 30 typedef struct MppDataV2_t { 31 RK_S32 size; 32 RK_S32 pos_r; 33 RK_S32 pos_pw; 34 RK_S32 pos_w; 35 RK_S32 pos_ahead; 36 RK_S64 sum; 37 RK_S32 val[]; 38 } MppDataV2; 39 40 #ifdef __cplusplus 41 extern "C" { 42 #endif 43 44 MPP_RET mpp_data_init_v2(MppDataV2 **p, RK_S32 len, RK_S32 value); 45 void mpp_data_deinit_v2(MppDataV2 *p); 46 void mpp_data_reset_v2(MppDataV2 *p, RK_S32 val); 47 void mpp_data_preset_v2(MppDataV2 *p, RK_S32 val); 48 void mpp_data_update_v2(MppDataV2 *p, RK_S32 val); 49 RK_S32 mpp_data_sum_v2(MppDataV2 *p); 50 RK_S32 mpp_data_mean_v2(MppDataV2 *p); 51 RK_S32 mpp_data_get_pre_val_v2(MppDataV2 *p, RK_S32 idx); 52 RK_S32 mpp_data_sum_with_ratio_v2(MppDataV2 *p, RK_S32 len, RK_S32 num, RK_S32 denom); 53 54 #ifdef __cplusplus 55 } 56 #endif 57 58 #endif /* __RC_BASE_H__ */ 59