• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2  *
3  * Copyright (C) 2015 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
23  *  ih264e_me.h
24  *
25  * @brief
26  *
27  *
28  * @author
29  *  Ittiam
30  *
31  * @par List of Functions:
32  *  -
33  *
34  * @remarks
35  *  None
36  *
37  *******************************************************************************
38  */
39 
40 #ifndef _IME_STRUCTS_H_
41 #define _IME_STRUCTS_H_
42 
43 /**
44  * Motion vector
45  */
46 typedef struct
47 {
48     /**
49      * Horizontal Motion Vector
50      */
51     WORD16 i2_mvx;
52 
53     /**
54      * Vertical Motion Vector
55      */
56     WORD16 i2_mvy;
57 } ime_mv_t;
58 
59 
60 /**
61 **************************************************************************
62 *   @brief   mb_part_ctxt
63 *
64 *   Structure that would hold the information for individual MB partitions
65 *   gathered during the full pel ME stage
66 **************************************************************************
67 */
68 typedef struct
69 {
70     /**
71      * best mvs
72      */
73     ime_mv_t  s_mv_curr;
74 
75     /**
76      * mv predictor
77      */
78     ime_mv_t  s_mv_pred;
79 
80     /**
81      * SAD associated with the MB partition
82      */
83     WORD32 i4_mb_distortion;
84 
85     /**
86      * cost for the MB partition
87      */
88     WORD32 i4_mb_cost;
89 
90     /**
91      * Search position for least cost among the list of candidates
92      */
93     WORD32 i4_srch_pos_idx;
94 
95     /**
96      * Search position for least cost among the list of candidates
97      */
98     UWORD32 u4_exit;
99 
100     /*
101      * Buffer corresponding to best half pel cost
102      */
103     UWORD8 *pu1_best_hpel_buf;
104 
105 } mb_part_ctxt;
106 
107 
108 /**
109 **************************************************************************
110 *   @brief   me_ctxt_t
111 *
112 *   Structure encapsulating the parameters used in the motion estimation
113 *   context
114 **************************************************************************
115 */
116 typedef struct
117 {
118     /**
119      * Ref pointer to current MB luma for each ref list
120      */
121     UWORD8 *apu1_ref_buf_luma[MAX_NUM_REFLIST];
122 
123     /**
124      * Src pointer to current MB luma
125      */
126     UWORD8 *pu1_src_buf_luma;
127 
128     /**
129      * source stride
130      * (strides for luma and chroma are the same)
131      */
132     WORD32 i4_src_strd;
133 
134     /**
135      * recon stride
136      * (strides for luma and chroma are the same)
137      */
138     WORD32 i4_rec_strd;
139 
140     /**
141      * Offset for half pel x plane from the pic buf
142      */
143     UWORD32 u4_half_x_offset;
144 
145     /**
146      * Offset for half pel y plane from half x plane
147      */
148     UWORD32 u4_half_y_offset;
149 
150     /**
151      * Offset for half pel xy plane from half y plane
152      */
153     UWORD32 u4_half_xy_offset;
154 
155     /**
156      *  Search range in the X, Y axis in terms of pixels
157      */
158     WORD32 ai2_srch_boundaries[2];
159 
160     /**
161      *  Search range in the north direction in terms of pixels
162      */
163     WORD32 i4_srch_range_n;
164 
165     /**
166      *  Search range in the south direction in terms of pixels
167      */
168     WORD32 i4_srch_range_s;
169 
170     /**
171      *  Search range in the east direction in terms of pixels
172      */
173     WORD32 i4_srch_range_e;
174 
175     /**
176      *  Search range in the west direction in terms of pixels
177      */
178     WORD32 i4_srch_range_w;
179 
180     /**
181      * left mb motion vector
182      */
183     ime_mv_t s_left_mv;
184 
185     /**
186      * top left mb motion vector
187      */
188     ime_mv_t s_top_left_mv;
189 
190     /**
191      * Number of valid candidates for the Initial search position
192      */
193     UWORD32 u4_num_candidates[MAX_NUM_REFLIST + 1];
194 
195     /**
196      * Motion vector predictors derived from neighboring
197      * blocks for each of the six block partitions
198      */
199     ime_mv_t as_mv_init_search[MAX_NUM_REFLIST + 1][6];
200 
201     /**
202      * mv bits
203      */
204     UWORD8 *pu1_mv_bits;
205 
206     /**
207      * lambda (lagrange multiplier for cost computation)
208      */
209     UWORD32 u4_lambda_motion;
210 
211     /**
212      * enabled fast sad computation
213      */
214     UWORD32 u4_enable_fast_sad;
215 
216     /*
217      * Enable SKIP block prediction based on SATQD
218      */
219     UWORD32 u4_enable_stat_sad;
220 
221     /*
222      * Minimum distortion to search for
223      * */
224     WORD32 i4_min_sad;
225 
226     /*
227      * Signal that minimum sad has been reached in ME
228      * */
229     UWORD32 u4_min_sad_reached;
230 
231     /**
232      * Flag to enable/disbale half pel motion estimation
233      */
234     UWORD32 u4_enable_hpel;
235 
236     /**
237      * Diamond search Iteration Max Cnt
238      */
239     UWORD32 u4_num_layers;
240 
241     /**
242      * encoder me speed
243      */
244     UWORD32 u4_me_speed_preset;
245 
246     UWORD32 u4_left_is_intra;
247 
248     UWORD32 u4_left_is_skip;
249 
250     /* skip_type can be PREDL0, PREDL1 or  BIPRED */
251     WORD32 i4_skip_type;
252 
253     /* Biasing given for skip prediction */
254     WORD32 i4_skip_bias[2];
255 
256     /**
257      * Structure to store the MB partition info
258      * We need 1(L0)+1(L1)+1(bi)
259      */
260     mb_part_ctxt as_mb_part[MAX_NUM_REFLIST + 1];
261     /*
262      * Threshold to compare the sad with
263      */
264     UWORD16 *pu2_sad_thrsh;
265 
266     /**
267      * fn ptrs for compute sad routines
268      */
269     ime_compute_sad_ft *pf_ime_compute_sad_16x16[2];
270     ime_compute_sad_ft *pf_ime_compute_sad_16x8;
271     ime_compute_sad4_diamond *pf_ime_compute_sad4_diamond;
272     ime_compute_sad3_diamond *pf_ime_compute_sad3_diamond;
273     ime_compute_sad2_diamond *pf_ime_compute_sad2_diamond;
274     ime_sub_pel_compute_sad_16x16_ft *pf_ime_sub_pel_compute_sad_16x16;
275 
276     /*
277      * Function poitners for SATQD
278      */
279     ime_compute_sad_stat *pf_ime_compute_sad_stat_luma_16x16;
280 
281     /**
282      * Qp
283      */
284     UWORD8 u1_mb_qp;
285 
286     /*
287      * Buffers for holding subpel and bipred temp buffers
288      */
289     UWORD8 *apu1_subpel_buffs[SUBPEL_BUFF_CNT];
290 
291     WORD32 u4_subpel_buf_strd;
292 
293     /*
294      * Buffers to store the best halfpel plane*
295      */
296     UWORD8 *pu1_hpel_buf;
297 
298 } me_ctxt_t;
299 
300 
301 #endif  // _IME_STRUCTS_H_
302 
303