1 /****************************************************************************** 2 * 3 * Copyright (C) 2022 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 * isvce_function_selector_av8.c 24 * 25 * @brief 26 * Contains functions to initialize function pointers of codec context 27 * 28 * @author 29 * Ittiam 30 * 31 * @par List of Functions: 32 * - isvce_init_function_ptr_generic 33 * 34 * @remarks 35 * None 36 * 37 ******************************************************************************* 38 */ 39 40 /*****************************************************************************/ 41 /* File Includes */ 42 /*****************************************************************************/ 43 44 /* System Include files */ 45 #include <stdio.h> 46 #include <stddef.h> 47 #include <stdlib.h> 48 #include <string.h> 49 50 /* User Include files */ 51 #include "ih264_typedefs.h" 52 #include "iv2.h" 53 #include "ive2.h" 54 #include "isvc_defs.h" 55 #include "ih264_size_defs.h" 56 #include "isvce_defs.h" 57 #include "ih264e_error.h" 58 #include "ih264e_bitstream.h" 59 #include "ime_distortion_metrics.h" 60 #include "ime_defs.h" 61 #include "ime_structs.h" 62 #include "ih264_error.h" 63 #include "isvc_structs.h" 64 #include "isvc_trans_quant_itrans_iquant.h" 65 #include "ih264_inter_pred_filters.h" 66 #include "ih264_mem_fns.h" 67 #include "isvc_mem_fns.h" 68 #include "ih264_padding.h" 69 #include "ih264_intra_pred_filters.h" 70 #include "ih264_deblk_edge_filters.h" 71 #include "isvc_cabac_tables.h" 72 #include "irc_cntrl_param.h" 73 #include "irc_frame_info_collector.h" 74 #include "isvce_rate_control.h" 75 #include "isvce_cabac_structs.h" 76 #include "isvce_structs.h" 77 #include "ih264e_platform_macros.h" 78 #include "isvce_cabac.h" 79 #include "isvce_core_coding.h" 80 #include "ih264_cavlc_tables.h" 81 #include "isvce_cavlc.h" 82 #include "ih264e_intra_modes_eval.h" 83 #include "ih264e_fmt_conv.h" 84 #include "ih264e_half_pel.h" 85 86 /** 87 ******************************************************************************* 88 * 89 * @brief Initialize the intra/inter/transform/deblk function pointers of 90 * codec context 91 * 92 * @par Description: the current routine initializes the function pointers of 93 * codec context basing on the architecture in use 94 * 95 * @param[in] ps_codec 96 * Codec context pointer 97 * 98 * @returns none 99 * 100 * @remarks none 101 * 102 ******************************************************************************* 103 */ isvce_init_function_ptr_neon_av8(isvce_codec_t * ps_codec)104void isvce_init_function_ptr_neon_av8(isvce_codec_t *ps_codec) 105 { 106 WORD32 i = 0; 107 108 /* curr proc ctxt */ 109 isvce_process_ctxt_t *ps_proc = NULL; 110 isvce_me_ctxt_t *ps_me_ctxt = NULL; 111 isa_dependent_fxns_t *ps_isa_dependent_fxns = &ps_codec->s_isa_dependent_fxns; 112 enc_loop_fxns_t *ps_enc_loop_fxns = &ps_isa_dependent_fxns->s_enc_loop_fxns; 113 inter_pred_fxns_t *ps_inter_pred_fxns = &ps_isa_dependent_fxns->s_inter_pred_fxns; 114 mem_fxns_t *ps_mem_fxns = &ps_isa_dependent_fxns->s_mem_fxns; 115 116 /* Init function pointers for intra pred leaf level functions luma 117 * Intra 16x16 */ 118 ps_codec->apf_intra_pred_16_l[0] = ih264_intra_pred_luma_16x16_mode_vert_av8; 119 ps_codec->apf_intra_pred_16_l[1] = ih264_intra_pred_luma_16x16_mode_horz_av8; 120 ps_codec->apf_intra_pred_16_l[2] = ih264_intra_pred_luma_16x16_mode_dc_av8; 121 ps_codec->apf_intra_pred_16_l[3] = ih264_intra_pred_luma_16x16_mode_plane_av8; 122 123 /* Init function pointers for intra pred leaf level functions luma 124 * Intra 4x4 */ 125 ps_codec->apf_intra_pred_4_l[0] = ih264_intra_pred_luma_4x4_mode_vert_av8; 126 ps_codec->apf_intra_pred_4_l[1] = ih264_intra_pred_luma_4x4_mode_horz_av8; 127 ps_codec->apf_intra_pred_4_l[2] = ih264_intra_pred_luma_4x4_mode_dc_av8; 128 ps_codec->apf_intra_pred_4_l[3] = ih264_intra_pred_luma_4x4_mode_diag_dl_av8; 129 ps_codec->apf_intra_pred_4_l[4] = ih264_intra_pred_luma_4x4_mode_diag_dr_av8; 130 ps_codec->apf_intra_pred_4_l[5] = ih264_intra_pred_luma_4x4_mode_vert_r_av8; 131 ps_codec->apf_intra_pred_4_l[6] = ih264_intra_pred_luma_4x4_mode_horz_d_av8; 132 ps_codec->apf_intra_pred_4_l[7] = ih264_intra_pred_luma_4x4_mode_vert_l_av8; 133 ps_codec->apf_intra_pred_4_l[8] = ih264_intra_pred_luma_4x4_mode_horz_u_av8; 134 135 /* Init function pointers for intra pred leaf level functions luma 136 * Intra 8x8 */ 137 ps_codec->apf_intra_pred_8_l[0] = ih264_intra_pred_luma_8x8_mode_vert_av8; 138 ps_codec->apf_intra_pred_8_l[2] = ih264_intra_pred_luma_8x8_mode_dc_av8; 139 ps_codec->apf_intra_pred_8_l[3] = ih264_intra_pred_luma_8x8_mode_diag_dl_av8; 140 ps_codec->apf_intra_pred_8_l[4] = ih264_intra_pred_luma_8x8_mode_diag_dr_av8; 141 ps_codec->apf_intra_pred_8_l[5] = ih264_intra_pred_luma_8x8_mode_vert_r_av8; 142 ps_codec->apf_intra_pred_8_l[6] = ih264_intra_pred_luma_8x8_mode_horz_d_av8; 143 ps_codec->apf_intra_pred_8_l[7] = ih264_intra_pred_luma_8x8_mode_vert_l_av8; 144 ps_codec->apf_intra_pred_8_l[8] = ih264_intra_pred_luma_8x8_mode_horz_u_av8; 145 146 /* Init function pointers for intra pred leaf level functions chroma 147 * Intra 8x8 */ 148 ps_codec->apf_intra_pred_c[0] = ih264_intra_pred_chroma_8x8_mode_dc_av8; 149 ps_codec->apf_intra_pred_c[1] = ih264_intra_pred_chroma_8x8_mode_horz_av8; 150 ps_codec->apf_intra_pred_c[2] = ih264_intra_pred_chroma_8x8_mode_vert_av8; 151 ps_codec->apf_intra_pred_c[3] = ih264_intra_pred_chroma_8x8_mode_plane_av8; 152 153 /* Init forward transform fn ptr */ 154 ps_enc_loop_fxns->apf_resi_trans_quant_8x8[0] = isvc_resi_trans_quant_8x8; 155 ps_enc_loop_fxns->apf_resi_trans_quant_8x8[1] = isvc_resi_trans_quant_8x8; 156 ps_enc_loop_fxns->apf_resi_trans_quant_4x4[0] = isvc_resi_trans_quant_4x4_neon; 157 ps_enc_loop_fxns->apf_resi_trans_quant_4x4[1] = 158 isvc_resi_trans_quant_4x4_with_residual_sub_neon; 159 ps_enc_loop_fxns->apf_resi_trans_quant_chroma_4x4[0] = isvc_resi_trans_quant_chroma_4x4_neon; 160 ps_enc_loop_fxns->apf_resi_trans_quant_chroma_4x4[1] = 161 isvc_resi_trans_quant_chroma_4x4_with_residual_sub_neon; 162 163 /* Init inverse transform fn ptr */ 164 ps_enc_loop_fxns->apf_iquant_itrans_recon_4x4[0] = 165 isvc_iquant_itrans_recon_4x4_with_res_output_neon; 166 ps_enc_loop_fxns->apf_iquant_itrans_recon_4x4[1] = 167 isvc_iquant_itrans_recon_4x4_with_res_accumulate_neon; 168 ps_enc_loop_fxns->apf_iquant_itrans_recon_4x4[2] = isvc_iquant_itrans_recon_4x4_neon; 169 ; 170 ps_enc_loop_fxns->apf_iquant_itrans_recon_4x4_dc[2] = isvc_iquant_itrans_recon_4x4_dc_neon; 171 172 ps_enc_loop_fxns->apf_iquant_itrans_recon_chroma_4x4[0] = 173 isvc_iquant_itrans_recon_chroma_4x4_with_res_output_neon; 174 ps_enc_loop_fxns->apf_iquant_itrans_recon_chroma_4x4[1] = 175 isvc_iquant_itrans_recon_chroma_4x4_with_res_accumulate_neon; 176 177 ps_enc_loop_fxns->apf_iquant_itrans_recon_chroma_4x4_dc[0] = 178 isvc_iquant_itrans_recon_chroma_4x4_dc_with_res_output_neon; 179 ps_enc_loop_fxns->apf_iquant_itrans_recon_chroma_4x4_dc[1] = 180 isvc_iquant_itrans_recon_chroma_4x4_dc_with_res_accumulate_neon; 181 182 ps_enc_loop_fxns->pf_ihadamard_scaling_4x4 = ih264_ihadamard_scaling_4x4_av8; 183 ps_enc_loop_fxns->pf_ihadamard_scaling_2x2_uv = ih264_ihadamard_scaling_2x2_uv_av8; 184 185 /* Init fn ptr luma core coding */ 186 ps_enc_loop_fxns->apf_luma_energy_compaction[0] = isvce_code_luma_intra_macroblock_16x16; 187 ps_enc_loop_fxns->apf_luma_energy_compaction[1] = isvce_code_luma_intra_macroblock_4x4; 188 ps_enc_loop_fxns->apf_luma_energy_compaction[3] = isvce_code_luma_inter_macroblock_16x16; 189 190 /* Init fn ptr chroma core coding */ 191 ps_enc_loop_fxns->apf_chroma_energy_compaction[0] = isvce_code_chroma_intra_macroblock_8x8; 192 ps_enc_loop_fxns->apf_chroma_energy_compaction[1] = isvce_code_chroma_inter_macroblock_8x8; 193 194 /* Init fn ptr luma deblocking */ 195 ps_codec->pf_deblk_luma_vert_bs4 = ih264_deblk_luma_vert_bs4_av8; 196 ps_codec->pf_deblk_luma_vert_bslt4 = ih264_deblk_luma_vert_bslt4_av8; 197 ps_codec->pf_deblk_luma_horz_bs4 = ih264_deblk_luma_horz_bs4_av8; 198 ps_codec->pf_deblk_luma_horz_bslt4 = ih264_deblk_luma_horz_bslt4_av8; 199 200 /* Init fn ptr chroma deblocking */ 201 ps_codec->pf_deblk_chroma_vert_bs4 = ih264_deblk_chroma_vert_bs4_av8; 202 ps_codec->pf_deblk_chroma_vert_bslt4 = ih264_deblk_chroma_vert_bslt4_av8; 203 ps_codec->pf_deblk_chroma_horz_bs4 = ih264_deblk_chroma_horz_bs4_av8; 204 ps_codec->pf_deblk_chroma_horz_bslt4 = ih264_deblk_chroma_horz_bslt4_av8; 205 206 /* write mb syntax layer */ 207 ps_codec->pf_write_mb_syntax_layer[CAVLC][ISLICE] = isvce_write_islice_mb_cavlc; 208 ps_codec->pf_write_mb_syntax_layer[CAVLC][PSLICE] = isvce_write_pslice_mb_cavlc; 209 ps_codec->pf_write_mb_syntax_layer[CAVLC][BSLICE] = isvce_write_bslice_mb_cavlc; 210 ps_codec->pf_write_mb_syntax_layer[CABAC][ISLICE] = isvce_write_islice_mb_cabac; 211 ps_codec->pf_write_mb_syntax_layer[CABAC][PSLICE] = isvce_write_pslice_mb_cabac; 212 213 /* Padding Functions */ 214 ps_codec->pf_pad_top = ih264_pad_top_av8; 215 ps_codec->pf_pad_bottom = ih264_pad_bottom; 216 ps_codec->pf_pad_left_luma = ih264_pad_left_luma_av8; 217 ps_codec->pf_pad_left_chroma = ih264_pad_left_chroma_av8; 218 ps_codec->pf_pad_right_luma = ih264_pad_right_luma_av8; 219 ps_codec->pf_pad_right_chroma = ih264_pad_right_chroma_av8; 220 221 /* Inter pred leaf level functions */ 222 ps_inter_pred_fxns->pf_inter_pred_luma_copy = ih264_inter_pred_luma_copy_av8; 223 ps_inter_pred_fxns->pf_inter_pred_luma_horz = ih264_inter_pred_luma_horz_av8; 224 ps_inter_pred_fxns->pf_inter_pred_luma_vert = ih264_inter_pred_luma_vert_av8; 225 ps_inter_pred_fxns->pf_inter_pred_luma_bilinear = ih264_inter_pred_luma_bilinear; 226 ps_inter_pred_fxns->pf_inter_pred_chroma = ih264_inter_pred_chroma_av8; 227 228 /* sad me level functions */ 229 ps_codec->apf_compute_sad_16x16[0] = ime_compute_sad_16x16_av8; 230 ps_codec->apf_compute_sad_16x16[1] = ime_compute_sad_16x16_fast_av8; 231 ps_codec->pf_compute_sad_16x8 = ime_compute_sad_16x8_av8; 232 233 /* memor handling operations */ 234 ps_mem_fxns->pf_mem_cpy_mul8 = ih264_memcpy_mul_8_av8; 235 ps_mem_fxns->pf_mem_set_mul8 = ih264_memset_mul_8_av8; 236 237 /* sad me level functions */ 238 for(i = 0; i < (MAX_PROCESS_CTXT); i++) 239 { 240 ps_proc = &ps_codec->as_process[i]; 241 ps_me_ctxt = &ps_proc->s_me_ctxt; 242 ps_me_ctxt->pf_ime_compute_sad_16x16[0] = ime_compute_sad_16x16_av8; 243 ps_me_ctxt->pf_ime_compute_sad_16x16[1] = ime_compute_sad_16x16_fast_av8; 244 ps_me_ctxt->pf_ime_compute_sad_16x8 = ime_compute_sad_16x8_av8; 245 ps_me_ctxt->pf_ime_compute_sad4_diamond = ime_calculate_sad4_prog_av8; 246 ps_me_ctxt->pf_ime_compute_sad3_diamond = ime_calculate_sad3_prog_av8; 247 ps_me_ctxt->pf_ime_compute_sad2_diamond = ime_calculate_sad2_prog_av8; 248 ps_me_ctxt->pf_ime_sub_pel_compute_sad_16x16 = ime_sub_pel_compute_sad_16x16_av8; 249 ps_me_ctxt->pf_ime_compute_sad_stat_luma_16x16 = ime_compute_satqd_16x16_lumainter_av8; 250 } 251 252 /* intra mode eval -encoder level function */ 253 ps_codec->pf_ih264e_evaluate_intra16x16_modes = ih264e_evaluate_intra16x16_modes_av8; 254 ps_codec->pf_ih264e_evaluate_intra_chroma_modes = ih264e_evaluate_intra_chroma_modes_av8; 255 ps_codec->pf_ih264e_evaluate_intra_4x4_modes = ih264e_evaluate_intra_4x4_modes; 256 257 /* csc */ 258 ps_codec->pf_ih264e_conv_420p_to_420sp = ih264e_fmt_conv_420p_to_420sp; 259 ps_codec->pf_ih264e_fmt_conv_422i_to_420sp = ih264e_fmt_conv_422i_to_420sp; 260 261 /* Halp pel generation function - encoder level*/ 262 ps_codec->pf_ih264e_sixtapfilter_horz = ih264e_sixtapfilter_horz_av8; 263 ps_codec->pf_ih264e_sixtap_filter_2dvh_vert = ih264e_sixtap_filter_2dvh_vert_av8; 264 } 265