• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2  *
3  * Copyright (C) 2018 The Android Open Source Project
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at:
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *****************************************************************************
18  * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
19 */
20 /*!
21 ******************************************************************************
22 * \file rate_control_api_structs.h
23 *
24 * \brief
25 *    This file contains rate_control API struct and constant macro
26 *
27 * \date
28 *
29 * \author
30 *    ittiam
31 *
32 ******************************************************************************
33 */
34 #ifndef _RATE_CONTROL_API_STRUCTS_H_
35 #define _RATE_CONTROL_API_STRUCTS_H_
36 
37 /* The following definitions were present in rc_cntrl_param.h, moved to this file
38    as it is used by rate_control_api.c*/
39 /*#define VBR_BIT_ALLOC_PERIOD 3  num_frm_in_period = BIT_ALLOC_PERIOD*intra_frame_interval */
40 /*****************************************************************************/
41 /* Constant Macros                                                           */
42 /*****************************************************************************/
43 #define CBR_BIT_ALLOC_PERIOD 1
44 #define MAX_SCENE_NUM_RC 30
45 #define HALF_MAX_SCENE_NUM_RC MAX_SCENE_NUM_RC / 2
46 
47 /*****************************************************************************/
48 /* Structure                                                                 */
49 /*****************************************************************************/
50 /* Rate control state structure */
51 typedef struct rate_control_api_t
52 {
53     rc_type_e e_rc_type; /* RC Algorithm */
54     UWORD8 u1_is_mb_level_rc_on; /* Whether MB level rc is enabled or not */
55     /* rate_control_param_t s_rate_control_param;                 Store a copy of input parameters for re-initialisation */
56     pic_handling_handle ps_pic_handling; /* Picture handling struct */
57     rc_rd_model_handle aps_rd_model[MAX_PIC_TYPE]; /* Model struct for I and P frms */
58     vbr_storage_vbv_handle ps_vbr_storage_vbv; /* VBR storage VBV structure */
59     est_sad_handle ps_est_sad; /* Calculate the estimated SAD */
60     bit_allocation_handle ps_bit_allocation; /* Allocation of bits for each frame */
61     mb_rate_control_handle ps_mb_rate_control; /* MB Level rate control state structure */
62     sad_acc_handle ps_sad_acc; /* Sad accumulator */
63     UWORD8 au1_is_first_frm_coded[MAX_PIC_TYPE];
64     WORD32 ai4_prev_frm_qp[MAX_SCENE_NUM_RC][MAX_PIC_TYPE];
65     WORD32 ai4_prev_frm_qp_q6[MAX_SCENE_NUM_RC][MAX_PIC_TYPE];
66 
67     cbr_buffer_handle ps_cbr_buffer;
68     UWORD8 au1_avg_bitrate_changed[MAX_PIC_TYPE];
69     UWORD8 u1_is_first_frm;
70     /* UWORD8               au1_min_max_qp[(MAX_PIC_TYPE << 1)]; */
71     WORD32 ai4_min_qp[MAX_PIC_TYPE];
72     WORD32 ai4_max_qp[MAX_PIC_TYPE];
73     WORD32 ai4_max_qp_q6[MAX_PIC_TYPE];
74     WORD32 ai4_min_qp_q6[MAX_PIC_TYPE];
75 
76     WORD32 i4_prev_frm_est_bits;
77     WORD32 i4_orig_frm_est_bits;
78     vbr_str_prms_t s_vbr_str_prms;
79     init_qp_handle ps_init_qp;
80     /* Store the values which are to be impacted after a delay */
81     UWORD32 u4_frms_in_delay_prd_for_peak_bit_rate_change;
82     UWORD32 au4_new_peak_bit_rate[MAX_NUM_DRAIN_RATES];
83     picture_type_e prev_ref_pic_type;
84     WORD32 i4_P_to_I_ratio;
85     WORD32 ai4_min_texture_bits[MAX_PIC_TYPE];
86     /* Complexity based buffer movement */
87     WORD32 i4_prev_ref_is_scd;
88     WORD32 i4_is_hbr; /*Flag to indicate CBR_NLDRC_HBR*/
89     WORD32 i4_num_active_pic_type;
90     WORD32 i4_lap_f_sim;
91     WORD32 i4_quality_preset;
92     WORD32 i4_scd_I_frame_estimated_tot_bits;
93     WORD32 i4_I_frame_qp_model; /*offline = 0, online = 1*/
94     LWORD64 i8_per_pixel_p_frm_hme_sad_q10;
95     UWORD32 u4_min_scd_hevc_qp;
96     UWORD32 u4_bit_depth_based_max_qp;
97     UWORD8 u1_bit_depth;
98     FILE *pf_rc_stat_file;
99     WORD32 i4_rc_pass; /*variable to differentiate first pass and second pass*/
100     WORD32 i4_max_frame_width;
101     WORD32 i4_max_frame_height;
102     void *pv_2pass_gop_summary;
103     WORD32 i4_num_gop;
104     void *pv_rc_sys_api;
105     /*In static cases signal the future underflow warning to lower the qp*/
106     WORD32 i4_underflow_warning;
107     float f_max_hme_sad_per_pixel;
108     /*f_p_to_i_comp_ratio is for comparison of pre intra complexity of  i & p frames
109     It is used for jacking up of p frame qp if i frame was
110     extremely simple to avoid overconsumption of bits in p frame*/
111     float f_p_to_i_comp_ratio;
112     /*i4_scd_in_period_2_pass is used to signal the scd in period for 2 pass
113     this signal is one of the criteria for clipping the sudden increase of qp*/
114     WORD32 i4_scd_in_period_2_pass;
115     WORD32 i4_is_infinite_gop;
116     WORD32 i4_frames_since_last_scd;
117     WORD32 i4_num_frame_parallel;
118     WORD32 ai4_est_tot_bits[MAX_NUM_FRAME_PARALLEL];
119     WORD32 i4_capped_vbr_flag;
120 } rate_control_api_t;
121 
122 #endif /*_RATE_CONTROL_API_STRUCTS_H_*/
123