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