Coverage Report

Created: 2025-12-08 06:50

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libxaac/decoder/ixheaacd_mps_res_tns.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 "ixheaac_constants.h"
22
#include "ixheaac_basic_ops32.h"
23
#include "ixheaac_basic_ops16.h"
24
#include "ixheaac_basic_ops40.h"
25
#include "ixheaac_basic_ops.h"
26
#include "ixheaacd_defines.h"
27
28
VOID ixheaacd_res_tns_parcor_2_lpc_32x16(WORD16 *parcor, WORD16 *lpc, WORD16 *scale, WORD order)
29
30
449
{
31
449
  WORD i, j, status;
32
449
  WORD32 z1;
33
449
  WORD16 z[MAX_ORDER + 1];
34
449
  WORD16 w[MAX_ORDER + 1];
35
449
  WORD32 accu1, accu2;
36
37
449
  status = 1;
38
449
  *scale = 0;
39
1.48k
  while (status) {
40
1.03k
    status = 0;
41
42
34.1k
    for (i = MAX_ORDER; i >= 0; i--) {
43
33.1k
      z[i] = 0;
44
33.1k
      w[i] = 0;
45
33.1k
    }
46
47
1.03k
    accu1 = (0x7fffffff >> *scale);
48
49
7.19k
    for (i = 0; i <= order; i++) {
50
6.16k
      z1 = accu1;
51
52
48.8k
      for (j = 0; j < order; j++) {
53
42.6k
        w[j] = ixheaac_round16(accu1);
54
55
42.6k
        accu1 = ixheaac_mac16x16in32_shl_sat(accu1, parcor[j], z[j]);
56
42.6k
        if (ixheaac_abs32_sat(accu1) == 0x7fffffff) status = 1;
57
42.6k
      }
58
48.8k
      for (j = (order - 1); j >= 0; j--) {
59
42.6k
        accu2 = ixheaac_deposit16h_in32(z[j]);
60
42.6k
        accu2 = ixheaac_mac16x16in32_shl_sat(accu2, parcor[j], w[j]);
61
42.6k
        z[j + 1] = ixheaac_round16(accu2);
62
42.6k
        if (ixheaac_abs32_sat(accu2) == 0x7fffffff) status = 1;
63
42.6k
      }
64
65
6.16k
      z[0] = ixheaac_round16(z1);
66
6.16k
      lpc[i] = ixheaac_round16(accu1);
67
6.16k
      accu1 = 0;
68
6.16k
    }
69
1.03k
    accu1 = (status - 1);
70
1.03k
    if (accu1 == 0) {
71
586
      *scale = *scale + 1;
72
586
    }
73
1.03k
  }
74
449
}
75
76
VOID ixheaacd_res_tns_ar_filter_fixed_32x16(WORD32 *spectrum, WORD32 size, WORD32 inc,
77
                                            WORD16 *lpc, WORD32 order, WORD32 shift_value,
78
449
                                            WORD scale_spec) {
79
449
  WORD32 i, j;
80
449
  WORD32 y, state[MAX_ORDER + 1];
81
82
449
  if ((order & 3) != 0) {
83
750
    for (i = order + 1; i < ((WORD32)(order & 0xfffffffc) + 4); i++) {
84
371
      lpc[i] = 0;
85
371
    }
86
379
    lpc[i] = 0;
87
379
    order = ((order & 0xfffffffc) + 4);
88
379
    order = order & 31;
89
379
  }
90
91
3.15k
  for (i = 0; i < order; i++) {
92
2.70k
    y = (*spectrum) << scale_spec;
93
10.8k
    for (j = i; j > 0; j--) {
94
8.15k
      y = ixheaac_sub32_sat(y, ixheaac_mult32x16in32_shl_sat(state[j - 1], lpc[j]));
95
8.15k
      state[j] = state[j - 1];
96
8.15k
    }
97
98
2.70k
    state[0] = ixheaac_shl32_dir_sat_limit(y, shift_value);
99
2.70k
    *spectrum = y >> scale_spec;
100
2.70k
    spectrum += inc;
101
2.70k
  }
102
103
29.6k
  for (i = order; i < size; i++) {
104
29.2k
    y = (*spectrum) << scale_spec;
105
106
240k
    for (j = order; j > 0; j--) {
107
211k
      y = ixheaac_sub32_sat(y, ixheaac_mult32x16in32_shl_sat(state[j - 1], lpc[j]));
108
211k
      state[j] = state[j - 1];
109
211k
    }
110
111
29.2k
    state[0] = ixheaac_shl32_dir_sat_limit(y, shift_value);
112
29.2k
    *spectrum = y >> scale_spec;
113
29.2k
    spectrum += inc;
114
29.2k
  }
115
449
}
116
117
449
WORD32 ixheaacd_res_calc_max_spectral_line(WORD32 *p_tmp, WORD32 size) {
118
449
  WORD32 max_spectral_line = 0, i;
119
449
  WORD count, remaining, temp_1, temp_2, temp3, temp4;
120
121
449
  count = size >> 3;
122
4.29k
  for (i = count; i--;) {
123
3.84k
    temp_1 = *p_tmp++;
124
3.84k
    temp_2 = *p_tmp++;
125
3.84k
    temp3 = *p_tmp++;
126
3.84k
    temp4 = *p_tmp++;
127
128
3.84k
    max_spectral_line = ixheaac_abs32_nrm(temp_1) | max_spectral_line;
129
3.84k
    max_spectral_line = ixheaac_abs32_nrm(temp_2) | max_spectral_line;
130
3.84k
    max_spectral_line = ixheaac_abs32_nrm(temp3) | max_spectral_line;
131
3.84k
    max_spectral_line = ixheaac_abs32_nrm(temp4) | max_spectral_line;
132
3.84k
    temp_1 = *p_tmp++;
133
3.84k
    temp_2 = *p_tmp++;
134
3.84k
    temp3 = *p_tmp++;
135
3.84k
    temp4 = *p_tmp++;
136
137
3.84k
    max_spectral_line = ixheaac_abs32_nrm(temp_1) | max_spectral_line;
138
3.84k
    max_spectral_line = ixheaac_abs32_nrm(temp_2) | max_spectral_line;
139
3.84k
    max_spectral_line = ixheaac_abs32_nrm(temp3) | max_spectral_line;
140
3.84k
    max_spectral_line = ixheaac_abs32_nrm(temp4) | max_spectral_line;
141
3.84k
  }
142
143
449
  remaining = size - (count << 3);
144
449
  if (remaining) {
145
1.46k
    for (i = remaining; i--;) {
146
1.16k
      max_spectral_line = ixheaac_abs32_nrm(*p_tmp) | max_spectral_line;
147
1.16k
      p_tmp++;
148
1.16k
    }
149
292
  }
150
151
449
  return ixheaac_norm32(max_spectral_line);
152
449
}