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 ******************************************************************************* 23 * @file 24 * ih264e_function_selector_generic.c 25 * 26 * @brief 27 * Contains functions to initialize function pointers of codec context 28 * 29 * @author 30 * ittiam 31 * 32 * @par List of Functions: 33 * - ih264e_init_function_ptr_generic 34 * 35 * @remarks 36 * None 37 * 38 ******************************************************************************* 39 */ 40 41 42 /*****************************************************************************/ 43 /* File Includes */ 44 /*****************************************************************************/ 45 46 47 /* System Include files */ 48 #include <stdio.h> 49 #include <stddef.h> 50 #include <stdlib.h> 51 #include <string.h> 52 53 /* User Include files */ 54 #include "ih264_typedefs.h" 55 #include "iv2.h" 56 #include "ive2.h" 57 #include "ih264_defs.h" 58 #include "ih264_size_defs.h" 59 #include "ih264e_defs.h" 60 #include "ih264e_error.h" 61 #include "ih264e_bitstream.h" 62 #include "ime_distortion_metrics.h" 63 #include "ime_defs.h" 64 #include "ime_structs.h" 65 #include "ih264_error.h" 66 #include "ih264_structs.h" 67 #include "ih264_trans_quant_itrans_iquant.h" 68 #include "ih264_inter_pred_filters.h" 69 #include "ih264_mem_fns.h" 70 #include "ih264_padding.h" 71 #include "ih264_intra_pred_filters.h" 72 #include "ih264_deblk_edge_filters.h" 73 #include "ih264_cabac_tables.h" 74 #include "irc_cntrl_param.h" 75 #include "irc_frame_info_collector.h" 76 #include "ih264e_rate_control.h" 77 #include "ih264e_cabac_structs.h" 78 #include "ih264e_structs.h" 79 #include "ih264e_platform_macros.h" 80 #include "ih264e_cabac.h" 81 #include "ih264e_core_coding.h" 82 #include "ih264_cavlc_tables.h" 83 #include "ih264e_cavlc.h" 84 #include "ih264e_intra_modes_eval.h" 85 #include "ih264e_fmt_conv.h" 86 #include "ih264e_half_pel.h" 87 #include "ih264e_me.h" 88 89 90 /*****************************************************************************/ 91 /* Function Definitions */ 92 /*****************************************************************************/ 93 94 /** 95 ******************************************************************************* 96 * 97 * @brief Initialize the intra/inter/transform/deblk function pointers of 98 * codec context 99 * 100 * @par Description: the current routine initializes the function pointers of 101 * codec context basing on the architecture in use 102 * 103 * @param[in] ps_codec 104 * Codec context pointer 105 * 106 * @returns none 107 * 108 * @remarks none 109 * 110 ******************************************************************************* 111 */ ih264e_init_function_ptr_generic(codec_t * ps_codec)112void ih264e_init_function_ptr_generic(codec_t *ps_codec) 113 { 114 WORD32 i = 0; 115 116 /* curr proc ctxt */ 117 process_ctxt_t *ps_proc = NULL; 118 me_ctxt_t *ps_me_ctxt = NULL; 119 120 /* Init function pointers for intra pred leaf level functions luma 121 * Intra 16x16 */ 122 ps_codec->apf_intra_pred_16_l[0] = ih264_intra_pred_luma_16x16_mode_vert; 123 ps_codec->apf_intra_pred_16_l[1] = ih264_intra_pred_luma_16x16_mode_horz; 124 ps_codec->apf_intra_pred_16_l[2] = ih264_intra_pred_luma_16x16_mode_dc; 125 ps_codec->apf_intra_pred_16_l[3] = ih264_intra_pred_luma_16x16_mode_plane; 126 127 /* Init function pointers for intra pred leaf level functions luma 128 * Intra 4x4 */ 129 ps_codec->apf_intra_pred_4_l[0] = ih264_intra_pred_luma_4x4_mode_vert; 130 ps_codec->apf_intra_pred_4_l[1] = ih264_intra_pred_luma_4x4_mode_horz; 131 ps_codec->apf_intra_pred_4_l[2] = ih264_intra_pred_luma_4x4_mode_dc; 132 ps_codec->apf_intra_pred_4_l[3] = ih264_intra_pred_luma_4x4_mode_diag_dl; 133 ps_codec->apf_intra_pred_4_l[4] = ih264_intra_pred_luma_4x4_mode_diag_dr; 134 ps_codec->apf_intra_pred_4_l[5] = ih264_intra_pred_luma_4x4_mode_vert_r; 135 ps_codec->apf_intra_pred_4_l[6] = ih264_intra_pred_luma_4x4_mode_horz_d; 136 ps_codec->apf_intra_pred_4_l[7] = ih264_intra_pred_luma_4x4_mode_vert_l; 137 ps_codec->apf_intra_pred_4_l[8] = ih264_intra_pred_luma_4x4_mode_horz_u; 138 139 /* Init function pointers for intra pred leaf level functions luma 140 * Intra 8x8 */ 141 ps_codec->apf_intra_pred_8_l[0] = ih264_intra_pred_luma_8x8_mode_vert; 142 ps_codec->apf_intra_pred_8_l[2] = ih264_intra_pred_luma_8x8_mode_dc; 143 ps_codec->apf_intra_pred_8_l[3] = ih264_intra_pred_luma_8x8_mode_diag_dl; 144 ps_codec->apf_intra_pred_8_l[4] = ih264_intra_pred_luma_8x8_mode_diag_dr; 145 ps_codec->apf_intra_pred_8_l[5] = ih264_intra_pred_luma_8x8_mode_vert_r; 146 ps_codec->apf_intra_pred_8_l[6] = ih264_intra_pred_luma_8x8_mode_horz_d; 147 ps_codec->apf_intra_pred_8_l[7] = ih264_intra_pred_luma_8x8_mode_vert_l; 148 ps_codec->apf_intra_pred_8_l[8] = ih264_intra_pred_luma_8x8_mode_horz_u; 149 150 /* Init function pointers for intra pred leaf level functions chroma 151 * Intra 8x8 */ 152 ps_codec->apf_intra_pred_c[0] = ih264_intra_pred_chroma_8x8_mode_dc; 153 ps_codec->apf_intra_pred_c[1] = ih264_intra_pred_chroma_8x8_mode_horz; 154 ps_codec->apf_intra_pred_c[2] = ih264_intra_pred_chroma_8x8_mode_vert; 155 ps_codec->apf_intra_pred_c[3] = ih264_intra_pred_chroma_8x8_mode_plane; 156 157 /* Init luma forward transform fn ptr */ 158 ps_codec->pf_resi_trans_quant_8x8 = ih264_resi_trans_quant_8x8; 159 ps_codec->pf_resi_trans_quant_4x4 = ih264_resi_trans_quant_4x4; 160 ps_codec->pf_resi_trans_quant_chroma_4x4 = ih264_resi_trans_quant_chroma_4x4; 161 ps_codec->pf_hadamard_quant_4x4 = ih264_hadamard_quant_4x4; 162 ps_codec->pf_hadamard_quant_2x2_uv = ih264_hadamard_quant_2x2_uv; 163 164 /* Init inverse transform fn ptr */ 165 ps_codec->pf_iquant_itrans_recon_8x8 = ih264_iquant_itrans_recon_8x8; 166 ps_codec->pf_iquant_itrans_recon_4x4 = ih264_iquant_itrans_recon_4x4; 167 ps_codec->pf_iquant_itrans_recon_4x4_dc = ih264_iquant_itrans_recon_4x4_dc; 168 ps_codec->pf_iquant_itrans_recon_chroma_4x4 = ih264_iquant_itrans_recon_chroma_4x4; 169 ps_codec->pf_iquant_itrans_recon_chroma_4x4_dc = ih264_iquant_itrans_recon_chroma_4x4_dc; 170 171 ps_codec->pf_ihadamard_scaling_4x4 = ih264_ihadamard_scaling_4x4; 172 ps_codec->pf_ihadamard_scaling_2x2_uv = ih264_ihadamard_scaling_2x2_uv; 173 ps_codec->pf_interleave_copy = ih264_interleave_copy; 174 175 /* Init fn ptr luma core coding */ 176 ps_codec->luma_energy_compaction[0] = ih264e_code_luma_intra_macroblock_16x16; 177 ps_codec->luma_energy_compaction[1] = ih264e_code_luma_intra_macroblock_4x4; 178 ps_codec->luma_energy_compaction[3] = ih264e_code_luma_inter_macroblock_16x16; 179 180 /* Init fn ptr chroma core coding */ 181 ps_codec->chroma_energy_compaction[0] = ih264e_code_chroma_intra_macroblock_8x8; 182 ps_codec->chroma_energy_compaction[1] = ih264e_code_chroma_inter_macroblock_8x8; 183 184 /* Init fn ptr luma deblocking */ 185 ps_codec->pf_deblk_luma_vert_bs4 = ih264_deblk_luma_vert_bs4; 186 ps_codec->pf_deblk_luma_vert_bslt4 = ih264_deblk_luma_vert_bslt4; 187 ps_codec->pf_deblk_luma_horz_bs4 = ih264_deblk_luma_horz_bs4; 188 ps_codec->pf_deblk_luma_horz_bslt4 = ih264_deblk_luma_horz_bslt4; 189 190 /* Init fn ptr chroma deblocking */ 191 ps_codec->pf_deblk_chroma_vert_bs4 = ih264_deblk_chroma_vert_bs4; 192 ps_codec->pf_deblk_chroma_vert_bslt4 = ih264_deblk_chroma_vert_bslt4; 193 ps_codec->pf_deblk_chroma_horz_bs4 = ih264_deblk_chroma_horz_bs4; 194 ps_codec->pf_deblk_chroma_horz_bslt4 = ih264_deblk_chroma_horz_bslt4; 195 196 /* write mb syntax layer */ 197 ps_codec->pf_write_mb_syntax_layer[CAVLC][ISLICE] = ih264e_write_islice_mb_cavlc; 198 ps_codec->pf_write_mb_syntax_layer[CAVLC][PSLICE] = ih264e_write_pslice_mb_cavlc; 199 ps_codec->pf_write_mb_syntax_layer[CAVLC][BSLICE] = ih264e_write_bslice_mb_cavlc; 200 ps_codec->pf_write_mb_syntax_layer[CABAC][ISLICE] = ih264e_write_islice_mb_cabac; 201 ps_codec->pf_write_mb_syntax_layer[CABAC][PSLICE] = ih264e_write_pslice_mb_cabac; 202 ps_codec->pf_write_mb_syntax_layer[CABAC][BSLICE] = ih264e_write_bslice_mb_cabac; 203 204 /* Padding Functions */ 205 ps_codec->pf_pad_top = ih264_pad_top; 206 ps_codec->pf_pad_bottom = ih264_pad_bottom; 207 ps_codec->pf_pad_left_luma = ih264_pad_left_luma; 208 ps_codec->pf_pad_left_chroma = ih264_pad_left_chroma; 209 ps_codec->pf_pad_right_luma = ih264_pad_right_luma; 210 ps_codec->pf_pad_right_chroma = ih264_pad_right_chroma; 211 212 /* Inter pred leaf level functions */ 213 ps_codec->pf_inter_pred_luma_copy = ih264_inter_pred_luma_copy; 214 ps_codec->pf_inter_pred_luma_horz = ih264_inter_pred_luma_horz; 215 ps_codec->pf_inter_pred_luma_vert = ih264_inter_pred_luma_vert; 216 ps_codec->pf_inter_pred_luma_bilinear = ih264_inter_pred_luma_bilinear; 217 ps_codec->pf_inter_pred_chroma = ih264_inter_pred_chroma; 218 219 /* sad me level functions */ 220 ps_codec->apf_compute_sad_16x16[0] = ime_compute_sad_16x16; 221 ps_codec->apf_compute_sad_16x16[1] = ime_compute_sad_16x16_fast; 222 ps_codec->pf_compute_sad_16x8 = ime_compute_sad_16x8; 223 224 /* memory handling operations */ 225 ps_codec->pf_mem_cpy = ih264_memcpy; 226 ps_codec->pf_mem_cpy_mul8 = ih264_memcpy_mul_8; 227 ps_codec->pf_mem_set = ih264_memset; 228 ps_codec->pf_mem_set_mul8 = ih264_memset_mul_8; 229 230 /* sad me level functions */ 231 for (i = 0; i < (MAX_PROCESS_CTXT); i++) 232 { 233 ps_proc = &ps_codec->as_process[i]; 234 235 ps_me_ctxt = &ps_proc->s_me_ctxt; 236 ps_me_ctxt->pf_ime_compute_sad_16x16[0] = ime_compute_sad_16x16; 237 ps_me_ctxt->pf_ime_compute_sad_16x16[1] = ime_compute_sad_16x16_fast; 238 ps_me_ctxt->pf_ime_compute_sad_16x8 = ime_compute_sad_16x8; 239 ps_me_ctxt->pf_ime_compute_sad4_diamond = ime_calculate_sad4_prog; 240 ps_me_ctxt->pf_ime_compute_sad3_diamond = ime_calculate_sad3_prog; 241 ps_me_ctxt->pf_ime_compute_sad2_diamond = ime_calculate_sad2_prog; 242 ps_me_ctxt->pf_ime_sub_pel_compute_sad_16x16 = ime_sub_pel_compute_sad_16x16; 243 ps_me_ctxt->pf_ime_compute_sad_stat_luma_16x16 = ime_compute_satqd_16x16_lumainter; 244 } 245 246 /* intra mode eval -encoder level function */ 247 ps_codec->pf_ih264e_evaluate_intra16x16_modes = ih264e_evaluate_intra16x16_modes; 248 ps_codec->pf_ih264e_evaluate_intra_chroma_modes = ih264e_evaluate_intra_chroma_modes; 249 ps_codec->pf_ih264e_evaluate_intra_4x4_modes = ih264e_evaluate_intra_4x4_modes; 250 251 /* csc */ 252 ps_codec->pf_ih264e_conv_420p_to_420sp = ih264e_fmt_conv_420p_to_420sp; 253 ps_codec->pf_ih264e_fmt_conv_422i_to_420sp = ih264e_fmt_conv_422i_to_420sp; 254 255 /* Halp pel generation function - encoder level*/ 256 ps_codec->pf_ih264e_sixtapfilter_horz = ih264e_sixtapfilter_horz; 257 ps_codec->pf_ih264e_sixtap_filter_2dvh_vert = ih264e_sixtap_filter_2dvh_vert; 258 259 /* ME compute */ 260 ps_codec->apf_compute_me[PSLICE] = &ih264e_compute_me_single_reflist; 261 ps_codec->apf_compute_me[BSLICE] = &ih264e_compute_me_multi_reflist; 262 263 /* skip decision */ 264 ps_codec->apf_find_skip_params_me[PSLICE] = &ih264e_find_pskip_params_me; 265 ps_codec->apf_find_skip_params_me[BSLICE] = &ih264e_find_bskip_params_me; 266 267 268 return; 269 } 270