• 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 ihevce_decomp_pre_intra_structs.h
23 *
24 * \brief
25 *    This file contains strcutures of pre_enc_loop pass
26 *
27 * \date
28 *    18/09/2012
29 *
30 * \author
31 *    Ittiam
32 *
33 ******************************************************************************
34 */
35 
36 #ifndef _IHEVCE_DECOMP_PRE_INTRA_STRUCTS_H_
37 #define _IHEVCE_DECOMP_PRE_INTRA_STRUCTS_H_
38 
39 /*****************************************************************************/
40 /* Constant Macros                                                           */
41 /*****************************************************************************/
42 
43 /*For decomposition of every row we need some extra rows above n below that row*/
44 #define NUM_EXTRA_ROWS_REQ 3
45 
46 /*Macros for pre intra early decisions*/
47 #define NUM_MODES 35
48 #define SAD_NOT_VALID 0xFFFFF
49 
50 #define SET_T_AVAILABLE(x) (x = x | (1 << 8))
51 #define SET_L_AVAILABLE(x) (x = x | (1 << 7))
52 #define SET_TL_AVAILABLE(x) (x = x | (1 << 16))
53 #define SET_TR_AVAILABLE(x) (x = x | (1 << 12))
54 #define SET_BL_AVAILABLE(x) (x = x | (1 << 3))
55 #define SET_ALL_AVAILABLE(x) (x = (1 << 8) + (1 << 7) + (1 << 16) + (1 << 12) + (1 << 3))
56 
57 #define SET_T_UNAVAILABLE(x) (x = x & ~((WORD32)1 << 8))
58 #define SET_L_UNAVAILABLE(x) (x = x & ~((WORD32)1 << 7))
59 #define SET_TL_UNAVAILABLE(x) (x = x & ~((WORD32)1 << 16))
60 #define SET_TR_UNAVAILABLE(x) (x = x & ~((WORD32)1 << 12))
61 #define SET_BL_UNAVAILABLE(x) (x = x & ~((WORD32)1 << 3))
62 #define SET_ALL_UNAVAILABLE(x) (x = 0)
63 
64 #define CHECK_T_AVAILABLE(x) ((x & (1 << 8)) >> 8)
65 #define CHECK_L_AVAILABLE(x) ((x & (1 << 7)) >> 7)
66 #define CHECK_TL_AVAILABLE(x) ((x & (1 << 16)) >> 16)
67 #define CHECK_TR_AVAILABLE(x) ((x & (1 << 12)) >> 12)
68 #define CHECK_BL_AVAILABLE(x) ((x & (1 << 3)) >> 3)
69 
70 /*  q format for lamba used in the encoder                                   */
71 #define LAMBDA_Q_SHIFT 8
72 
73 /*****************************************************************************/
74 /* Enums                                                                     */
75 /*****************************************************************************/
76 typedef enum
77 {
78     DECOMP_PRE_INTRA_CTXT = 0,
79     DECOMP_PRE_INTRA_THRDS_CTXT,
80     DECOMP_PRE_INTRA_ED_CTXT,
81 
82     /* should always be the last entry */
83     NUM_DECOMP_PRE_INTRA_MEM_RECS
84 } DECOMP_PRE_INTRA_MEM_TABS_T;
85 
86 /*****************************************************************************/
87 /* Structure                                                                 */
88 /*****************************************************************************/
89 
90 /**
91 ******************************************************************************
92  *  @brief  Context for  early intra or inter decision
93 ******************************************************************************
94  */
95 typedef struct
96 {
97     /** lambda for cost calculation */
98     WORD32 lambda;
99 
100     /*Pointer to 4x4 blocks of entire frame */
101     ihevce_ed_blk_t *ps_ed_pic;
102 
103     /*Pointer to present 4x4 block */
104     ihevce_ed_blk_t *ps_ed;
105 
106     /*Pointer to ctb level data of entire frame */
107     ihevce_ed_ctb_l1_t *ps_ed_ctb_l1_pic;
108 
109     /*Pointer to ctb level data of current ctb */
110     ihevce_ed_ctb_l1_t *ps_ed_ctb_l1;
111 
112     /*Sum of best SATDs at L1*/
113     LWORD64 i8_sum_best_satd;
114 
115     /*Sum of best SATDs at L1*/
116     LWORD64 i8_sum_sq_best_satd;
117 
118     /** Encoder quality preset : See IHEVCE_QUALITY_CONFIG_T for presets */
119     WORD32 i4_quality_preset;
120 
121     /*following are the changes for reducing the stack memory used by this module. Local variables are copied to context memory */
122 
123     /** Neighbour flags. Used as local variable in pre_intra_process_row function. Shouldnt be used by other functions */
124     WORD32 ai4_nbr_flags[64];
125 
126     /** reference data for four 4x4 blocks. This is used as local variable in ed_calc_8x8_blk */
127     UWORD8 au1_ref_full_ctb[4][18];
128 
129     /** reference data for 8x8 block. This is used as local variable in ed_calc_8x8_blk */
130     UWORD8 au1_ref_8x8[1][33];
131 
132     /** mode bits costs array. This is used as local variable in ed_calc_8x8_blk */
133     UWORD16 au2_mode_bits_cost_full_ctb[4][NUM_MODES];
134 
135     /** Pointer to structure containing function pointers of common*/
136     func_selector_t *ps_func_selector;
137 
138 } ihevce_ed_ctxt_t;  //early decision
139 
140 typedef struct
141 {
142     /** Actual Width of this layer */
143     WORD32 i4_actual_wd;
144 
145     /** Actual height of this layer */
146     WORD32 i4_actual_ht;
147 
148     /** Padded width of this layer */
149     WORD32 i4_padded_wd;
150 
151     /** Padded height of this layer */
152     WORD32 i4_padded_ht;
153 
154     /** input pointer. */
155     UWORD8 *pu1_inp;
156 
157     /** stride of input buffer */
158     WORD32 i4_inp_stride;
159 
160     /** Decomposition block height size */
161     WORD32 i4_decomp_blk_ht;
162 
163     /** Decomposition block width size */
164     WORD32 i4_decomp_blk_wd;
165 
166     /** Number of blocks in a row */
167     WORD32 i4_num_col_blks;
168 
169     /** Number of rows in a layer */
170     WORD32 i4_num_row_blks;
171     WORD32 ai4_curr_row_no[MAX_NUM_CTB_ROWS_FRM];
172 
173     WORD32 i4_num_rows_processed;
174 } decomp_layer_ctxt_t;
175 
176 typedef struct
177 {
178     /* Number of layers */
179     WORD32 i4_num_layers;
180 
181     /** Handles for all layers. Entry 0 refers to L0 , 3 refers to L3 */
182     decomp_layer_ctxt_t as_layers[MAX_NUM_HME_LAYERS];
183 
184     /** Array for working memory of the thread */
185     UWORD8 au1_wkg_mem[((MAX_CTB_SIZE >> 1) * (MAX_CTB_SIZE + 2 * NUM_EXTRA_ROWS_REQ))];
186 
187     /** Encoder quality preset : See IHEVCE_QUALITY_CONFIG_T for presets */
188     WORD32 i4_quality_preset;
189 
190     /** ed_ctxt pointer. This memory is re-used across layers now */
191     ihevce_ed_ctxt_t *ps_ed_ctxt;
192 
193     ihevce_ed_blk_t *ps_layer1_buf;
194     ihevce_ed_blk_t *ps_layer2_buf;
195     ihevce_ed_ctb_l1_t *ps_ed_ctb_l1;
196 
197     WORD32 ai4_lambda[MAX_NUM_HME_LAYERS];
198 
199     /* pointer to the structure ps_ctb_analyse in pre_enc_me_ctxt_t */
200     ctb_analyse_t *ps_ctb_analyse;
201 
202     WORD32 i4_enable_noise_detection;
203 
204     ihevce_ipe_optimised_function_list_t s_ipe_optimised_function_list;
205 
206     ihevce_cmn_opt_func_t s_cmn_opt_func;
207 
208 } ihevce_decomp_pre_intra_ctxt_t;
209 
210 /**
211 ******************************************************************************
212  *  @brief  Encode loop master context structure
213 ******************************************************************************
214 */
215 typedef struct
216 {
217     /** Array of encode loop structure */
218     ihevce_decomp_pre_intra_ctxt_t *aps_decomp_pre_intra_thrd_ctxt[MAX_NUM_FRM_PROC_THRDS_PRE_ENC];
219 
220     /** Number of processing threads created run time */
221     WORD32 i4_num_proc_thrds;
222 
223 } ihevce_decomp_pre_intra_master_ctxt_t;
224 
225 /*****************************************************************************/
226 /* Extern Variable Declarations                                              */
227 /*****************************************************************************/
228 
229 /*****************************************************************************/
230 /* Extern Function Declarations                                              */
231 /*****************************************************************************/
232 
233 #endif /* _IHEVCE_DECOMP_PRE_INTRA_STRUCTS_H_ */
234