xref: /aosp_15_r20/external/libxaac/encoder/ixheaace_tns.h (revision 15dc779a375ca8b5125643b829a8aa4b70d7f451)
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 #pragma once
22 #define TEMPORAL_NOISE_SHAPING_MAX_ORDER (12)
23 #define TEMPORAL_NOISE_SHAPING_MAX_ORDER_SHORT (5)
24 #define TEMPORAL_NOISE_SHAPING_START_FREQ (1275)
25 #define TEMPORAL_NOISE_SHAPING_START_FREQ_SHORT (2750)
26 #define TEMPORAL_NOISE_SHAPING_COEF_RES (4)
27 #define TEMPORAL_NOISE_SHAPING_COEF_RES_SHORT (3)
28 #define FILTER_DIRECTION (0)
29 #define PI_BY_1000 (0.00314159265358979323f)
30 #define TEMPORAL_NOISE_SHAPING_MODIFY_BEGIN 2600 /* Hz */
31 #define RATIO_PATCH_LOWER_BORDER 380             /* Hz */
32 #define INT_BITS 32
33 typedef struct {
34   WORD32 channel_bit_rate;
35   WORD32 bandwidth_mono;
36   WORD32 bandwidth_stereo;
37 } ixheaace_bandwidth_table;
38 typedef struct {
39   FLOAT32 thresh_on;
40   WORD32 lpc_start_freq;
41   WORD32 lpc_stop_freq;
42   FLOAT32 tns_time_resolution;
43 } ixheaace_temporal_noise_shaping_config_tabulated;
44 
45 typedef struct {
46   WORD8 tns_active;
47   WORD32 tns_max_sfb;
48   WORD32 max_order;
49   WORD32 tns_start_freq;
50   WORD32 coef_res;
51   ixheaace_temporal_noise_shaping_config_tabulated conf_tab;
52   FLOAT32 acf_window_float[TEMPORAL_NOISE_SHAPING_MAX_ORDER + 1];
53   WORD32 tns_start_band;
54   WORD32 tns_start_line;
55   WORD32 tns_stop_band;
56   WORD32 tns_stop_line;
57   WORD32 lpc_start_band;
58   WORD32 lpc_start_line;
59   WORD32 lpc_stop_band;
60   WORD32 lpc_stop_line;
61   WORD32 tns_ratio_patch_lowest_cb;
62   WORD32 tns_modify_begin_cb;
63   FLOAT32 threshold;
64 } ixheaace_temporal_noise_shaping_config;
65 
66 typedef struct {
67   WORD8 tns_active;
68   FLOAT32 parcor[TEMPORAL_NOISE_SHAPING_MAX_ORDER];
69   FLOAT32 prediction_gain;
70 } ixheaace_temporal_noise_shaping_subblock_info_long;
71 
72 typedef struct {
73   WORD8 tns_active;
74   FLOAT32 parcor[TEMPORAL_NOISE_SHAPING_MAX_ORDER];
75   FLOAT32 prediction_gain;
76 } ixheaace_temporal_noise_shaping_subblock_info_short;
77 
78 typedef struct {
79   ixheaace_temporal_noise_shaping_subblock_info_short sub_block_info[TRANS_FAC];
80 } ixheaace_temporal_noise_shaping_data_short;
81 
82 typedef struct {
83   ixheaace_temporal_noise_shaping_subblock_info_long sub_block_info;
84 } ixheaace_temporal_noise_shaping_data_long;
85 
86 typedef struct {
87   ixheaace_temporal_noise_shaping_data_long tns_data_long;
88   ixheaace_temporal_noise_shaping_data_short tns_data_short;
89 } ixheaace_temporal_noise_shaping_data_raw;
90 
91 typedef struct {
92   WORD32 numOfSubblocks;
93   ixheaace_temporal_noise_shaping_data_raw data_raw;
94 } ixheaace_temporal_noise_shaping_data;
95 
96 typedef struct {
97   WORD8 tns_active[TRANS_FAC];
98   WORD8 coef_res[TRANS_FAC];
99   WORD32 length[TRANS_FAC];
100   WORD32 order[TRANS_FAC];
101   WORD32 coef[TRANS_FAC * TEMPORAL_NOISE_SHAPING_MAX_ORDER_SHORT];
102 } ixheaace_temporal_noise_shaping_params;
103