Coverage Report

Created: 2025-10-10 06:12

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libxaac/decoder/ixheaacd_mps_apply_m1.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 <string.h>
21
#include "ixheaac_type_def.h"
22
#include "ixheaacd_mps_struct_def.h"
23
#include "ixheaacd_mps_res_rom.h"
24
#include "ixheaacd_mps_aac_struct.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 "ixheaacd_mps_polyphase.h"
37
#include "ixheaacd_config.h"
38
#include "ixheaacd_qmf_dec.h"
39
#include "ixheaacd_mps_dec.h"
40
#include "ixheaacd_mps_macro_def.h"
41
#include "ixheaacd_mps_apply_common.h"
42
#include "ixheaacd_mps_basic_op.h"
43
44
14.7k
VOID ixheaacd_mps_apply_m1(ia_heaac_mps_state_struct *pstr_mps_state) {
45
14.7k
  ia_mps_dec_reuse_array_struct *p_array_struct = pstr_mps_state->array_struct;
46
14.7k
  ia_mps_dec_m1_param_struct *m1_param = p_array_struct->m1_param;
47
14.7k
  WORD32 ts, qs, row, col;
48
14.7k
  WORD32 temp_1, temp_2;
49
14.7k
  WORD32 *rout_real_ptr, *rout_imag_ptr, *rout_kernel_real_ptr, *rout_kernel_imag_ptr;
50
14.7k
  WORD32 *v_real, *v_imag, *x_real, *x_imag;
51
14.7k
  WORD32 *p_buffer_real, *p_buffer_imag, *p_v_real, *p_v_imag;
52
53
14.7k
  ia_heaac_mps_state_struct *curr_state = pstr_mps_state;
54
14.7k
  WORD32 *m1_param_real_prev = curr_state->mps_persistent_mem.m1_param_real_prev;
55
14.7k
  WORD32 *m1_param_imag_prev = curr_state->mps_persistent_mem.m1_param_imag_prev;
56
14.7k
  WORD32 imag_present = curr_state->m1_param_imag_present;
57
14.7k
  WORD32 v_channels = curr_state->num_v_channels;
58
14.7k
  WORD32 x_channels = curr_state->num_x_channels;
59
14.7k
  WORD32 hybrid_bands = curr_state->hybrid_bands;
60
14.7k
  WORD32 num_parameter_bands = curr_state->num_parameter_bands;
61
14.7k
  WORD32 *index = curr_state->index;
62
63
14.7k
  WORD32 *p_x_re, *p_x_im;
64
65
14.7k
  WORD32 hyb_bands = hybrid_bands;
66
14.7k
  WORD32 time_slots = curr_state->time_slots;
67
14.7k
  SIZE_T params[4];
68
69
14.7k
  params[0] = (SIZE_T)(&curr_state->kernels[0]);
70
14.7k
  params[1] = time_slots;
71
14.7k
  params[2] = num_parameter_bands;
72
14.7k
  params[3] = hybrid_bands;
73
74
14.7k
  rout_real_ptr = pstr_mps_state->mps_scratch_mem_v;
75
14.7k
  rout_kernel_real_ptr = rout_real_ptr + IXHEAAC_GET_SIZE_ALIGNED_TYPE(
76
14.7k
                                             TSXHB, sizeof(*rout_kernel_real_ptr), BYTE_ALIGN_8);
77
14.7k
  rout_imag_ptr = rout_kernel_real_ptr +
78
14.7k
                  IXHEAAC_GET_SIZE_ALIGNED_TYPE(TSXHB, sizeof(*rout_imag_ptr), BYTE_ALIGN_8);
79
14.7k
  rout_kernel_imag_ptr = rout_imag_ptr + IXHEAAC_GET_SIZE_ALIGNED_TYPE(
80
14.7k
                                             TSXHB, sizeof(*rout_kernel_imag_ptr), BYTE_ALIGN_8);
81
82
14.7k
  p_buffer_real = p_array_struct->buf_real;
83
14.7k
  p_buffer_imag = p_array_struct->buf_imag;
84
85
124k
  for (row = 0; row < v_channels; row++) {
86
109k
    v_real = p_buffer_real;
87
109k
    v_imag = p_buffer_imag;
88
89
3.40M
    for (ts = 0; ts < time_slots; ts++) {
90
3.29M
      memset(v_real, 0, hybrid_bands * sizeof(v_real[0]));
91
3.29M
      memset(v_imag, 0, hybrid_bands * sizeof(v_imag[0]));
92
93
3.29M
      v_real += MAX_HYBRID_BANDS;
94
3.29M
      v_imag += MAX_HYBRID_BANDS;
95
3.29M
    }
96
109k
    p_buffer_real += TSXHB;
97
109k
    p_buffer_imag += TSXHB;
98
109k
  }
99
100
14.7k
  p_buffer_real = p_array_struct->buf_real;
101
14.7k
  p_buffer_imag = p_array_struct->buf_imag;
102
103
14.7k
  if (!imag_present) {
104
27.4k
    for (row = 0; row < v_channels; row++) {
105
23.5k
      WORD32 *p_x_real = p_array_struct->x_real;
106
23.5k
      WORD32 *p_x_imag = p_array_struct->x_imag;
107
108
108k
      for (col = 0; col < x_channels; col++) {
109
84.7k
        if (pstr_mps_state->m1_param_present[row][col]) {
110
32.3k
          WORD32 idx = index[col];
111
112
32.3k
          ixheaacd_dec_interp_umx(m1_param->m1_param_real[row][col], rout_real_ptr,
113
32.3k
                                  m1_param_real_prev, pstr_mps_state);
114
32.3k
          ixheaacd_apply_abs_kernels(rout_real_ptr, rout_kernel_real_ptr, params);
115
116
32.3k
          p_v_real = p_buffer_real;
117
32.3k
          p_v_imag = p_buffer_imag;
118
119
32.3k
          p_x_re = p_x_real;
120
32.3k
          p_x_im = p_x_imag;
121
122
818k
          for (ts = 0; ts < time_slots; ts++) {
123
785k
            v_real = p_v_real;
124
785k
            v_imag = p_v_imag;
125
126
785k
            x_real = p_x_re;
127
785k
            x_imag = p_x_im;
128
129
32.8M
            for (qs = 0; qs < idx; qs++) {
130
32.1M
              temp_1 = ixheaacd_mps_mult32_shr_15(*x_real, *rout_kernel_real_ptr);
131
32.1M
              *v_real = *v_real + temp_1;
132
32.1M
              v_real++;
133
134
32.1M
              temp_1 = ixheaacd_mps_mult32_shr_15(*x_imag, *rout_kernel_real_ptr);
135
32.1M
              rout_kernel_real_ptr++;
136
32.1M
              *v_imag = *v_imag + temp_1;
137
32.1M
              v_imag++;
138
139
32.1M
              x_real++;
140
32.1M
              x_imag++;
141
32.1M
            }
142
785k
            rout_kernel_real_ptr += hyb_bands - idx;
143
144
785k
            p_v_real += MAX_HYBRID_BANDS;
145
785k
            p_v_imag += MAX_HYBRID_BANDS;
146
147
785k
            p_x_re += MAX_HYBRID_BANDS;
148
785k
            p_x_im += MAX_HYBRID_BANDS;
149
785k
          }
150
151
32.3k
          m1_param_real_prev += num_parameter_bands;
152
153
32.3k
          p_x_real += TSXHB;
154
32.3k
          p_x_imag += TSXHB;
155
52.4k
        } else {
156
52.4k
          m1_param_real_prev += num_parameter_bands;
157
158
52.4k
          p_x_real += TSXHB;
159
52.4k
          p_x_imag += TSXHB;
160
52.4k
        }
161
84.7k
      }
162
23.5k
      p_buffer_real += TSXHB;
163
23.5k
      p_buffer_imag += TSXHB;
164
23.5k
    }
165
10.9k
  } else {
166
96.9k
    for (row = 0; row < v_channels; row++) {
167
85.9k
      WORD32 *p_x_real = p_array_struct->x_real;
168
85.9k
      WORD32 *p_x_imag = p_array_struct->x_imag;
169
170
582k
      for (col = 0; col < x_channels; col++) {
171
496k
        if (pstr_mps_state->m1_param_present[row][col]) {
172
89.7k
          WORD32 idx = index[col];
173
174
89.7k
          ixheaacd_dec_interp_umx(m1_param->m1_param_real[row][col], rout_real_ptr,
175
89.7k
                                  m1_param_real_prev, pstr_mps_state);
176
89.7k
          ixheaacd_dec_interp_umx(m1_param->m1_param_imag[row][col], rout_imag_ptr,
177
89.7k
                                  m1_param_imag_prev, pstr_mps_state);
178
89.7k
          ixheaacd_apply_abs_kernels(rout_real_ptr, rout_kernel_real_ptr, params);
179
89.7k
          ixheaacd_apply_abs_kernels(rout_imag_ptr, rout_kernel_imag_ptr, params);
180
181
89.7k
          p_v_real = p_buffer_real;
182
89.7k
          p_v_imag = p_buffer_imag;
183
184
89.7k
          p_x_re = p_x_real;
185
89.7k
          p_x_im = p_x_imag;
186
187
2.85M
          for (ts = 0; ts < time_slots; ts++) {
188
2.76M
            v_real = p_v_real;
189
2.76M
            v_imag = p_v_imag;
190
191
2.76M
            x_real = p_x_re;
192
2.76M
            x_imag = p_x_im;
193
8.30M
            for (qs = 0; qs < 2; qs++) {
194
5.53M
              temp_1 = ixheaacd_mps_mult32_shr_15(*x_real, *rout_kernel_real_ptr);
195
5.53M
              temp_2 = ixheaacd_mps_mult32_shr_15(*x_imag, *rout_kernel_imag_ptr);
196
5.53M
              temp_1 += temp_2;
197
198
5.53M
              *v_real = *v_real + temp_1;
199
5.53M
              v_real++;
200
201
5.53M
              temp_1 = ixheaacd_mps_mult32_shr_15(*x_imag, *rout_kernel_real_ptr);
202
5.53M
              rout_kernel_real_ptr++;
203
5.53M
              temp_2 = ixheaacd_mps_mult32_shr_15(*x_real, *rout_kernel_imag_ptr);
204
5.53M
              rout_kernel_imag_ptr++;
205
5.53M
              temp_1 -= temp_2;
206
207
5.53M
              *v_imag = *v_imag + temp_1;
208
5.53M
              v_imag++;
209
210
5.53M
              x_real++;
211
5.53M
              x_imag++;
212
5.53M
            }
213
164M
            for (; qs < idx; qs++) {
214
162M
              temp_1 = ixheaacd_mps_mult32_shr_15(*x_real, *rout_kernel_real_ptr);
215
162M
              temp_2 = ixheaacd_mps_mult32_shr_15(*x_imag, *rout_kernel_imag_ptr);
216
162M
              temp_1 -= temp_2;
217
218
162M
              *v_real = *v_real + temp_1;
219
162M
              v_real++;
220
221
162M
              temp_1 = ixheaacd_mps_mult32_shr_15(*x_imag, *rout_kernel_real_ptr);
222
162M
              rout_kernel_real_ptr++;
223
162M
              temp_2 = ixheaacd_mps_mult32_shr_15(*x_real, *rout_kernel_imag_ptr);
224
162M
              rout_kernel_imag_ptr++;
225
162M
              temp_1 += temp_2;
226
227
162M
              *v_imag = *v_imag + temp_1;
228
162M
              v_imag++;
229
230
162M
              x_real++;
231
162M
              x_imag++;
232
162M
            }
233
2.76M
            rout_kernel_real_ptr += hyb_bands - idx;
234
2.76M
            rout_kernel_imag_ptr += hyb_bands - idx;
235
236
2.76M
            p_v_real += MAX_HYBRID_BANDS;
237
2.76M
            p_v_imag += MAX_HYBRID_BANDS;
238
239
2.76M
            p_x_re += MAX_HYBRID_BANDS;
240
2.76M
            p_x_im += MAX_HYBRID_BANDS;
241
2.76M
          }
242
243
89.7k
          m1_param_real_prev += num_parameter_bands;
244
89.7k
          m1_param_imag_prev += num_parameter_bands;
245
246
89.7k
          p_x_real += TSXHB;
247
89.7k
          p_x_imag += TSXHB;
248
407k
        } else {
249
407k
          m1_param_real_prev += num_parameter_bands;
250
407k
          m1_param_imag_prev += num_parameter_bands;
251
252
407k
          p_x_real += TSXHB;
253
407k
          p_x_imag += TSXHB;
254
407k
        }
255
496k
      }
256
85.9k
      p_buffer_real += TSXHB;
257
85.9k
      p_buffer_imag += TSXHB;
258
85.9k
    }
259
10.9k
  }
260
14.7k
  return;
261
14.7k
}