• 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 rc_frame_info_collector.h
23 *
24 * \brief
25 *    This file contains structs used by encoder to pass information to RC lib
26 *
27 * \date
28 *
29 * \author
30 *    ittiam
31 *
32 ******************************************************************************
33 */
34 
35 #ifndef _RC_FRAME_INFO_COLLECTOR_H_
36 #define _RC_FRAME_INFO_COLLECTOR_H_
37 
38 /*****************************************************************************/
39 /* Constant Macros                                                           */
40 /*****************************************************************************/
41 
42 #define MAX_NUM_FRAME_IN_GOP 300
43 #define MAX_CHAR_IN_LINE 250
44 #define MAX_MEM_FOR_LINE (MAX_CHAR_IN_LINE + 1)
45 
46 // Minimum allocate memory for 10 bit allocation period
47 #define MIN_GOP_FOR_MEM_ALLOC 10
48 
49 /*****************************************************************************/
50 /* Structure                                                                 */
51 /*****************************************************************************/
52 typedef struct
53 {
54     WORD32 sm; /* MSB 1 bit sign & rest magnitude */
55     WORD32 e; /* Q-format */
56 } number_t_frame;
57 
58 typedef struct
59 {
60     LWORD64 i8_frame_num;
61     WORD32 i4_poc;
62     picture_type_e e_pic_type;
63     WORD32 i4_rc_hevc_qp;
64     WORD32 i4_scene_type; /*Should be in sync with what lap signals*/
65     float f_8bit_q_scale;
66     float f_8bit_q_scale_without_offset;
67     float f_hbd_q_scale;
68     float f_hbd_q_scale_without_offset;
69     LWORD64 i8_cl_sad;
70     LWORD64 i8_tex_bits;
71     LWORD64 i8_header_bits;
72     LWORD64 i8_L1_me_sad;
73     LWORD64 i8_L1_ipe_raw_sad;
74     LWORD64 i8_L1_me_or_ipe_raw_sad;
75     LWORD64 i8_L0_open_cost;
76     LWORD64 i8_est_texture_bits;
77     WORD32 i4_num_scd_in_lap_window;
78     WORD32 i4_num_frames_b4_scd;
79     WORD32 i4_num_entries;
80     LWORD64 i8_frame_acc_coarse_me_cost;
81     WORD32 i4_lap_f_sim;
82     float i_to_avg_bit_ratio;
83     WORD32 i4_lap_complexity_q7;
84     WORD32 i4_lap_var;
85     LWORD64 i8_num_bit_alloc_period;
86     WORD8 i1_is_complexity_based_bits_reset;
87     float af_sum_weigh[MAX_PIC_TYPE][3];
88     number_t_frame model_coeff_a_lin_wo_int;
89     WORD32 i4_flag_rc_model_update;
90     WORD32 i4_non_i_scd;
91 } frame_info_t;
92 
93 typedef struct
94 {
95     LWORD64 i4_gop_count;
96     WORD32 i4_tot_frm_in_gop;
97     //WORD32    ai4_pic_dist_in_cur_gop[MAX_PIC_TYPE];
98     float f_bits_complexity_l1_based;
99     float f_bits_complexity_l1_based_peak_factor;
100     float f_complexity_l1_based;
101     LWORD64 i8_bits_allocated_to_gop;
102     LWORD64 i8_tot_bits_consumed_first_pass;
103     float f_tot_bits_into_qscale_first_pass;
104     LWORD64 i8_L1_complexity_sad[MAX_NUM_FRAME_IN_GOP];
105     WORD8 ai1_is_complexlity_reset_bits[MAX_NUM_FRAME_IN_GOP];
106     WORD8 ai1_scene_type[MAX_NUM_FRAME_IN_GOP];
107     float f_den_wt_bits;
108     WORD32 ai4_pic_type[MAX_NUM_FRAME_IN_GOP];
109     LWORD64 ai8_head_bits_consumed[MAX_NUM_FRAME_IN_GOP];
110     LWORD64 ai8_tex_bits_consumed[MAX_NUM_FRAME_IN_GOP];
111     WORD32 ai4_first_pass_qscale[MAX_NUM_FRAME_IN_GOP];
112     WORD32 ai4_q6_frame_offsets[MAX_NUM_FRAME_IN_GOP];
113     float f_gop_level_buffer_play_factor;
114     //WORD32 i4_flag_query_buffer_excess;
115     float f_hbd_avg_q_scale_gop_without_offset;
116     WORD32 i4_num_scene_cuts;
117     LWORD64 i8_minimum_gop_bits;
118     WORD32 i4_is_below_avg_rate_gop_frame;
119     LWORD64 i8_cur_gop_bit_consumption;
120     LWORD64 i8_actual_bits_allocated_to_gop;
121     //LWORD64 i8_buffer_play_bits;
122     LWORD64 i8_buffer_play_bits_allocated_to_gop;
123     WORD32 i4_peak_br_clip;
124     float f_buffer_play_complexity;
125     float f_avg_complexity_factor;
126     //float f_gop_level_complexity_sum;
127     LWORD64 i8_max_bit_for_gop;
128     LWORD64 i8_acc_gop_sad;
129 } gop_level_stat_t;
130 /*This should be exact order in which data should be dumped and read back from stat file*/
131 
132 /*****************************************************************************/
133 /* Enums                                                                     */
134 /*****************************************************************************/
135 typedef enum
136 {
137     S_FRAME_NUM = 0,
138     S_POC,
139     S_PIC_TYPE,
140     S_HEVCQP,
141     S_SCENE_TYPE,
142     S_QSCALE,
143     S_CL_SAD,
144     S_HEAD_BITS,
145     S_TEXT_BITS,
146     S_EST_TEX_BITS,
147     S_L1_ME_SAD,
148     S_L1_IPE_SAD,
149     MAX_PARAM_DUMP
150 } DUMP_PARAM_TYPE_E;
151 
152 /*****************************************************************************/
153 /* Extern Function Declarations                                              */
154 /*****************************************************************************/
155 void init_frame_info(frame_info_t *frame_info);
156 
157 void multi_pass_dump_frame_level_stat_binary(
158     FILE *pf_stat_file,
159     frame_info_t *ps_finfo,
160     void *pv_lap_out,
161     WORD32 i4_size_of_lap_out,
162     void *pv_rc_lap_out,
163     WORD32 i4_size_of_rc_lap_out,
164     void *pv_sys_rc_api,
165     WORD32 i4_br_id_for_2pass);
166 
167 WORD32 multi_pass_extract_frame_data_binary(
168     FILE *pf_stat_file,
169     frame_info_t *ps_finfo,
170     void *pv_lap_out,
171     WORD32 i4_sizeof_lap_out,
172     void *pv_rc_lap_out,
173     WORD32 i4_sizeof_rc_lap_out,
174     LWORD64 i8_frame_offset,
175     WORD32 i4_flag,
176     void *pv_sys_rc_api,
177     WORD32 i4_br_id_for_2pass);
178 
179 #endif
180