• 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_enc_loop_inter_mode_sifter.h
23 *
24 * \brief
25 *
26 * \date
27 *    11/09/2014
28 *
29 * \author
30 *    Ittiam
31 *
32 ******************************************************************************
33 */
34 #ifndef _IHEVCE_ENC_LOOP_INTER_MODE_SIFTER
35 #define _IHEVCE_ENC_LOOP_INTER_MODE_SIFTER
36 
37 /*****************************************************************************/
38 /* Function Macros                                                           */
39 /*****************************************************************************/
40 
41 #define SKIP_MODE_COST ((DISABLE_SKIP) ? INT_MAX : 1)
42 
43 #define COMPUTE_NUM_POSITIVE_REFERENCES_AND_FREE_IF_ZERO(                                          \
44     value_referred, pos_array, neg_array, length_pos_array, length_neg_array, usage_indicator)     \
45     {                                                                                              \
46         UWORD8 i;                                                                                  \
47                                                                                                    \
48         UWORD8 num_references = 0;                                                                 \
49                                                                                                    \
50         for(i = 0; i < length_pos_array; i++)                                                      \
51         {                                                                                          \
52             num_references += (value_referred == pos_array[i]);                                    \
53         }                                                                                          \
54                                                                                                    \
55         for(i = 0; i < length_neg_array; i++)                                                      \
56         {                                                                                          \
57             num_references -= (value_referred == neg_array[i]);                                    \
58         }                                                                                          \
59                                                                                                    \
60         if(num_references <= 0)                                                                    \
61         {                                                                                          \
62             ihevce_set_pred_buf_as_free(usage_indicator, value_referred);                          \
63         }                                                                                          \
64     }
65 
66 /*****************************************************************************/
67 /* Enums                                                                     */
68 /*****************************************************************************/
69 
70 typedef enum
71 {
72     ME_OR_SKIP_DERIVED = 0,
73     MERGE_DERIVED = 1,
74     MIXED_MODE_TYPE0 = 2,
75     MIXED_MODE_TYPE1 = 3
76 
77 } INTER_CANDIDATE_ID_T;
78 
79 typedef enum
80 {
81     CLASS1,
82     CLASS2,
83     CLASS3
84 
85 } UNIVERSE_CLASS_ID_T;
86 
87 /*****************************************************************************/
88 /* Structure                                                                 */
89 /*****************************************************************************/
90 typedef struct
91 {
92     cu_inter_merge_skip_t *ps_cu_inter_merge_skip;
93 
94     cu_mixed_mode_inter_t *ps_mixed_modes_datastore;
95 
96     cu_inter_cand_t *ps_me_cands;
97 
98     inter_cu_mode_info_t *ps_inter_cu_mode_info;
99 
100     mv_pred_ctxt_t *ps_mv_pred_ctxt;
101 
102     inter_pred_ctxt_t *ps_mc_ctxt;
103 
104     WORD32 (*pai4_mv_cost)[NUM_INTER_PU_PARTS];
105 
106     WORD32 (*pai4_me_err_metric)[NUM_INTER_PU_PARTS];
107 
108     void *pv_src;
109 
110     ihevce_inter_pred_buf_data_t *ps_pred_buf_data;
111 
112     UWORD8 *pu1_ctb_nbr_map;
113 
114     nbr_4x4_t *aps_cu_nbr_buf[2];
115 
116     nbr_4x4_t *ps_left_nbr_4x4;
117 
118     nbr_4x4_t *ps_top_nbr_4x4;
119 
120     nbr_4x4_t *ps_topleft_nbr_4x4;
121 
122     cu_me_intra_pred_prms_t *ps_cu_me_intra_pred_prms;
123 
124     PF_LUMA_INTER_PRED_PU pf_luma_inter_pred_pu;
125 
126     WORD32 i4_ctb_nbr_map_stride;
127 
128     WORD32 i4_src_strd;
129 
130     WORD32 i4_nbr_4x4_left_strd;
131 
132     WORD32 i4_max_num_inter_rdopt_cands;
133 
134     WORD32 i4_lambda_qf;
135 
136     UWORD8 u1_cu_size;
137 
138     UWORD8 u1_cu_pos_x;
139 
140     UWORD8 u1_cu_pos_y;
141 
142     UWORD8 u1_num_me_cands;
143 
144     UWORD8 u1_max_merge_candidates;
145 
146     UWORD8 u1_use_satd_for_merge_eval;
147 
148     UWORD8 u1_quality_preset;
149 
150     WORD8 i1_slice_type;
151 
152     UWORD8 u1_is_hbd;
153 
154     UWORD8 u1_reuse_me_sad;
155 
156     UWORD8 u1_merge_idx_cabac_model;
157 
158     UWORD8 u1_use_merge_cand_from_top_row;
159 
160     UWORD8 u1_is_cu_noisy;
161 
162     WORD32 i4_alpha_stim_multiplier;
163 
164     ihevce_cmn_opt_func_t *ps_cmn_utils_optimised_function_list;
165 
166     FT_SAD_EVALUATOR *pf_evalsad_pt_npu_mxn_8bit;
167 
168 } ihevce_inter_cand_sifter_prms_t;
169 
170 typedef struct
171 {
172     UWORD8 au1_valid_merge_indices[MAX_NUM_MERGE_CAND];
173 
174     merge_cand_list_t *ps_list;
175 
176     inter_pred_ctxt_t *ps_mc_ctxt;
177 
178     mv_pred_ctxt_t *ps_mv_pred_ctxt;
179 
180     PF_LUMA_INTER_PRED_PU pf_luma_inter_pred_pu;
181 
182     PF_SAD_FXN_T pf_sad_fxn;
183 
184     void **ppv_pred_buf_list;
185 
186     UWORD8 *pu1_merge_pred_buf_array;
187 
188     UWORD8 (*pau1_best_pred_buf_id)[MAX_NUM_INTER_PARTS];
189 
190     UWORD8 *pu1_is_top_used;
191 
192     WORD32 (*pai4_noise_term)[MAX_NUM_INTER_PARTS];
193 
194     UWORD32 (*pau4_pred_variance)[MAX_NUM_INTER_PARTS];
195 
196     UWORD32 *pu4_src_variance;
197 
198     WORD32 i4_alpha_stim_multiplier;
199 
200     UWORD8 u1_merge_idx_cabac_model;
201     WORD32 i4_src_stride;
202 
203     WORD32 i4_pred_stride;
204 
205     WORD32 i4_lambda;
206 
207     UWORD8 u1_max_cands;
208 
209     UWORD8 u1_use_merge_cand_from_top_row;
210 
211     UWORD8 u1_is_cu_noisy;
212 
213     UWORD8 u1_is_hbd;
214 
215     ihevce_cmn_opt_func_t *ps_cmn_utils_optimised_function_list;
216 
217 } merge_prms_t;
218 
219 /*****************************************************************************/
220 /* Extern Function Declarations                                              */
221 /*****************************************************************************/
222 
223 void ihevce_inter_cand_sifter(ihevce_inter_cand_sifter_prms_t *ps_ctxt);
224 
225 #endif /* _IHEVCE_ENC_LOOP_INTER_MODE_SIFTER */
226