Coverage Report

Created: 2025-10-10 06:12

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libxaac/encoder/ixheaace_mps_static_gain.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 <stdlib.h>
23
#include <string.h>
24
#include "ixheaac_type_def.h"
25
#include "ixheaac_error_standards.h"
26
#include "ixheaace_error_codes.h"
27
#include "ixheaace_mps_common_fix.h"
28
#include "ixheaace_mps_defines.h"
29
#include "ixheaace_mps_common_define.h"
30
#include "ixheaace_bitbuffer.h"
31
32
#include "ixheaace_mps_static_gain.h"
33
#include "ixheaace_mps_bitstream.h"
34
#include "ixheaace_mps_struct_def.h"
35
#include "ixheaace_mps_sac_polyphase.h"
36
#include "ixheaace_mps_sac_nlc_enc.h"
37
#include "ixheaace_mps_sac_hybfilter.h"
38
#include "ixheaace_mps_spatial_bitstream.h"
39
#include "ixheaace_mps_param_extract.h"
40
#include "ixheaace_mps_tree.h"
41
#include "ixheaace_mps_rom.h"
42
43
IA_ERRORCODE ixheaace_mps_212_static_gain_init(
44
    ixheaace_mps_pstr_static_gain pstr_static_gain,
45
1.49k
    const ixheaace_mps_pstr_static_gain_config pstr_static_gain_config) {
46
1.49k
  IA_ERRORCODE error = IA_NO_ERROR;
47
1.49k
  FLOAT32 pre_gain_factor;
48
1.49k
  pstr_static_gain->fixed_gain_dmx = pstr_static_gain_config->fixed_gain_dmx;
49
1.49k
  pstr_static_gain->pre_gain_factor_db = pstr_static_gain_config->pre_gain_factor_db;
50
51
1.49k
  if ((pstr_static_gain->pre_gain_factor_db < -20) ||
52
1.49k
      (pstr_static_gain->pre_gain_factor_db > 20)) {
53
0
    return IA_EXHEAACE_CONFIG_NONFATAL_MPS_INVALID_CONFIG;
54
0
  }
55
56
1.49k
  if (pstr_static_gain->pre_gain_factor_db) {
57
0
    pre_gain_factor = pre_gain_factor_table_flt_new[pstr_static_gain->pre_gain_factor_db + 20];
58
1.49k
  } else {
59
1.49k
    pre_gain_factor = 1.0f;
60
1.49k
  }
61
62
1.49k
  if (pstr_static_gain->fixed_gain_dmx) {
63
1.49k
    pstr_static_gain->post_gain = dmx_gain_table_flt[pstr_static_gain->fixed_gain_dmx - 1];
64
1.49k
  } else {
65
0
    pstr_static_gain->post_gain = 1.0f;
66
0
  }
67
68
1.49k
  memset(pstr_static_gain->pre_gain, 0, sizeof(pstr_static_gain->pre_gain));
69
70
1.49k
  pstr_static_gain->pre_gain[0] = pre_gain_factor;
71
1.49k
  pstr_static_gain->pre_gain[1] = pre_gain_factor;
72
73
1.49k
  return error;
74
1.49k
}