• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2  *
3  * Copyright (C) 2023 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 #include "ixheaacd_type_def.h"
21 #include "ixheaacd_mps_struct_def.h"
22 #include "ixheaacd_mps_res_rom.h"
23 #include "ixheaacd_mps_aac_struct.h"
24 #include "ixheaacd_constants.h"
25 #include "ixheaacd_bitbuffer.h"
26 #include "ixheaacd_common_rom.h"
27 #include "ixheaacd_sbrdecsettings.h"
28 #include "ixheaacd_sbr_scale.h"
29 #include "ixheaacd_env_extr_part.h"
30 #include "ixheaacd_sbr_rom.h"
31 #include "ixheaacd_hybrid.h"
32 #include "ixheaacd_ps_dec.h"
33 #include "ixheaacd_mps_polyphase.h"
34 #include "ixheaacd_config.h"
35 #include "ixheaacd_qmf_dec.h"
36 #include "ixheaacd_mps_dec.h"
37 #include "ixheaacd_mps_macro_def.h"
38 
ixheaacd_dec_interp_umx(WORD32 m[MAX_PARAMETER_SETS][MAX_PARAMETER_BANDS],WORD32 * ptr_r,WORD32 * ptr_m_prev,ia_heaac_mps_state_struct * pstr_mps_state)39 VOID ixheaacd_dec_interp_umx(WORD32 m[MAX_PARAMETER_SETS][MAX_PARAMETER_BANDS], WORD32 *ptr_r,
40                              WORD32 *ptr_m_prev, ia_heaac_mps_state_struct *pstr_mps_state) {
41   WORD32 ts, ps = 0, pb;
42   WORD32 *r_out;
43   const WORD32 *reciprocal_tab = pstr_mps_state->ia_mps_dec_mps_table.m1_m2_table_ptr->reciprocal;
44 
45   WORD32 num_parameter_bands = pstr_mps_state->num_parameter_bands;
46   WORD32 num_parameter_sets = pstr_mps_state->num_parameter_sets;
47 
48   WORD32 prev_slot = -1;
49   WORD32 *prm_slot = pstr_mps_state->aux_struct->param_slot;
50   WORD32 curr_slot = *prm_slot;
51 
52   WORD32 temp = reciprocal_tab[curr_slot];
53   r_out = ptr_r;
54 
55   for (ts = prev_slot + 1; ts <= curr_slot; ts++) {
56     for (pb = 0; pb < num_parameter_bands; pb++) {
57       WORD32 alpha = temp * (ts + 1);
58       WORD32 one_minus_alpha;
59       WORD64 result;
60 
61       one_minus_alpha = (ONE_IN_Q28 - alpha);
62 
63       result = ((WORD64)(*ptr_m_prev) * (WORD64)one_minus_alpha);
64       result += ((WORD64)(m[ps][pb]) * (WORD64)alpha);
65 
66       *r_out++ = (WORD32)((WORD64)result >> 28);
67       ptr_m_prev++;
68     }
69     ptr_m_prev -= num_parameter_bands;
70   }
71 
72   for (ps = 1; ps < num_parameter_sets; ps++) {
73     WORD32 prev_slot = prm_slot[ps - 1];
74     WORD32 curr_slot = prm_slot[ps];
75 
76     temp = reciprocal_tab[curr_slot - prev_slot - 1];
77 
78     for (ts = (prev_slot) + 1; ts <= (curr_slot); ts++) {
79       for (pb = 0; pb < num_parameter_bands; pb++) {
80         WORD32 alpha = (ts - prev_slot) * temp;
81         WORD64 result;
82         WORD32 one_minus_alpha;
83         one_minus_alpha = (ONE_IN_Q28 - alpha);
84 
85         result = ((WORD64)(m[ps - 1][pb]) * (WORD64)one_minus_alpha);
86         result += ((WORD64)(m[ps][pb]) * (WORD64)alpha);
87 
88         *r_out++ = (WORD32)((WORD64)result >> 28);
89       }
90     }
91   }
92   return;
93 }
94 
ixheaacd_apply_abs_kernels(WORD32 * ptr_r_in,WORD32 * ptr_r_out,SIZE_T * ptr_params)95 VOID ixheaacd_apply_abs_kernels(WORD32 *ptr_r_in, WORD32 *ptr_r_out, SIZE_T *ptr_params) {
96   WORD32 ts, qb;
97   SIZE_T *idx_ptr = (SIZE_T *)ptr_params[0];
98   WORD32 time_slots = (WORD32)ptr_params[1];
99   WORD32 num_parameter_bands = (WORD32)ptr_params[2];
100   WORD32 hybrid_bands = (WORD32)ptr_params[3];
101 
102   for (ts = 0; ts < time_slots; ts++) {
103     SIZE_T *idx = idx_ptr;
104     for (qb = 0; qb < hybrid_bands; qb++) {
105       WORD32 idx_v = (WORD32)(*idx);
106       *ptr_r_out++ = *(ptr_r_in + idx_v);
107       idx++;
108     }
109     ptr_r_in += num_parameter_bands;
110   }
111   return;
112 }
113