Coverage Report

Created: 2026-01-25 06:51

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libxaac/encoder/ixheaace_mps_dct.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
21
#include "ixheaac_type_def.h"
22
#include "ixheaace_error_codes.h"
23
#include "ixheaac_error_standards.h"
24
#include "ixheaace_mps_common_fix.h"
25
#include "ixheaace_mps_defines.h"
26
#include "ixheaace_mps_common_define.h"
27
#include "ixheaace_bitbuffer.h"
28
29
#include "ixheaace_psy_const.h"
30
#include "ixheaace_tns.h"
31
#include "ixheaace_tns_params.h"
32
#include "ixheaace_rom.h"
33
#include "ixheaace_common_rom.h"
34
#include "ixheaace_fft.h"
35
36
#include "ixheaace_mps_dct.h"
37
#include "ixheaace_mps_buf.h"
38
#include "ixheaace_mps_lib.h"
39
#include "ixheaace_mps_main_structure.h"
40
41
#include "ixheaace_mps_bitstream.h"
42
#include "ixheaace_mps_frame_windowing.h"
43
#include "ixheaace_mps_param_extract.h"
44
#include "ixheaace_mps_static_gain.h"
45
#include "ixheaace_mps_filter.h"
46
#include "ixheaace_mps_delay.h"
47
#include "ixheaace_mps_dmx_tdom_enh.h"
48
#include "ixheaace_mps_tools_rom.h"
49
50
5.90M
IA_ERRORCODE ixheaace_mps_212_dct_iv(FLOAT32 *ptr_data, WORD32 length, WORD8 *ptr_scratch) {
51
5.90M
  WORD32 sin_step = 0;
52
5.90M
  WORD32 length_by_2 = length >> 1;
53
5.90M
  WORD32 step, idx;
54
5.90M
  FLOAT32 accu_1, accu_2, accu_3, accu_4;
55
5.90M
  FLOAT32 *ptr_data_0;
56
5.90M
  FLOAT32 *ptr_data_1;
57
5.90M
  const ixheaace_cmplx_str *ptr_cmplx_twiddle;
58
5.90M
  const ixheaace_cmplx_str *ptr_cmplx_sin_twiddle;
59
5.90M
  ixheaace_scratch_mem *pstr_scratch = (ixheaace_scratch_mem *)ptr_scratch;
60
61
5.90M
  if (length == 64) {
62
5.90M
    ptr_cmplx_twiddle = sine_window_64;
63
5.90M
    ptr_cmplx_sin_twiddle = sine_table_1024;
64
5.90M
    sin_step = 32;
65
5.90M
  } else {
66
0
    ptr_cmplx_twiddle = sine_window_32;
67
0
    ptr_cmplx_sin_twiddle = sine_table_1024;
68
0
    sin_step = 64;
69
0
  }
70
71
5.90M
  ptr_data_0 = &ptr_data[0];
72
5.90M
  ptr_data_1 = &ptr_data[length - 2];
73
100M
  for (idx = 0; idx < length_by_2 - 1; idx += 2, ptr_data_0 += 2, ptr_data_1 -= 2) {
74
94.4M
    accu_1 =
75
94.4M
        (ptr_data_1[1] * ptr_cmplx_twiddle[idx].re) - (ptr_data_0[0] * ptr_cmplx_twiddle[idx].im);
76
94.4M
    accu_2 =
77
94.4M
        (ptr_data_1[1] * ptr_cmplx_twiddle[idx].im) + (ptr_data_0[0] * ptr_cmplx_twiddle[idx].re);
78
94.4M
    accu_3 = (ptr_data_1[0] * ptr_cmplx_twiddle[idx + 1].re) -
79
94.4M
             (ptr_data_0[1] * ptr_cmplx_twiddle[idx + 1].im);
80
94.4M
    accu_4 = (ptr_data_1[0] * ptr_cmplx_twiddle[idx + 1].im) +
81
94.4M
             (ptr_data_0[1] * ptr_cmplx_twiddle[idx + 1].re);
82
83
94.4M
    ptr_data_0[0] = accu_2 / 4;
84
94.4M
    ptr_data_0[1] = accu_1 / 4;
85
94.4M
    ptr_data_1[0] = accu_4 / 4;
86
94.4M
    ptr_data_1[1] = -(accu_3 / 4);
87
94.4M
  }
88
5.90M
  ia_enhaacplus_enc_complex_fft(ptr_data, length_by_2, pstr_scratch);
89
5.90M
  if (length_by_2 == 32) {
90
383M
    for (idx = 0; idx < length; idx++) {
91
377M
      ptr_data[idx] = (ptr_data[idx] / (1 << (4)));
92
377M
    }
93
5.90M
  } else {
94
0
    for (idx = 0; idx < length; idx++) {
95
0
      ptr_data[idx] = (ptr_data[idx] / (1 << (3)));
96
0
    }
97
0
  }
98
99
5.90M
  ptr_data_0 = &ptr_data[0];
100
5.90M
  ptr_data_1 = &ptr_data[length - 2];
101
5.90M
  accu_1 = ptr_data_1[0];
102
5.90M
  accu_2 = ptr_data_1[1];
103
5.90M
  ptr_data_1[1] = -ptr_data_0[1];
104
105
94.4M
  for (step = sin_step, idx = 1; idx<(length_by_2 + 1)>> 1; idx++, step += sin_step) {
106
88.5M
    ixheaace_cmplx_str twd = ptr_cmplx_sin_twiddle[step];
107
88.5M
    accu_3 = (accu_1 * twd.re) - (accu_2 * twd.im);
108
88.5M
    accu_4 = (accu_1 * twd.im) + (accu_2 * twd.re);
109
88.5M
    ptr_data_0[1] = accu_3;
110
88.5M
    ptr_data_1[0] = accu_4;
111
112
88.5M
    ptr_data_0 += 2;
113
88.5M
    ptr_data_1 -= 2;
114
115
88.5M
    accu_3 = (ptr_data_0[1] * twd.re) - (ptr_data_0[0] * twd.im);
116
88.5M
    accu_4 = (ptr_data_0[1] * twd.im) + (ptr_data_0[0] * twd.re);
117
88.5M
    accu_1 = ptr_data_1[0];
118
88.5M
    accu_2 = ptr_data_1[1];
119
120
88.5M
    ptr_data_1[1] = -accu_3;
121
88.5M
    ptr_data_0[0] = accu_4;
122
88.5M
  }
123
5.90M
  accu_1 = (accu_1 * SQUARE_ROOT_TWO);
124
5.90M
  accu_2 = (accu_2 * SQUARE_ROOT_TWO);
125
126
5.90M
  ptr_data_1[0] = (accu_1 + accu_2) / 2;
127
5.90M
  ptr_data_0[1] = (accu_1 - accu_2) / 2;
128
129
5.90M
  return IA_NO_ERROR;
130
5.90M
}
131
132
5.90M
IA_ERRORCODE ixheaace_mps_212_dst_iv(FLOAT32 *ptr_data, WORD32 length, WORD8 *ptr_scratch) {
133
5.90M
  WORD32 sin_step = 0;
134
5.90M
  WORD32 step, idx;
135
5.90M
  WORD32 length_by_2 = length >> 1;
136
5.90M
  FLOAT32 accu_1, accu_2, accu_3, accu_4;
137
5.90M
  FLOAT32 *ptr_data_0;
138
5.90M
  FLOAT32 *ptr_data_1;
139
5.90M
  const ixheaace_cmplx_str *ptr_cmplx_twiddle;
140
5.90M
  const ixheaace_cmplx_str *ptr_cmplx_sin_twiddle;
141
5.90M
  ixheaace_scratch_mem *pstr_scratch = (ixheaace_scratch_mem *)ptr_scratch;
142
5.90M
  if (length == 64) {
143
5.90M
    ptr_cmplx_twiddle = sine_window_64;
144
5.90M
    ptr_cmplx_sin_twiddle = sine_table_1024;
145
5.90M
    sin_step = 32;
146
5.90M
  } else {
147
0
    ptr_cmplx_twiddle = sine_window_32;
148
0
    ptr_cmplx_sin_twiddle = sine_table_1024;
149
0
    sin_step = 64;
150
0
  }
151
152
5.90M
  ptr_data_0 = &ptr_data[0];
153
5.90M
  ptr_data_1 = &ptr_data[length - 2];
154
100M
  for (idx = 0; idx < length_by_2 - 1; idx += 2, ptr_data_0 += 2, ptr_data_1 -= 2) {
155
94.4M
    accu_1 = (ptr_data_1[1] * ptr_cmplx_twiddle[idx].re) -
156
94.4M
             ((-ptr_data_0[0]) * ptr_cmplx_twiddle[idx].im);
157
94.4M
    accu_2 = (ptr_data_1[1] * ptr_cmplx_twiddle[idx].im) +
158
94.4M
             ((-ptr_data_0[0]) * ptr_cmplx_twiddle[idx].re);
159
94.4M
    accu_3 = ((-ptr_data_1[0]) * ptr_cmplx_twiddle[idx + 1].re) -
160
94.4M
             (ptr_data_0[1] * ptr_cmplx_twiddle[idx + 1].im);
161
94.4M
    accu_4 = ((-ptr_data_1[0]) * ptr_cmplx_twiddle[idx + 1].im) +
162
94.4M
             (ptr_data_0[1] * ptr_cmplx_twiddle[idx + 1].re);
163
94.4M
    ptr_data_0[0] = accu_2 / 4;
164
94.4M
    ptr_data_0[1] = accu_1 / 4;
165
94.4M
    ptr_data_1[0] = accu_4 / 4;
166
94.4M
    ptr_data_1[1] = -(accu_3) / 4;
167
94.4M
  }
168
5.90M
  ia_enhaacplus_enc_complex_fft(ptr_data, length_by_2, pstr_scratch);
169
5.90M
  if (length_by_2 == 32) {
170
383M
    for (idx = 0; idx < length; idx++) {
171
377M
      ptr_data[idx] = (ptr_data[idx] / (1 << (4)));
172
377M
    }
173
5.90M
  } else {
174
0
    for (idx = 0; idx < length; idx++) {
175
0
      ptr_data[idx] = (ptr_data[idx] / (1 << (3)));
176
0
    }
177
0
  }
178
5.90M
  ptr_data_0 = &ptr_data[0];
179
5.90M
  ptr_data_1 = &ptr_data[length - 2];
180
5.90M
  accu_1 = ptr_data_1[0];
181
5.90M
  accu_2 = ptr_data_1[1];
182
5.90M
  ptr_data_1[1] = -ptr_data_0[0];
183
5.90M
  ptr_data_0[0] = ptr_data_0[1];
184
185
94.4M
  for (step = sin_step, idx = 1; idx<(length_by_2 + 1)>> 1; idx++, step += sin_step) {
186
88.5M
    ixheaace_cmplx_str twd = ptr_cmplx_sin_twiddle[step];
187
188
88.5M
    accu_3 = (accu_1 * twd.re) - (accu_2 * twd.im);
189
88.5M
    accu_4 = (accu_1 * twd.im) + (accu_2 * twd.re);
190
88.5M
    ptr_data_1[0] = -accu_3;
191
88.5M
    ptr_data_0[1] = -accu_4;
192
193
88.5M
    ptr_data_0 += 2;
194
88.5M
    ptr_data_1 -= 2;
195
196
88.5M
    accu_3 = (ptr_data_0[1] * twd.re) - (ptr_data_0[0] * twd.im);
197
88.5M
    accu_4 = (ptr_data_0[1] * twd.im) + (ptr_data_0[0] * twd.re);
198
88.5M
    accu_1 = ptr_data_1[0];
199
88.5M
    accu_2 = ptr_data_1[1];
200
201
88.5M
    ptr_data_0[0] = accu_3;
202
88.5M
    ptr_data_1[1] = -accu_4;
203
88.5M
  }
204
205
5.90M
  accu_1 = (accu_1 * SQUARE_ROOT_TWO);
206
5.90M
  accu_2 = (accu_2 * SQUARE_ROOT_TWO);
207
5.90M
  ptr_data_1[0] = (accu_1 + accu_2) / 2;
208
5.90M
  ptr_data_0[1] = (accu_1 - accu_2) / 2;
209
210
5.90M
  return IA_NO_ERROR;
211
5.90M
}