Coverage Report

Created: 2026-01-09 06:51

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libxaac/encoder/ixheaace_calc_ms_band_energy.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 <string.h>
22
23
#include "ixheaac_type_def.h"
24
#include "ixheaace_aac_constants.h"
25
26
#include "ixheaace_calc_ms_band_energy.h"
27
28
VOID ia_enhaacplus_enc_calc_band_energy(const FLOAT32 *ptr_spec_coeffs,
29
                                        const WORD32 *ptr_band_offset, const WORD32 num_bands,
30
                                        FLOAT32 *ptr_band_energy, WORD32 sfb_count,
31
1.32M
                                        FLOAT32 *ptr_band_energy_sum) {
32
1.32M
  WORD32 i, j;
33
34
1.32M
  j = 0;
35
1.32M
  memset(ptr_band_energy, 0, sfb_count * sizeof(*ptr_band_energy));
36
1.32M
  *ptr_band_energy_sum = 0;
37
38
25.4M
  for (i = 0; i < num_bands; i++) {
39
292M
    while (j < ptr_band_offset[i + 1]) {
40
268M
      ptr_band_energy[i] += (FLOAT32)((FLOAT64)ptr_spec_coeffs[j] * ptr_spec_coeffs[j]);
41
268M
      j++;
42
268M
    }
43
24.0M
    *ptr_band_energy_sum = *ptr_band_energy_sum + ptr_band_energy[i];
44
24.0M
  }
45
1.32M
}
46
47
VOID ia_enhaacplus_enc_calc_band_energy_ms(
48
    const FLOAT32 *ptr_mdct_spectrum_left_fix, const FLOAT32 *ptr_mdct_spectrum_right_fix,
49
    const WORD32 *ptr_sfb_offset, const WORD32 num_sfb_active, const WORD32 num_sfb_total,
50
    FLOAT32 *ptr_band_nrg_mid, FLOAT32 *ptr_band_nrg_mid_sum, FLOAT32 *ptr_band_nrg_side,
51
349k
    FLOAT32 *ptr_band_nrg_side_sum) {
52
349k
  WORD32 i;
53
349k
  const FLOAT32 *ptr_spec_left = ptr_mdct_spectrum_left_fix;
54
349k
  const FLOAT32 *ptr_spec_right = ptr_mdct_spectrum_right_fix;
55
56
349k
  *ptr_band_nrg_mid_sum = 0;
57
349k
  *ptr_band_nrg_side_sum = 0;
58
59
5.92M
  for (i = 0; i < num_sfb_active; i++) {
60
5.57M
    WORD16 offset = (WORD16)(ptr_sfb_offset[i + 1] - ptr_sfb_offset[i]);
61
5.57M
    FLOAT32 band_nrgy_mid = 0, band_nrg_side = 0;
62
5.57M
    ptr_band_nrg_mid[i] = 0;
63
5.57M
    ptr_band_nrg_side[i] = 0;
64
5.57M
    FLOAT32 spec_mid, spec_side;
65
5.57M
    FLOAT32 temp_mid, temp_side;
66
67
64.2M
    while (offset--) {
68
58.6M
      spec_mid = (*ptr_spec_left + *ptr_spec_right) * 0.5f;
69
58.6M
      spec_side = (*ptr_spec_left++ - *ptr_spec_right++) * 0.5f;
70
71
58.6M
      temp_mid = (spec_mid * spec_mid);
72
58.6M
      temp_side = (spec_side * spec_side);
73
74
58.6M
      band_nrgy_mid = (band_nrgy_mid + temp_mid);
75
58.6M
      band_nrg_side = (band_nrg_side + temp_side);
76
58.6M
    }
77
78
5.57M
    ptr_band_nrg_mid[i] = band_nrgy_mid;
79
5.57M
    ptr_band_nrg_side[i] = band_nrg_side;
80
81
5.57M
    *ptr_band_nrg_mid_sum += ptr_band_nrg_mid[i];
82
5.57M
    *ptr_band_nrg_side_sum += ptr_band_nrg_side[i];
83
5.57M
  }
84
85
349k
  memset(&ptr_band_nrg_mid[num_sfb_active], 0,
86
349k
         (num_sfb_total - num_sfb_active) * sizeof(*ptr_band_nrg_mid));
87
349k
  memset(&ptr_band_nrg_side[num_sfb_active], 0,
88
349k
         (num_sfb_total - num_sfb_active) * sizeof(*ptr_band_nrg_side));
89
349k
}