• 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_rd_model_struct.h
23 *
24 * \brief
25 *    This file contains rate control rd model struct and constant macro
26 *
27 * \date
28 *
29 * \author
30 *    ittiam
31 *
32 ******************************************************************************
33 */
34 #ifndef RC_RD_MODEL_STRUCT
35 #define RC_RD_MODEL_STRUCT
36 
37 /*****************************************************************************/
38 /* Constant Macros                                                           */
39 /*****************************************************************************/
40 /* Tool Set Switch */
41 #define ENABLE_QUAD_MODEL 1
42 
43 /* Number of elements for QP */
44 /* #define MPEG2_QP_ELEM       (MAX_MPEG2_QP + 1) */
45 
46 /*#define MAX_NUM_PIC_TYPES_FOR_RC_MODEL  3*/ /* how many types of pictures will the rate-control handle */
47 
48 #define QUAD 1
49 #define MIN_FRAMES_FOR_QUAD_MODEL 5
50 #define MAX_ACTIVE_FRAMES 16
51 #define MIN_FRAMES_FOR_LIN_MODEL 3
52 #define INVALID_FRAME_INDEX 255
53 
54 #define UP_THR_SM 1 /* (1  /pow(2,4) = 0.0625   */
55 #define UP_THR_E 4
56 
57 #define LO_THR_SM 368 /* (368.64 / pow(2,14)) = 0.0225 */
58 #define LO_THR_E 14
59 
60 #define QUAD_DEV_THR_SM 1 /* (1 / pow(1,2)) = .25*/
61 #define QUAD_DEV_THR_E 2
62 
63 #define LIN_DEV_THR_SM 1 /* (1 / pow(1,2)) = .25*/
64 #define LIN_DEV_THR_E 2
65 
66 #define QUAD_MODEL 0
67 #define LIN_MODEL 1
68 #define PREV_FRAME_MODEL 2
69 
70 /* Q Factors used for fixed point calculation */
71 #define Q_FORMAT_GAMMA 8
72 #define Q_FORMAT_ETA 8
73 
74 /*****************************************************************************/
75 /* Structure                                                                 */
76 /*****************************************************************************/
77 typedef struct rc_rd_model_t
78 {
79     UWORD8 u1_curr_frm_counter;
80     UWORD8 u1_num_frms_in_model;
81     UWORD8 u1_max_frms_to_model;
82     UWORD8 u1_model_used;
83 
84     UWORD32 pi4_res_bits[MAX_FRAMES_MODELLED];
85     LWORD64 pi8_sad[MAX_FRAMES_MODELLED];
86 
87     UWORD8 pu1_num_skips[MAX_FRAMES_MODELLED];
88     /* UWORD8   pu1_avg_qp[MAX_FRAMES_MODELLED]; */
89     WORD32 ai4_avg_qp[MAX_FRAMES_MODELLED];
90     WORD32 ai4_avg_qp_q6[MAX_FRAMES_MODELLED];
91     /* UWORD8   au1_num_frames[MPEG2_QP_ELEM];  */
92 
93     model_coeff model_coeff_a_quad;
94     model_coeff model_coeff_b_quad;
95     model_coeff model_coeff_c_quad;
96 
97     model_coeff model_coeff_a_lin;
98     model_coeff model_coeff_b_lin;
99     model_coeff model_coeff_c_lin;
100 
101     model_coeff model_coeff_a_lin_wo_int;
102     model_coeff model_coeff_b_lin_wo_int;
103     model_coeff model_coeff_c_lin_wo_int;
104 } rc_rd_model_t;
105 
106 #endif /* RC_RD_MODEL_STRUCT*/
107