Coverage Report

Created: 2025-10-27 06:23

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libxaac/decoder/ixheaacd_mps_calc_m1m2_emm.c
Line
Count
Source
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 "ixheaac_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_sbr_common.h"
25
#include "ixheaac_constants.h"
26
#include "ixheaac_basic_ops32.h"
27
#include "ixheaac_basic_ops40.h"
28
#include "ixheaacd_bitbuffer.h"
29
#include "ixheaacd_common_rom.h"
30
#include "ixheaacd_sbrdecsettings.h"
31
#include "ixheaacd_sbr_scale.h"
32
#include "ixheaacd_env_extr_part.h"
33
#include "ixheaacd_sbr_rom.h"
34
#include "ixheaacd_hybrid.h"
35
#include "ixheaacd_ps_dec.h"
36
#include "ixheaac_error_standards.h"
37
#include "ixheaacd_mps_polyphase.h"
38
#include "ixheaacd_config.h"
39
#include "ixheaacd_qmf_dec.h"
40
#include "ixheaacd_mps_dec.h"
41
#include "ixheaacd_mps_macro_def.h"
42
#include "ixheaacd_mps_basic_op.h"
43
#include "ixheaacd_mps_calc_m1m2_common.h"
44
45
0
VOID ixheaacd_calc_m1m2_emm(ia_heaac_mps_state_struct *pstr_mps_state) {
46
0
  ia_mps_dec_auxilary_struct *p_aux_struct = pstr_mps_state->aux_struct;
47
0
  ia_mps_dec_m2_param_struct *m2_param = p_aux_struct->m2_param;
48
0
  ia_mps_dec_m1_param_struct *m1_param = pstr_mps_state->array_struct->m1_param;
49
0
  WORD32 ps;
50
0
  WORD32 pb;
51
0
  WORD32 col;
52
0
  WORD32 row;
53
54
0
  WORD64 acc;
55
0
  WORD32 *h11, *h12, *h21, *h22, *dummy1, *dummy2;
56
0
  WORD16 *dummy3, *dummy4;
57
58
0
  h11 = pstr_mps_state->mps_scratch_mem_v;
59
0
  h12 = h11 + IXHEAAC_GET_SIZE_ALIGNED_TYPE(MAX_PARAMETER_BANDS, sizeof(*h12), BYTE_ALIGN_8);
60
0
  h21 = h12 + IXHEAAC_GET_SIZE_ALIGNED_TYPE(MAX_PARAMETER_BANDS, sizeof(*h21), BYTE_ALIGN_8);
61
0
  h22 = h21 + IXHEAAC_GET_SIZE_ALIGNED_TYPE(MAX_PARAMETER_BANDS, sizeof(*h22), BYTE_ALIGN_8);
62
0
  dummy1 =
63
0
      h22 + IXHEAAC_GET_SIZE_ALIGNED_TYPE(MAX_PARAMETER_BANDS, sizeof(*dummy1), BYTE_ALIGN_8);
64
0
  dummy2 =
65
0
      dummy1 + IXHEAAC_GET_SIZE_ALIGNED_TYPE(MAX_PARAMETER_BANDS, sizeof(*dummy2), BYTE_ALIGN_8);
66
67
0
  dummy3 = (WORD16 *)pstr_mps_state->mps_scratch_mem_v +
68
0
           IXHEAAC_GET_SIZE_ALIGNED_TYPE(PARAMETER_BANDSX12, sizeof(*dummy3), BYTE_ALIGN_8);
69
0
  dummy4 =
70
0
      dummy3 + IXHEAAC_GET_SIZE_ALIGNED_TYPE(MAX_PARAMETER_BANDS, sizeof(*dummy4), BYTE_ALIGN_8);
71
72
0
  for (ps = 0; ps < pstr_mps_state->num_parameter_sets; ps++) {
73
0
    ixheaacd_param_2_umx_ps(pstr_mps_state, h11, h12, h21, h22, dummy1, dummy2, dummy3, dummy4, 0,
74
0
                            ps, 0);
75
76
0
    for (pb = 0; pb < pstr_mps_state->num_parameter_bands; pb++) {
77
0
      WORD32 m11 = p_aux_struct->ttt_cpc_1[0][ps][pb] + ONE_IN_Q16;
78
0
      WORD32 m12 = p_aux_struct->ttt_cpc_2[0][ps][pb] - ONE_IN_Q15;
79
0
      WORD32 m21 = p_aux_struct->ttt_cpc_1[0][ps][pb] - ONE_IN_Q15;
80
0
      WORD32 m22 = p_aux_struct->ttt_cpc_2[0][ps][pb] + ONE_IN_Q16;
81
0
      WORD32 m31 = ONE_IN_Q15 - p_aux_struct->ttt_cpc_1[0][ps][pb];
82
0
      WORD32 m32 = ONE_IN_Q15 - p_aux_struct->ttt_cpc_2[0][ps][pb];
83
0
      WORD32 weight1;
84
0
      WORD32 weight2;
85
0
      WORD32 h_real[2][2];
86
0
      WORD32 h_imag[2][2];
87
88
0
      ia_mps_dec_spatial_bs_frame_struct *p_cur_bs = pstr_mps_state->bs_frame;
89
90
0
      ixheaacd_get_matrix_inversion_weights(
91
0
          p_cur_bs->ott_cld_idx[0][ps][pb], p_cur_bs->ott_cld_idx[0][ps][pb], 1,
92
0
          p_aux_struct->ttt_cpc_1[0][ps][pb], p_aux_struct->ttt_cpc_2[0][ps][pb], &weight1,
93
0
          &weight2, &(pstr_mps_state->ia_mps_dec_mps_table));
94
95
0
      ixheaacd_invert_matrix(weight1, weight2, h_real, h_imag,
96
0
                             pstr_mps_state->ia_mps_dec_mps_table.common_table_ptr);
97
98
0
      pstr_mps_state->m1_param_imag_present = 1;
99
100
0
      acc = (WORD64)((WORD64)h_real[0][0] * (WORD64)m11 + (WORD64)h_real[1][0] * (WORD64)m12);
101
0
      acc >>= 15;
102
0
      m1_param->m1_param_real[0][0][ps][pb] = (WORD32)acc;
103
104
0
      acc = (WORD64)((WORD64)h_real[0][1] * (WORD64)m11 + (WORD64)h_real[1][1] * (WORD64)m12);
105
0
      acc >>= 15;
106
0
      m1_param->m1_param_real[0][1][ps][pb] = (WORD32)acc;
107
108
0
      acc = (WORD64)((WORD64)h_imag[0][0] * (WORD64)m11 + (WORD64)h_imag[1][0] * (WORD64)m12);
109
0
      acc >>= 15;
110
0
      m1_param->m1_param_imag[0][0][ps][pb] = (WORD32)acc;
111
112
0
      acc = (WORD64)((WORD64)h_imag[0][1] * (WORD64)m11 + (WORD64)h_imag[1][1] * (WORD64)m12);
113
0
      acc >>= 15;
114
0
      m1_param->m1_param_imag[0][1][ps][pb] = (WORD32)acc;
115
116
0
      acc = (WORD64)((WORD64)h_real[0][0] * (WORD64)m21 + (WORD64)h_real[1][0] * (WORD64)m22);
117
0
      acc >>= 15;
118
0
      m1_param->m1_param_real[1][0][ps][pb] = (WORD32)acc;
119
120
0
      acc = (WORD64)((WORD64)h_real[0][1] * (WORD64)m21 + (WORD64)h_real[1][1] * (WORD64)m22);
121
0
      acc >>= 15;
122
0
      m1_param->m1_param_real[1][1][ps][pb] = (WORD32)acc;
123
124
0
      acc = (WORD64)((WORD64)h_imag[0][0] * (WORD64)m21 + (WORD64)h_imag[1][0] * (WORD64)m22);
125
0
      acc >>= 15;
126
0
      m1_param->m1_param_imag[1][0][ps][pb] = (WORD32)acc;
127
128
0
      acc = (WORD64)((WORD64)h_imag[0][1] * (WORD64)m21 + (WORD64)h_imag[1][1] * (WORD64)m22);
129
0
      acc >>= 15;
130
0
      m1_param->m1_param_imag[1][1][ps][pb] = (WORD32)acc;
131
132
0
      acc = (WORD64)((WORD64)h_real[0][0] * (WORD64)m31 + (WORD64)h_real[1][0] * (WORD64)m32);
133
0
      acc >>= 15;
134
0
      m1_param->m1_param_real[2][0][ps][pb] = (WORD32)acc;
135
136
0
      acc = (WORD64)((WORD64)h_real[0][1] * (WORD64)m31 + (WORD64)h_real[1][1] * (WORD64)m32);
137
0
      acc >>= 15;
138
0
      m1_param->m1_param_real[2][1][ps][pb] = (WORD32)acc;
139
140
0
      acc = (WORD64)((WORD64)h_imag[0][0] * (WORD64)m31 + (WORD64)h_imag[1][0] * (WORD64)m32);
141
0
      acc >>= 15;
142
0
      m1_param->m1_param_imag[2][0][ps][pb] = (WORD32)acc;
143
144
0
      acc = (WORD64)((WORD64)h_imag[0][1] * (WORD64)m31 + (WORD64)h_imag[1][1] * (WORD64)m32);
145
0
      acc >>= 15;
146
0
      m1_param->m1_param_imag[2][1][ps][pb] = (WORD32)acc;
147
148
0
      m1_param->m1_param_real[0][2][ps][pb] = ONE_IN_Q15;
149
0
      m1_param->m1_param_real[1][2][ps][pb] = ONE_IN_Q15;
150
0
      m1_param->m1_param_real[2][2][ps][pb] = -32768;
151
152
0
      m1_param->m1_param_imag[0][2][ps][pb] = 0;
153
0
      m1_param->m1_param_imag[1][2][ps][pb] = 0;
154
0
      m1_param->m1_param_imag[2][2][ps][pb] = 0;
155
156
0
      for (row = 0; row < 3; row++) {
157
0
        for (col = 0; col < 3; col++) {
158
0
          m1_param->m1_param_real[row][col][ps][pb] = ixheaacd_mps_mult32_shr_15(
159
0
              m1_param->m1_param_real[row][col][ps][pb], ONE_BY_THREE_Q15);
160
0
          m1_param->m1_param_imag[row][col][ps][pb] = ixheaacd_mps_mult32_shr_15(
161
0
              m1_param->m1_param_imag[row][col][ps][pb], ONE_BY_THREE_Q15);
162
0
        }
163
164
0
        m1_param->m1_param_real[2][col][ps][pb] =
165
0
            ixheaacd_mps_mult32_shr_15(m1_param->m1_param_real[2][col][ps][pb], SQRT_TWO_Q15);
166
0
        m1_param->m1_param_imag[2][col][ps][pb] =
167
0
            ixheaacd_mps_mult32_shr_15(m1_param->m1_param_imag[2][col][ps][pb], SQRT_TWO_Q15);
168
169
0
        m1_param->m1_param_real[3][col][ps][pb] = m1_param->m1_param_real[0][col][ps][pb];
170
0
        m1_param->m1_param_imag[3][col][ps][pb] = m1_param->m1_param_imag[0][col][ps][pb];
171
0
        m1_param->m1_param_real[4][col][ps][pb] = m1_param->m1_param_real[1][col][ps][pb];
172
0
        m1_param->m1_param_imag[4][col][ps][pb] = m1_param->m1_param_imag[1][col][ps][pb];
173
0
        m1_param->m1_param_real[5][col][ps][pb] = 0;
174
0
        m1_param->m1_param_imag[5][col][ps][pb] = 0;
175
0
      }
176
0
    }
177
178
0
    for (pb = 0; pb < pstr_mps_state->num_parameter_bands; pb++) {
179
0
      m2_param->m2_decor_real[0][ps][pb] = h12[pb];
180
0
      m2_param->m2_decor_real[1][ps][pb] = h22[pb];
181
0
      m2_param->m2_decor_real[2][ps][pb] = h12[pb];
182
0
      m2_param->m2_decor_real[3][ps][pb] = h22[pb];
183
0
    }
184
185
0
    for (pb = 0; pb < pstr_mps_state->num_parameter_bands; pb++) {
186
0
      m2_param->m2_resid_real[0][ps][pb] = h11[pb];
187
0
      m2_param->m2_resid_real[1][ps][pb] = h21[pb];
188
0
      m2_param->m2_resid_real[2][ps][pb] = h21[pb];
189
0
      m2_param->m2_resid_real[3][ps][pb] = 32768;
190
0
    }
191
0
  }
192
0
  return;
193
0
}