Coverage Report

Created: 2025-09-17 07:02

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libxaac/encoder/ixheaace_radix2_fft.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 <math.h>
22
#include "ixheaac_type_def.h"
23
#include "ixheaac_constants.h"
24
#include "ixheaace_aac_constants.h"
25
#include "ixheaace_psy_const.h"
26
#include "ixheaace_tns.h"
27
#include "ixheaace_tns_params.h"
28
#include "ixheaace_rom.h"
29
#include "ixheaace_common_rom.h"
30
#include "ixheaace_bitbuffer.h"
31
32
static VOID ia_enhaacplus_enc_ps_fft(complex *out, LOOPINDEX N, WORD32 nob,
33
6.20M
                                     ixheaace_common_tables *comm_tab_ptr) {
34
6.20M
  LOOPINDEX block_per_stage, stage_num, inner;
35
36
6.20M
  WORD32 index_1, index_2, tab_modifier;
37
6.20M
  WORD32 len, increment, i;
38
39
6.20M
  FLOAT32 cos_val;
40
6.20M
  FLOAT32 sin_val;
41
42
6.20M
  WORD16 index1;
43
6.20M
  FLOAT32 re_temp, re_temp2;
44
6.20M
  FLOAT32 im_temp, im_temp2;
45
6.20M
  FLOAT32 *out1_w32, *out2_w32;
46
47
6.20M
  len = N >> 1;
48
6.20M
  index_1 = 0;
49
50
6.20M
  out1_w32 = (FLOAT32 *)&out[index_1];
51
6.20M
  out2_w32 = (FLOAT32 *)&out[index_1 + 1];
52
53
22.7M
  for (block_per_stage = len - 1; block_per_stage >= 0; block_per_stage--) {
54
16.5M
    re_temp = out1_w32[0];
55
16.5M
    im_temp = out1_w32[1];
56
57
16.5M
    re_temp2 = out2_w32[0];
58
16.5M
    im_temp2 = out2_w32[1];
59
60
16.5M
    out1_w32[0] = re_temp + re_temp2;
61
16.5M
    out1_w32[1] = im_temp + im_temp2;
62
63
16.5M
    out2_w32[0] = re_temp - re_temp2;
64
16.5M
    out2_w32[1] = im_temp - im_temp2;
65
66
16.5M
    out1_w32 += 4;
67
16.5M
    out2_w32 += 4;
68
16.5M
  }
69
70
6.20M
  if (nob == 3) {
71
2.06M
    i = 2; /* used for dist calculation*/
72
2.06M
    increment = 1;
73
2.06M
    tab_modifier = 2;
74
6.20M
    for (stage_num = 1; stage_num >= 0; stage_num--) {
75
4.13M
      len = len >> 1;
76
4.13M
      index_1 = 0;
77
4.13M
      increment += 1;
78
79
4.13M
      tab_modifier--;
80
81
10.3M
      for (block_per_stage = len - 1; block_per_stage >= 0; block_per_stage--) {
82
6.20M
        index_2 = index_1 + i;
83
84
6.20M
        out1_w32 = (FLOAT32 *)&out[index_1];
85
6.20M
        out2_w32 = (FLOAT32 *)&out[index_2];
86
87
6.20M
        re_temp = out1_w32[0];
88
6.20M
        im_temp = out1_w32[1];
89
90
6.20M
        re_temp2 = out2_w32[0];
91
6.20M
        im_temp2 = out2_w32[1];
92
93
6.20M
        out1_w32[0] = re_temp + re_temp2;
94
6.20M
        out1_w32[1] = im_temp + im_temp2;
95
96
6.20M
        out2_w32[0] = re_temp - re_temp2;
97
6.20M
        out2_w32[1] = im_temp - im_temp2;
98
99
6.20M
        index1 = (WORD16)tab_modifier;
100
101
6.20M
        out1_w32 += 2;
102
6.20M
        out2_w32 += 2;
103
104
16.5M
        for (inner = 0; inner < (2 * i - 2); inner += 2) {
105
10.3M
          cos_val = comm_tab_ptr->cos_arr[index1];
106
10.3M
          sin_val = comm_tab_ptr->sin_arr[index1];
107
108
10.3M
          index1++;
109
110
10.3M
          re_temp = (out2_w32[inner] * cos_val) + (out2_w32[inner + 1] * sin_val);
111
10.3M
          im_temp = (out2_w32[inner + 1] * cos_val) - (out2_w32[inner] * sin_val);
112
113
10.3M
          re_temp2 = out1_w32[inner];
114
10.3M
          im_temp2 = out1_w32[inner + 1];
115
116
10.3M
          out1_w32[inner] = re_temp2 + re_temp;
117
10.3M
          out1_w32[inner + 1] = im_temp2 + im_temp;
118
119
10.3M
          out2_w32[inner] = re_temp2 - re_temp;
120
10.3M
          out2_w32[inner + 1] = im_temp2 - im_temp;
121
10.3M
        }
122
123
6.20M
        index_1 += (WORD32)pow(2, increment);
124
6.20M
      }
125
4.13M
      i <<= 1;
126
4.13M
    }
127
4.13M
  } else {
128
4.13M
    out1_w32 = (FLOAT32 *)&out[0];
129
4.13M
    out2_w32 = (FLOAT32 *)&out[2];
130
131
4.13M
    re_temp = out1_w32[0];
132
4.13M
    im_temp = out1_w32[1];
133
134
4.13M
    re_temp2 = out2_w32[0];
135
4.13M
    im_temp2 = out2_w32[1];
136
137
4.13M
    out1_w32[0] = re_temp + re_temp2;
138
4.13M
    out1_w32[1] = im_temp + im_temp2;
139
140
4.13M
    out2_w32[0] = re_temp - re_temp2;
141
4.13M
    out2_w32[1] = im_temp - im_temp2;
142
143
4.13M
    out1_w32 += 2;
144
4.13M
    out2_w32 += 2;
145
146
4.13M
    sin_val = comm_tab_ptr->sin_arr[1];
147
148
4.13M
    re_temp = out2_w32[1] * sin_val;
149
4.13M
    im_temp = out2_w32[0] * sin_val;
150
151
4.13M
    re_temp2 = out1_w32[0];
152
4.13M
    im_temp2 = out1_w32[1];
153
154
4.13M
    out1_w32[0] = re_temp2 + re_temp;
155
4.13M
    out1_w32[1] = im_temp2 - im_temp;
156
157
4.13M
    out2_w32[0] = re_temp2 - re_temp;
158
4.13M
    out2_w32[1] = im_temp2 + im_temp;
159
4.13M
  }
160
6.20M
}
161
162
6.20M
VOID ia_enhaacplus_enc_fft(complex *out, WORD32 N, ixheaace_common_tables *pstr_common_tab) {
163
6.20M
  WORD32 nob;
164
6.20M
  WORD32 len;
165
166
  /* time domain samples obtained with bit reversal*/
167
6.20M
  len = N;
168
169
6.20M
  if (len == 8) {
170
2.06M
    nob = 3;
171
4.13M
  } else {
172
4.13M
    nob = 2;
173
4.13M
  }
174
6.20M
  ia_enhaacplus_enc_ps_fft(out, N, nob, pstr_common_tab);
175
6.20M
}