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_generic.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_generic
33*
34* @remarks
35*  None
36*
37*******************************************************************************
38*/
39
40
41/*****************************************************************************/
42/* File Includes                                                             */
43/*****************************************************************************/
44
45/* System Include files */
46#include <stdio.h>
47#include <stddef.h>
48#include <stdlib.h>
49#include <string.h>
50
51/* User Include files */
52#include "ih264_typedefs.h"
53#include "iv2.h"
54#include "ive2.h"
55#include "ih264_defs.h"
56#include "ih264_size_defs.h"
57#include "ih264e_defs.h"
58#include "ih264e_error.h"
59#include "ih264e_bitstream.h"
60#include "ime_distortion_metrics.h"
61#include "ime_defs.h"
62#include "ime_structs.h"
63#include "ih264_error.h"
64#include "ih264_structs.h"
65#include "ih264_trans_quant_itrans_iquant.h"
66#include "ih264_inter_pred_filters.h"
67#include "ih264_mem_fns.h"
68#include "ih264_padding.h"
69#include "ih264_intra_pred_filters.h"
70#include "ih264_deblk_edge_filters.h"
71#include "ih264_cabac_tables.h"
72#include "irc_cntrl_param.h"
73#include "irc_frame_info_collector.h"
74#include "ih264e_rate_control.h"
75#include "ih264e_cabac_structs.h"
76#include "ih264e_structs.h"
77#include "ih264e_platform_macros.h"
78#include "ih264e_cabac.h"
79#include "ih264e_core_coding.h"
80#include "ih264_cavlc_tables.h"
81#include "ih264e_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*/
104void ih264e_init_function_ptr_neon_a9q(codec_t *ps_codec)
105{
106    WORD32 i= 0;
107    /* curr proc ctxt */
108    process_ctxt_t *ps_proc = NULL;
109    me_ctxt_t *ps_me_ctxt = NULL;
110
111    /* Init function pointers for intra pred leaf level functions luma
112     * Intra 16x16 */
113    ps_codec->apf_intra_pred_16_l[0] = ih264_intra_pred_luma_16x16_mode_vert_a9q;
114    ps_codec->apf_intra_pred_16_l[1] = ih264_intra_pred_luma_16x16_mode_horz_a9q;
115    ps_codec->apf_intra_pred_16_l[2] = ih264_intra_pred_luma_16x16_mode_dc_a9q;
116    ps_codec->apf_intra_pred_16_l[3] = ih264_intra_pred_luma_16x16_mode_plane_a9q;
117
118    /* Init function pointers for intra pred leaf level functions luma
119     * Intra 4x4 */
120    ps_codec->apf_intra_pred_4_l[0] = ih264_intra_pred_luma_4x4_mode_vert_a9q;
121    ps_codec->apf_intra_pred_4_l[1] = ih264_intra_pred_luma_4x4_mode_horz_a9q;
122    ps_codec->apf_intra_pred_4_l[2] = ih264_intra_pred_luma_4x4_mode_dc_a9q;
123    ps_codec->apf_intra_pred_4_l[3] = ih264_intra_pred_luma_4x4_mode_diag_dl_a9q;
124    ps_codec->apf_intra_pred_4_l[4] = ih264_intra_pred_luma_4x4_mode_diag_dr_a9q;
125    ps_codec->apf_intra_pred_4_l[5] = ih264_intra_pred_luma_4x4_mode_vert_r_a9q;
126    ps_codec->apf_intra_pred_4_l[6] = ih264_intra_pred_luma_4x4_mode_horz_d_a9q;
127    ps_codec->apf_intra_pred_4_l[7] = ih264_intra_pred_luma_4x4_mode_vert_l_a9q;
128    ps_codec->apf_intra_pred_4_l[8] = ih264_intra_pred_luma_4x4_mode_horz_u_a9q;
129
130    /* Init function pointers for intra pred leaf level functions luma
131     * Intra 8x8 */
132    ps_codec->apf_intra_pred_8_l[0] = ih264_intra_pred_luma_8x8_mode_vert_a9q;
133    ps_codec->apf_intra_pred_8_l[2] = ih264_intra_pred_luma_8x8_mode_dc_a9q;
134    ps_codec->apf_intra_pred_8_l[3] = ih264_intra_pred_luma_8x8_mode_diag_dl_a9q;
135    ps_codec->apf_intra_pred_8_l[4] = ih264_intra_pred_luma_8x8_mode_diag_dr_a9q;
136    ps_codec->apf_intra_pred_8_l[5] = ih264_intra_pred_luma_8x8_mode_vert_r_a9q;
137    ps_codec->apf_intra_pred_8_l[6] = ih264_intra_pred_luma_8x8_mode_horz_d_a9q;
138    ps_codec->apf_intra_pred_8_l[7] = ih264_intra_pred_luma_8x8_mode_vert_l_a9q;
139    ps_codec->apf_intra_pred_8_l[8] = ih264_intra_pred_luma_8x8_mode_horz_u_a9q;
140
141    /* Init function pointers for intra pred leaf level functions chroma
142     * Intra 8x8 */
143    ps_codec->apf_intra_pred_c[0] = ih264_intra_pred_chroma_8x8_mode_dc_a9q;
144    ps_codec->apf_intra_pred_c[1] = ih264_intra_pred_chroma_8x8_mode_horz_a9q;
145    ps_codec->apf_intra_pred_c[2] = ih264_intra_pred_chroma_8x8_mode_vert_a9q;
146    ps_codec->apf_intra_pred_c[3] = ih264_intra_pred_chroma_8x8_mode_plane_a9q;
147
148    /* Init forward transform fn ptr */
149    ps_codec->pf_resi_trans_quant_8x8           = ih264_resi_trans_quant_8x8;
150    ps_codec->pf_resi_trans_quant_4x4           = ih264_resi_trans_quant_4x4_a9;
151    ps_codec->pf_resi_trans_quant_chroma_4x4    = ih264_resi_trans_quant_chroma_4x4_a9;
152    ps_codec->pf_hadamard_quant_4x4             = ih264_hadamard_quant_4x4_a9;
153    ps_codec->pf_hadamard_quant_2x2_uv          = ih264_hadamard_quant_2x2_uv_a9;
154
155    /* Init inverse transform fn ptr */
156    ps_codec->pf_iquant_itrans_recon_8x8            = ih264_iquant_itrans_recon_8x8;
157    ps_codec->pf_iquant_itrans_recon_4x4            = ih264_iquant_itrans_recon_4x4_a9;
158    ps_codec->pf_iquant_itrans_recon_4x4_dc         = ih264_iquant_itrans_recon_4x4_dc_a9;
159    ps_codec->pf_iquant_itrans_recon_chroma_4x4     = ih264_iquant_itrans_recon_chroma_4x4_a9;
160    ps_codec->pf_iquant_itrans_recon_chroma_4x4_dc  = ih264_iquant_itrans_recon_chroma_4x4_dc_a9;
161    ps_codec->pf_ihadamard_scaling_4x4              = ih264_ihadamard_scaling_4x4_a9;
162    ps_codec->pf_ihadamard_scaling_2x2_uv           = ih264_ihadamard_scaling_2x2_uv_a9;
163    ps_codec->pf_interleave_copy                    = ih264_interleave_copy_a9;
164
165    /* Init fn ptr luma core coding */
166    ps_codec->luma_energy_compaction[0] = ih264e_code_luma_intra_macroblock_16x16;
167    ps_codec->luma_energy_compaction[1] = ih264e_code_luma_intra_macroblock_4x4;
168    ps_codec->luma_energy_compaction[3] = ih264e_code_luma_inter_macroblock_16x16;
169
170    /* Init fn ptr chroma core coding */
171    ps_codec->chroma_energy_compaction[0] = ih264e_code_chroma_intra_macroblock_8x8;
172    ps_codec->chroma_energy_compaction[1] = ih264e_code_chroma_inter_macroblock_8x8;
173
174    /* Init fn ptr luma deblocking */
175    ps_codec->pf_deblk_luma_vert_bs4 = ih264_deblk_luma_vert_bs4_a9;
176    ps_codec->pf_deblk_luma_vert_bslt4 = ih264_deblk_luma_vert_bslt4_a9;
177    ps_codec->pf_deblk_luma_horz_bs4 = ih264_deblk_luma_horz_bs4_a9;
178    ps_codec->pf_deblk_luma_horz_bslt4 = ih264_deblk_luma_horz_bslt4_a9;
179
180    /* Init fn ptr chroma deblocking */
181    ps_codec->pf_deblk_chroma_vert_bs4 = ih264_deblk_chroma_vert_bs4_a9;
182    ps_codec->pf_deblk_chroma_vert_bslt4 = ih264_deblk_chroma_vert_bslt4_a9;
183    ps_codec->pf_deblk_chroma_horz_bs4 = ih264_deblk_chroma_horz_bs4_a9;
184    ps_codec->pf_deblk_chroma_horz_bslt4 = ih264_deblk_chroma_horz_bslt4_a9;
185
186    /* write mb syntax layer */
187    ps_codec->pf_write_mb_syntax_layer[CAVLC][ISLICE] = ih264e_write_islice_mb_cavlc;
188    ps_codec->pf_write_mb_syntax_layer[CAVLC][PSLICE] = ih264e_write_pslice_mb_cavlc;
189    ps_codec->pf_write_mb_syntax_layer[CABAC][ISLICE] = ih264e_write_islice_mb_cabac;
190    ps_codec->pf_write_mb_syntax_layer[CABAC][PSLICE] = ih264e_write_pslice_mb_cabac;
191
192    /* Padding Functions */
193    ps_codec->pf_pad_top = ih264_pad_top_a9q;
194    ps_codec->pf_pad_bottom = ih264_pad_bottom;
195    ps_codec->pf_pad_left_luma = ih264_pad_left_luma_a9q;
196    ps_codec->pf_pad_left_chroma = ih264_pad_left_chroma_a9q;
197    ps_codec->pf_pad_right_luma = ih264_pad_right_luma_a9q;
198    ps_codec->pf_pad_right_chroma = ih264_pad_right_chroma_a9q;
199
200    /* Inter pred leaf level functions */
201    ps_codec->pf_inter_pred_luma_copy = ih264_inter_pred_luma_copy_a9q;
202    ps_codec->pf_inter_pred_luma_horz = ih264_inter_pred_luma_horz_a9q;
203    ps_codec->pf_inter_pred_luma_vert = ih264_inter_pred_luma_vert_a9q;
204    ps_codec->pf_inter_pred_luma_bilinear = ih264_inter_pred_luma_bilinear_a9q;
205    ps_codec->pf_inter_pred_chroma = ih264_inter_pred_chroma_a9q;
206
207    /* sad me level functions */
208    ps_codec->apf_compute_sad_16x16[0] = ime_compute_sad_16x16_a9q;
209    ps_codec->apf_compute_sad_16x16[1] = ime_compute_sad_16x16_fast_a9q;
210    ps_codec->pf_compute_sad_16x8 = ime_compute_sad_16x8_a9q;
211
212    /* memor handling operations */
213    ps_codec->pf_mem_cpy = ih264_memcpy_a9q;
214    ps_codec->pf_mem_cpy_mul8 = ih264_memcpy_mul_8_a9q;
215    ps_codec->pf_mem_set = ih264_memset_a9q;
216    ps_codec->pf_mem_set_mul8 = ih264_memset_mul_8_a9q;
217
218    /* sad me level functions */
219    for (i = 0; i < (MAX_PROCESS_CTXT); i++)
220    {
221        ps_proc = &ps_codec->as_process[i];
222        ps_me_ctxt = &ps_proc->s_me_ctxt;
223        ps_me_ctxt->pf_ime_compute_sad_16x16[0] = ime_compute_sad_16x16_a9q;
224        ps_me_ctxt->pf_ime_compute_sad_16x16[1] = ime_compute_sad_16x16_fast_a9q;
225        ps_me_ctxt->pf_ime_compute_sad_16x8 = ime_compute_sad_16x8_a9q;
226        ps_me_ctxt->pf_ime_compute_sad4_diamond = ime_calculate_sad4_prog_a9q;
227        ps_me_ctxt->pf_ime_compute_sad3_diamond = ime_calculate_sad3_prog_a9q;
228        ps_me_ctxt->pf_ime_compute_sad2_diamond = ime_calculate_sad2_prog_a9q;
229        ps_me_ctxt->pf_ime_sub_pel_compute_sad_16x16 = ime_sub_pel_compute_sad_16x16_a9q;
230        ps_me_ctxt->pf_ime_compute_sad_stat_luma_16x16 = ime_compute_satqd_16x16_lumainter_a9q;
231    }
232
233    /* intra mode eval -encoder level function */
234    ps_codec->pf_ih264e_evaluate_intra16x16_modes = ih264e_evaluate_intra16x16_modes_a9q;
235    ps_codec->pf_ih264e_evaluate_intra_chroma_modes = ih264e_evaluate_intra_chroma_modes_a9q;
236    ps_codec->pf_ih264e_evaluate_intra_4x4_modes = ih264e_evaluate_intra_4x4_modes_a9q;
237
238    /* csc */
239    ps_codec->pf_ih264e_conv_420p_to_420sp = ih264e_fmt_conv_420p_to_420sp_a9q;
240    ps_codec->pf_ih264e_fmt_conv_422i_to_420sp = ih264e_fmt_conv_422i_to_420sp_a9q;
241
242    /* Halp pel generation function - encoder level */
243    ps_codec->pf_ih264e_sixtapfilter_horz = ih264e_sixtapfilter_horz_a9q;
244    ps_codec->pf_ih264e_sixtap_filter_2dvh_vert = ih264e_sixtap_filter_2dvh_vert_a9q;
245
246}
247
248