Coverage Report

Created: 2026-01-17 06:57

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
465
{
31
465
  WORD i, j, status;
32
465
  WORD32 z1;
33
465
  WORD16 z[MAX_ORDER + 1];
34
465
  WORD16 w[MAX_ORDER + 1];
35
465
  WORD32 accu1, accu2;
36
37
465
  status = 1;
38
465
  *scale = 0;
39
1.59k
  while (status) {
40
1.12k
    status = 0;
41
42
37.1k
    for (i = MAX_ORDER; i >= 0; i--) {
43
36.0k
      z[i] = 0;
44
36.0k
      w[i] = 0;
45
36.0k
    }
46
47
1.12k
    accu1 = (0x7fffffff >> *scale);
48
49
7.87k
    for (i = 0; i <= order; i++) {
50
6.74k
      z1 = accu1;
51
52
51.1k
      for (j = 0; j < order; j++) {
53
44.3k
        w[j] = ixheaac_round16(accu1);
54
55
44.3k
        accu1 = ixheaac_mac16x16in32_shl_sat(accu1, parcor[j], z[j]);
56
44.3k
        if (ixheaac_abs32_sat(accu1) == 0x7fffffff) status = 1;
57
44.3k
      }
58
51.1k
      for (j = (order - 1); j >= 0; j--) {
59
44.3k
        accu2 = ixheaac_deposit16h_in32(z[j]);
60
44.3k
        accu2 = ixheaac_mac16x16in32_shl_sat(accu2, parcor[j], w[j]);
61
44.3k
        z[j + 1] = ixheaac_round16(accu2);
62
44.3k
        if (ixheaac_abs32_sat(accu2) == 0x7fffffff) status = 1;
63
44.3k
      }
64
65
6.74k
      z[0] = ixheaac_round16(z1);
66
6.74k
      lpc[i] = ixheaac_round16(accu1);
67
6.74k
      accu1 = 0;
68
6.74k
    }
69
1.12k
    accu1 = (status - 1);
70
1.12k
    if (accu1 == 0) {
71
661
      *scale = *scale + 1;
72
661
    }
73
1.12k
  }
74
465
}
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
465
                                            WORD scale_spec) {
79
465
  WORD32 i, j;
80
465
  WORD32 y, state[MAX_ORDER + 1];
81
82
465
  if ((order & 3) != 0) {
83
683
    for (i = order + 1; i < ((WORD32)(order & 0xfffffffc) + 4); i++) {
84
332
      lpc[i] = 0;
85
332
    }
86
351
    lpc[i] = 0;
87
351
    order = ((order & 0xfffffffc) + 4);
88
351
    order = order & 31;
89
351
  }
90
91
3.21k
  for (i = 0; i < order; i++) {
92
2.74k
    y = (*spectrum) << scale_spec;
93
10.7k
    for (j = i; j > 0; j--) {
94
8.04k
      y = ixheaac_sub32_sat(y, ixheaac_mult32x16in32_shl_sat(state[j - 1], lpc[j]));
95
8.04k
      state[j] = state[j - 1];
96
8.04k
    }
97
98
2.74k
    state[0] = ixheaac_shl32_dir_sat_limit(y, shift_value);
99
2.74k
    *spectrum = y >> scale_spec;
100
2.74k
    spectrum += inc;
101
2.74k
  }
102
103
36.2k
  for (i = order; i < size; i++) {
104
35.8k
    y = (*spectrum) << scale_spec;
105
106
274k
    for (j = order; j > 0; j--) {
107
239k
      y = ixheaac_sub32_sat(y, ixheaac_mult32x16in32_shl_sat(state[j - 1], lpc[j]));
108
239k
      state[j] = state[j - 1];
109
239k
    }
110
111
35.8k
    state[0] = ixheaac_shl32_dir_sat_limit(y, shift_value);
112
35.8k
    *spectrum = y >> scale_spec;
113
35.8k
    spectrum += inc;
114
35.8k
  }
115
465
}
116
117
465
WORD32 ixheaacd_res_calc_max_spectral_line(WORD32 *p_tmp, WORD32 size) {
118
465
  WORD32 max_spectral_line = 0, i;
119
465
  WORD count, remaining, temp_1, temp_2, temp3, temp4;
120
121
465
  count = size >> 3;
122
5.13k
  for (i = count; i--;) {
123
4.66k
    temp_1 = *p_tmp++;
124
4.66k
    temp_2 = *p_tmp++;
125
4.66k
    temp3 = *p_tmp++;
126
4.66k
    temp4 = *p_tmp++;
127
128
4.66k
    max_spectral_line = ixheaac_abs32_nrm(temp_1) | max_spectral_line;
129
4.66k
    max_spectral_line = ixheaac_abs32_nrm(temp_2) | max_spectral_line;
130
4.66k
    max_spectral_line = ixheaac_abs32_nrm(temp3) | max_spectral_line;
131
4.66k
    max_spectral_line = ixheaac_abs32_nrm(temp4) | max_spectral_line;
132
4.66k
    temp_1 = *p_tmp++;
133
4.66k
    temp_2 = *p_tmp++;
134
4.66k
    temp3 = *p_tmp++;
135
4.66k
    temp4 = *p_tmp++;
136
137
4.66k
    max_spectral_line = ixheaac_abs32_nrm(temp_1) | max_spectral_line;
138
4.66k
    max_spectral_line = ixheaac_abs32_nrm(temp_2) | max_spectral_line;
139
4.66k
    max_spectral_line = ixheaac_abs32_nrm(temp3) | max_spectral_line;
140
4.66k
    max_spectral_line = ixheaac_abs32_nrm(temp4) | max_spectral_line;
141
4.66k
  }
142
143
465
  remaining = size - (count << 3);
144
465
  if (remaining) {
145
1.51k
    for (i = remaining; i--;) {
146
1.20k
      max_spectral_line = ixheaac_abs32_nrm(*p_tmp) | max_spectral_line;
147
1.20k
      p_tmp++;
148
1.20k
    }
149
302
  }
150
151
465
  return ixheaac_norm32(max_spectral_line);
152
465
}