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.h 24 * 25 * @brief 26 * Contains declarations of global variables for H264 encoder 27 * 28 * @author 29 * Ittiam 30 * 31 * @remarks 32 * 33 ******************************************************************************* 34 */ 35 36 #ifndef IME_H_ 37 #define IME_H_ 38 39 /*****************************************************************************/ 40 /* Constant Macros */ 41 /*****************************************************************************/ 42 43 /** 44 ****************************************************************************** 45 * @brief Number of iterations before exiting during diamond search 46 ****************************************************************************** 47 */ 48 #define NUM_LAYERS 16 49 50 /*****************************************************************************/ 51 /* Extern Function Declarations */ 52 /*****************************************************************************/ 53 54 55 /** 56 ******************************************************************************* 57 * 58 * @brief Diamond Search 59 * 60 * @par Description: 61 * This function computes the sad at vertices of several layers of diamond grid 62 * at a time. The number of layers of diamond grid that would be evaluated is 63 * configurable.The function computes the sad at vertices of a diamond grid. If 64 * the sad at the center of the diamond grid is lesser than the sad at any other 65 * point of the diamond grid, the function marks the candidate Mb partition as 66 * mv. 67 * 68 * @param[in] ps_mb_part 69 * pointer to current mb partition ctxt with respect to ME 70 * 71 * @param[in] ps_me_ctxt 72 * pointer to me context 73 * 74 * @param[in] u4_lambda 75 * lambda motion 76 * 77 * @param[in] u4_fast_flag 78 * enable/disable fast sad computation 79 * 80 * @returns mv pair & corresponding distortion and cost 81 * 82 * @remarks This module cannot be part of the final product due to its lack of 83 * computational feasibility. This is only for quality eval purposes. 84 * 85 ******************************************************************************* 86 */ 87 extern void ime_diamond_search_16x16(me_ctxt_t *ps_me_ctxt, WORD32 i4_reflist); 88 89 90 /** 91 ******************************************************************************* 92 * 93 * @brief This function computes the best motion vector among the tentative mv 94 * candidates chosen. 95 * 96 * @par Description: 97 * This function determines the position in the search window at which the motion 98 * estimation should begin in order to minimise the number of search iterations. 99 * 100 * @param[in] ps_mb_part 101 * pointer to current mb partition ctxt with respect to ME 102 * 103 * @param[in] u4_lambda_motion 104 * lambda motion 105 * 106 * @param[in] u4_fast_flag 107 * enable/disable fast sad computation 108 * 109 * @returns mv pair & corresponding distortion and cost 110 * 111 * @remarks none 112 * 113 ******************************************************************************* 114 */ 115 extern void ime_evaluate_init_srchposn_16x16(me_ctxt_t *ps_me_ctxt, 116 WORD32 i4_reflist); 117 118 /** 119 ******************************************************************************* 120 * 121 * @brief Searches for the best matching full pixel predictor within the search 122 * range 123 * 124 * @par Description: 125 * This function begins by computing the mv predict vector for the current mb. 126 * This is used for cost computations. Further basing on the algo. chosen, it 127 * looks through a set of candidate vectors that best represent the mb a least 128 * cost and returns this information. 129 * 130 * @param[in] ps_proc 131 * pointer to current proc ctxt 132 * 133 * @param[in] ps_me_ctxt 134 * pointer to me context 135 * 136 * @returns mv pair & corresponding distortion and cost 137 * 138 * @remarks none 139 * 140 ******************************************************************************* 141 */ 142 extern void ime_full_pel_motion_estimation_16x16(me_ctxt_t *ps_me_ctxt, 143 WORD32 i4_ref_list); 144 145 /** 146 ******************************************************************************* 147 * 148 * @brief Searches for the best matching sub pixel predictor within the search 149 * range 150 * 151 * @par Description: 152 * This function begins by searching across all sub pixel sample points 153 * around the full pel motion vector. The vector with least cost is chosen as 154 * the mv for the current mb. If the skip mode is not evaluated while analysing 155 * the initial search candidates then analyse it here and update the mv. 156 * 157 * @param[in] ps_proc 158 * pointer to current proc ctxt 159 * 160 * @param[in] ps_me_ctxt 161 * pointer to me context 162 * 163 * @returns none 164 * 165 * @remarks none 166 * 167 ******************************************************************************* 168 */ 169 extern void ime_sub_pel_motion_estimation_16x16(me_ctxt_t *ps_me_ctxt, 170 WORD32 i4_reflist); 171 172 /** 173 ******************************************************************************* 174 * 175 * @brief This function computes cost of skip macroblocks 176 * 177 * @par Description: 178 * 179 * @param[in] ps_me_ctxt 180 * pointer to me ctxt 181 * 182 * @param[in] ps_skip_mv 183 * pointer to skip mv 184 * 185 @param[in] is_slice_type_b 186 * Whether slice type is BSLICE or not 187 188 * @returns none 189 * 190 * @remarks 191 * NOTE: while computing the skip cost, do not enable early exit from compute 192 * sad function because, a negative bias gets added later 193 * 194 ******************************************************************************* 195 */ 196 extern void ime_compute_skip_cost(me_ctxt_t *ps_me_ctxt, 197 ime_mv_t *ps_skip_mv, 198 mb_part_ctxt *ps_smb_part_info, 199 UWORD32 u4_use_stat_sad, 200 WORD32 i4_reflist, 201 WORD32 is_slice_type_b); 202 203 204 #endif /* IME_H_ */ 205