1 /* 2 * Copyright 2016 Rockchip Electronics Co. LTD 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef __RC_BASE_H__ 18 #define __RC_BASE_H__ 19 20 #include "mpp_list.h" 21 #include "mpp_enc_cfg.h" 22 #include "mpp_rc.h" 23 24 /* 25 * mpp rate control contain common caculation methd 26 */ 27 28 /* 29 * 1. MppData - data statistic struct 30 * size - max valid data number 31 * pos_pw - current data preset write position 32 * pos_w - current data write position 33 * pos_r - current data read position 34 * val - buffer array pointer 35 * 36 * When statistic length is less than 8 use direct save mode which will move 37 * all the data on each update. 38 * When statistic length is larger than 8 use loop save mode which will 39 * cyclically reuse the data position. 40 */ 41 typedef struct MppDataV2_t { 42 RK_S32 size; 43 RK_S32 pos_r; 44 RK_S32 pos_pw; 45 RK_S32 pos_w; 46 RK_S32 pos_ahead; 47 RK_S64 sum; 48 RK_S32 val[]; 49 } MppDataV2; 50 51 #ifdef __cplusplus 52 extern "C" { 53 #endif 54 55 MPP_RET mpp_data_init_v2(MppDataV2 **p, RK_S32 len, RK_S32 value); 56 void mpp_data_deinit_v2(MppDataV2 *p); 57 void mpp_data_reset_v2(MppDataV2 *p, RK_S32 val); 58 void mpp_data_preset_v2(MppDataV2 *p, RK_S32 val); 59 void mpp_data_update_v2(MppDataV2 *p, RK_S32 val); 60 RK_S32 mpp_data_sum_v2(MppDataV2 *p); 61 RK_S32 mpp_data_mean_v2(MppDataV2 *p); 62 RK_S32 mpp_data_get_pre_val_v2(MppDataV2 *p, RK_S32 idx); 63 RK_S32 mpp_data_sum_with_ratio_v2(MppDataV2 *p, RK_S32 len, RK_S32 num, RK_S32 denorm); 64 65 #ifdef __cplusplus 66 } 67 #endif 68 69 #endif /* __RC_BASE_H__ */ 70