xref: /aosp_15_r20/external/libavc/encoder/arm/ih264e_function_selector_av8.c (revision 495ae853bb871d1e5a258cb02c2cc13cde8ddb9a)
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 *  ih264e_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 *  - ih264e_init_function_ptr_neon_av8
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 
55 #include "ih264_error.h"
56 #include "ih264_defs.h"
57 #include "ih264_mem_fns.h"
58 #include "ih264_padding.h"
59 #include "ih264_structs.h"
60 #include "ih264_trans_quant_itrans_iquant.h"
61 #include "ih264_inter_pred_filters.h"
62 #include "ih264_intra_pred_filters.h"
63 #include "ih264_deblk_edge_filters.h"
64 #include "ih264_cavlc_tables.h"
65 #include "ih264_cabac_tables.h"
66 
67 #include "ime_defs.h"
68 #include "ime_distortion_metrics.h"
69 #include "ime_structs.h"
70 
71 #include "irc_cntrl_param.h"
72 #include "irc_frame_info_collector.h"
73 
74 #include "ih264e_error.h"
75 #include "ih264e_defs.h"
76 #include "ih264e_rate_control.h"
77 #include "ih264e_bitstream.h"
78 #include "ih264e_cabac_structs.h"
79 #include "ih264e_structs.h"
80 #include "ih264e_half_pel.h"
81 #include "ih264e_intra_modes_eval.h"
82 #include "ih264e_core_coding.h"
83 #include "ih264e_cavlc.h"
84 #include "ih264e_cabac.h"
85 #include "ih264e_fmt_conv.h"
86 #include "ih264e_platform_macros.h"
87 
88 
89 /*****************************************************************************/
90 /* Function Definitions                                                      */
91 /*****************************************************************************/
92 
93 /**
94 *******************************************************************************
95 *
96 * @brief Initialize the intra/inter/transform/deblk/entropy function pointers
97 *
98 * @par Description: the current routine initializes the function pointers of
99 * codec context basing on the architecture in use
100 *
101 * @param[in] ps_codec
102 *  Codec context pointer
103 *
104 * @returns  none
105 *
106 * @remarks none
107 *
108 *******************************************************************************
109 */
ih264e_init_function_ptr_neon_av8(codec_t * ps_codec)110 void ih264e_init_function_ptr_neon_av8(codec_t *ps_codec)
111 {
112     WORD32 i= 0;
113 
114     /* Init function pointers for intra pred leaf level functions luma
115      * Intra 16x16 */
116     ps_codec->apf_intra_pred_16_l[0] = ih264_intra_pred_luma_16x16_mode_vert_av8;
117     ps_codec->apf_intra_pred_16_l[1] = ih264_intra_pred_luma_16x16_mode_horz_av8;
118     ps_codec->apf_intra_pred_16_l[2] = ih264_intra_pred_luma_16x16_mode_dc_av8;
119     ps_codec->apf_intra_pred_16_l[3] = ih264_intra_pred_luma_16x16_mode_plane_av8;
120 
121     /* Init function pointers for intra pred leaf level functions luma
122      * Intra 4x4 */
123     ps_codec->apf_intra_pred_4_l[0] = ih264_intra_pred_luma_4x4_mode_vert_av8;
124     ps_codec->apf_intra_pred_4_l[1] = ih264_intra_pred_luma_4x4_mode_horz_av8;
125     ps_codec->apf_intra_pred_4_l[2] = ih264_intra_pred_luma_4x4_mode_dc_av8;
126     ps_codec->apf_intra_pred_4_l[3] = ih264_intra_pred_luma_4x4_mode_diag_dl_av8;
127     ps_codec->apf_intra_pred_4_l[4] = ih264_intra_pred_luma_4x4_mode_diag_dr_av8;
128     ps_codec->apf_intra_pred_4_l[5] = ih264_intra_pred_luma_4x4_mode_vert_r_av8;
129     ps_codec->apf_intra_pred_4_l[6] = ih264_intra_pred_luma_4x4_mode_horz_d_av8;
130     ps_codec->apf_intra_pred_4_l[7] = ih264_intra_pred_luma_4x4_mode_vert_l_av8;
131     ps_codec->apf_intra_pred_4_l[8] = ih264_intra_pred_luma_4x4_mode_horz_u_av8;
132 
133     /* Init function pointers for intra pred leaf level functions luma
134      * Intra 8x8 */
135     ps_codec->apf_intra_pred_8_l[0] = ih264_intra_pred_luma_8x8_mode_vert_av8;
136     ps_codec->apf_intra_pred_8_l[2] = ih264_intra_pred_luma_8x8_mode_dc_av8;
137     ps_codec->apf_intra_pred_8_l[3] = ih264_intra_pred_luma_8x8_mode_diag_dl_av8;
138     ps_codec->apf_intra_pred_8_l[4] = ih264_intra_pred_luma_8x8_mode_diag_dr_av8;
139     ps_codec->apf_intra_pred_8_l[5] = ih264_intra_pred_luma_8x8_mode_vert_r_av8;
140     ps_codec->apf_intra_pred_8_l[6] = ih264_intra_pred_luma_8x8_mode_horz_d_av8;
141     ps_codec->apf_intra_pred_8_l[7] = ih264_intra_pred_luma_8x8_mode_vert_l_av8;
142     ps_codec->apf_intra_pred_8_l[8] = ih264_intra_pred_luma_8x8_mode_horz_u_av8;
143 
144     /* Init function pointers for intra pred leaf level functions chroma
145      * Intra 8x8 */
146     ps_codec->apf_intra_pred_c[0] = ih264_intra_pred_chroma_8x8_mode_dc_av8;
147     ps_codec->apf_intra_pred_c[1] = ih264_intra_pred_chroma_8x8_mode_horz_av8;
148     ps_codec->apf_intra_pred_c[2] = ih264_intra_pred_chroma_8x8_mode_vert_av8;
149     ps_codec->apf_intra_pred_c[3] = ih264_intra_pred_chroma_8x8_mode_plane_av8;
150 
151     /* Init forward transform fn ptr */
152     ps_codec->pf_resi_trans_quant_8x8 = ih264_resi_trans_quant_8x8;
153     ps_codec->pf_resi_trans_quant_4x4 = ih264_resi_trans_quant_4x4_av8;
154     ps_codec->pf_resi_trans_quant_chroma_4x4 = ih264_resi_trans_quant_chroma_4x4_av8;
155     ps_codec->pf_hadamard_quant_4x4 = ih264_hadamard_quant_4x4_av8;
156     ps_codec->pf_hadamard_quant_2x2_uv = ih264_hadamard_quant_2x2_uv_av8;
157 
158     /* Init inverse transform fn ptr */
159     ps_codec->pf_iquant_itrans_recon_8x8 = ih264_iquant_itrans_recon_8x8_av8;
160     ps_codec->pf_iquant_itrans_recon_4x4 = ih264_iquant_itrans_recon_4x4_av8;
161     ps_codec->pf_iquant_itrans_recon_4x4_dc = ih264_iquant_itrans_recon_4x4_dc_av8;
162     ps_codec->pf_iquant_itrans_recon_chroma_4x4 = ih264_iquant_itrans_recon_chroma_4x4_av8;
163     ps_codec->pf_iquant_itrans_recon_chroma_4x4_dc = ih264_iquant_itrans_recon_chroma_4x4_dc_av8;
164     ps_codec->pf_ihadamard_scaling_4x4 = ih264_ihadamard_scaling_4x4_av8;
165     ps_codec->pf_ihadamard_scaling_2x2_uv = ih264_ihadamard_scaling_2x2_uv_av8;
166     ps_codec->pf_interleave_copy = ih264_interleave_copy_av8;
167 
168     /* Init fn ptr luma core coding */
169     ps_codec->luma_energy_compaction[0] = ih264e_code_luma_intra_macroblock_16x16;
170     ps_codec->luma_energy_compaction[1] = ih264e_code_luma_intra_macroblock_4x4;
171     ps_codec->luma_energy_compaction[3] = ih264e_code_luma_inter_macroblock_16x16;
172 
173     /* Init fn ptr chroma core coding */
174     ps_codec->chroma_energy_compaction[0] = ih264e_code_chroma_intra_macroblock_8x8;
175     ps_codec->chroma_energy_compaction[1] = ih264e_code_chroma_inter_macroblock_8x8;
176 
177     /* Init fn ptr luma deblocking */
178     ps_codec->pf_deblk_luma_vert_bs4 = ih264_deblk_luma_vert_bs4_av8;
179     ps_codec->pf_deblk_luma_vert_bslt4 = ih264_deblk_luma_vert_bslt4_av8;
180     ps_codec->pf_deblk_luma_horz_bs4 = ih264_deblk_luma_horz_bs4_av8;
181     ps_codec->pf_deblk_luma_horz_bslt4 = ih264_deblk_luma_horz_bslt4_av8;
182 
183     /* Init fn ptr chroma deblocking */
184     ps_codec->pf_deblk_chroma_vert_bs4 = ih264_deblk_chroma_vert_bs4_av8;
185     ps_codec->pf_deblk_chroma_vert_bslt4 = ih264_deblk_chroma_vert_bslt4_av8;
186     ps_codec->pf_deblk_chroma_horz_bs4 = ih264_deblk_chroma_horz_bs4_av8;
187     ps_codec->pf_deblk_chroma_horz_bslt4 = ih264_deblk_chroma_horz_bslt4_av8;
188 
189     /* write mb syntax layer */
190     /* write mb syntax layer */
191     ps_codec->pf_write_mb_syntax_layer[CAVLC][ISLICE] = ih264e_write_islice_mb_cavlc;
192     ps_codec->pf_write_mb_syntax_layer[CAVLC][PSLICE] = ih264e_write_pslice_mb_cavlc;
193     ps_codec->pf_write_mb_syntax_layer[CAVLC][BSLICE] = ih264e_write_bslice_mb_cavlc;
194     ps_codec->pf_write_mb_syntax_layer[CABAC][ISLICE] = ih264e_write_islice_mb_cabac;
195     ps_codec->pf_write_mb_syntax_layer[CABAC][PSLICE] = ih264e_write_pslice_mb_cabac;
196 
197     /* Padding Functions */
198     ps_codec->pf_pad_top = ih264_pad_top_av8;
199     ps_codec->pf_pad_bottom = ih264_pad_bottom;
200     ps_codec->pf_pad_left_luma = ih264_pad_left_luma_av8;
201     ps_codec->pf_pad_left_chroma = ih264_pad_left_chroma_av8;
202     ps_codec->pf_pad_right_luma = ih264_pad_right_luma_av8;
203     ps_codec->pf_pad_right_chroma = ih264_pad_right_chroma_av8;
204 
205     /* Inter pred leaf level functions */
206     ps_codec->pf_inter_pred_luma_copy = ih264_inter_pred_luma_copy_av8;
207     ps_codec->pf_inter_pred_luma_horz = ih264_inter_pred_luma_horz_av8;
208     ps_codec->pf_inter_pred_luma_vert = ih264_inter_pred_luma_vert_av8;
209     ps_codec->pf_inter_pred_luma_bilinear = ih264_inter_pred_luma_bilinear;
210     ps_codec->pf_inter_pred_chroma = ih264_inter_pred_chroma_av8;
211 
212     /* sad me level functions */
213     ps_codec->apf_compute_sad_16x16[0] = ime_compute_sad_16x16_av8;
214     ps_codec->apf_compute_sad_16x16[1] = ime_compute_sad_16x16_fast_av8;
215     ps_codec->pf_compute_sad_16x8 = ime_compute_sad_16x8_av8;
216 
217     /* memor handling operations */
218     ps_codec->pf_mem_cpy = ih264_memcpy_av8;
219     ps_codec->pf_mem_cpy_mul8 = ih264_memcpy_mul_8_av8;
220     ps_codec->pf_mem_set = ih264_memset_av8;
221     ps_codec->pf_mem_set_mul8 = ih264_memset_mul_8_av8;
222 
223     /* sad me level functions */
224     for(i = 0; i < (MAX_PROCESS_CTXT); i++)
225     {
226         process_ctxt_t *ps_proc = &ps_codec->as_process[i];
227         me_ctxt_t *ps_me_ctxt = &ps_proc->s_me_ctxt;
228 
229         ps_me_ctxt->pf_ime_compute_sad_16x16[0] = ime_compute_sad_16x16_av8;
230         ps_me_ctxt->pf_ime_compute_sad_16x16[1] = ime_compute_sad_16x16_fast_av8;
231         ps_me_ctxt->pf_ime_compute_sad_16x8 = ime_compute_sad_16x8_av8;
232         ps_me_ctxt->pf_ime_compute_sad4_diamond = ime_calculate_sad4_prog_av8;
233         ps_me_ctxt->pf_ime_compute_sad3_diamond = ime_calculate_sad3_prog_av8;
234         ps_me_ctxt->pf_ime_compute_sad2_diamond = ime_calculate_sad2_prog_av8;
235         ps_me_ctxt->pf_ime_sub_pel_compute_sad_16x16 = ime_sub_pel_compute_sad_16x16_av8;
236         ps_me_ctxt->pf_ime_compute_sad_stat_luma_16x16 = ime_compute_satqd_16x16_lumainter_av8;
237     }
238 
239     /* intra mode eval -encoder level function */
240     ps_codec->pf_ih264e_evaluate_intra16x16_modes = ih264e_evaluate_intra16x16_modes_av8;
241     ps_codec->pf_ih264e_evaluate_intra_chroma_modes = ih264e_evaluate_intra_chroma_modes_av8;
242     ps_codec->pf_ih264e_evaluate_intra_4x4_modes = ih264e_evaluate_intra_4x4_modes;
243 
244     /* csc */
245     ps_codec->pf_ih264e_conv_420p_to_420sp = ih264e_fmt_conv_420p_to_420sp;
246     ps_codec->pf_ih264e_fmt_conv_422i_to_420sp = ih264e_fmt_conv_422i_to_420sp;
247 
248     /* Halp pel generation function - encoder level*/
249     ps_codec->pf_ih264e_sixtapfilter_horz = ih264e_sixtapfilter_horz_av8;
250     ps_codec->pf_ih264e_sixtap_filter_2dvh_vert = ih264e_sixtap_filter_2dvh_vert_av8;
251 
252     return ;
253 }
254 
255