summaryrefslogtreecommitdiffstats
path: root/encoder/ime_structs.h
blob: 9baacb3cdb63931ac14b99239d4188987c107d39 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
/******************************************************************************
 *
 * Copyright (C) 2015 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at:
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 *****************************************************************************
 * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
*/
/**
 *******************************************************************************
 * @file
 *  ih264e_me.h
 *
 * @brief
 *
 *
 * @author
 *  Ittiam
 *
 * @par List of Functions:
 *  -
 *
 * @remarks
 *  None
 *
 *******************************************************************************
 */

#ifndef _IME_STRUCTS_H_
#define _IME_STRUCTS_H_

/**
 * Motion vector
 */
typedef struct
{
    /**
     * Horizontal Motion Vector
     */
    WORD16 i2_mvx;

    /**
     * Vertical Motion Vector
     */
    WORD16 i2_mvy;
} ime_mv_t;


/**
**************************************************************************
*   @brief   mb_part_ctxt
*
*   Structure that would hold the information for individual MB partitions
*   gathered during the full pel ME stage
**************************************************************************
*/
typedef struct
{
    /**
     * best mvs
     */
    ime_mv_t  s_mv_curr;

    /**
     * mv predictor
     */
    ime_mv_t  s_mv_pred;

    /**
     * SAD associated with the MB partition
     */
    WORD32 i4_mb_distortion;

    /**
     * cost for the MB partition
     */
    WORD32 i4_mb_cost;

    /**
     * Search position for least cost among the list of candidates
     */
    WORD32 i4_srch_pos_idx;

    /**
     * Search position for least cost among the list of candidates
     */
    UWORD32 u4_exit;

    /*
     * Buffer corresponding to best half pel cost
     */
    UWORD8 *pu1_best_hpel_buf;

} mb_part_ctxt;


/**
**************************************************************************
*   @brief   me_ctxt_t
*
*   Structure encapsulating the parameters used in the motion estimation
*   context
**************************************************************************
*/
typedef struct
{
    /**
     * Ref pointer to current MB luma for each ref list
     */
    UWORD8 *apu1_ref_buf_luma[MAX_NUM_REFLIST];

    /**
     * Src pointer to current MB luma
     */
    UWORD8 *pu1_src_buf_luma;

    /**
     * source stride
     * (strides for luma and chroma are the same)
     */
    WORD32 i4_src_strd;

    /**
     * recon stride
     * (strides for luma and chroma are the same)
     */
    WORD32 i4_rec_strd;

    /**
     * Offset for half pel x plane from the pic buf
     */
    UWORD32 u4_half_x_offset;

    /**
     * Offset for half pel y plane from half x plane
     */
    UWORD32 u4_half_y_offset;

    /**
     * Offset for half pel xy plane from half y plane
     */
    UWORD32 u4_half_xy_offset;

    /**
     *  Search range in the X, Y axis in terms of pixels
     */
    WORD32 ai2_srch_boundaries[2];

    /**
     *  Search range in the north direction in terms of pixels
     */
    WORD32 i4_srch_range_n;

    /**
     *  Search range in the south direction in terms of pixels
     */
    WORD32 i4_srch_range_s;

    /**
     *  Search range in the east direction in terms of pixels
     */
    WORD32 i4_srch_range_e;

    /**
     *  Search range in the west direction in terms of pixels
     */
    WORD32 i4_srch_range_w;

    /**
     * left mb motion vector
     */
    ime_mv_t s_left_mv;

    /**
     * top left mb motion vector
     */
    ime_mv_t s_top_left_mv;

    /**
     * Number of valid candidates for the Initial search position
     */
    UWORD32 u4_num_candidates[MAX_NUM_REFLIST + 1];

    /**
     * Motion vector predictors derived from neighboring
     * blocks for each of the six block partitions
     */
    ime_mv_t as_mv_init_search[MAX_NUM_REFLIST + 1][6];

    /**
     * mv bits
     */
    UWORD8 *pu1_mv_bits;

    /**
     * lambda (lagrange multiplier for cost computation)
     */
    UWORD32 u4_lambda_motion;

    /**
     * enabled fast sad computation
     */
    UWORD32 u4_enable_fast_sad;

    /*
     * Enable SKIP block prediction based on SATQD
     */
    UWORD32 u4_enable_stat_sad;

    /*
     * Minimum distortion to search for
     * */
    WORD32 i4_min_sad;

    /*
     * Signal that minimum sad has been reached in ME
     * */
    UWORD32 u4_min_sad_reached;

    /**
     * Flag to enable/disbale half pel motion estimation
     */
    UWORD32 u4_enable_hpel;

    /**
     * Diamond search Iteration Max Cnt
     */
    UWORD32 u4_num_layers;

    /**
     * encoder me speed
     */
    UWORD32 u4_me_speed_preset;

    UWORD32 u4_left_is_intra;

    UWORD32 u4_left_is_skip;

    /* skip_type can be PREDL0, PREDL1 or  BIPRED */
    WORD32 i4_skip_type;

    /* Biasing given for skip prediction */
    WORD32 i4_skip_bias[2];

    /**
     * Structure to store the MB partition info
     * We need 1(L0)+1(L1)+1(bi)
     */
    mb_part_ctxt as_mb_part[MAX_NUM_REFLIST + 1];
    /*
     * Threshold to compare the sad with
     */
    UWORD16 *pu2_sad_thrsh;

    /**
     * fn ptrs for compute sad routines
     */
    ime_compute_sad_ft *pf_ime_compute_sad_16x16[2];
    ime_compute_sad_ft *pf_ime_compute_sad_16x8;
    ime_compute_sad4_diamond *pf_ime_compute_sad4_diamond;
    ime_compute_sad3_diamond *pf_ime_compute_sad3_diamond;
    ime_compute_sad2_diamond *pf_ime_compute_sad2_diamond;
    ime_sub_pel_compute_sad_16x16_ft *pf_ime_sub_pel_compute_sad_16x16;

    /*
     * Function poitners for SATQD
     */
    ime_compute_sad_stat *pf_ime_compute_sad_stat_luma_16x16;

    /**
     * Qp
     */
    UWORD8 u1_mb_qp;

    /*
     * Buffers for holding subpel and bipred temp buffers
     */
    UWORD8 *apu1_subpel_buffs[SUBPEL_BUFF_CNT];

    WORD32 u4_subpel_buf_strd;

    /*
     * Buffers to store the best halfpel plane*
     */
    UWORD8 *pu1_hpel_buf;

} me_ctxt_t;


#endif  // _IME_STRUCTS_H_