xref: /aosp_15_r20/external/libxaac/encoder/ixheaace_tns.h (revision 15dc779a375ca8b5125643b829a8aa4b70d7f451)
1*15dc779aSAndroid Build Coastguard Worker /******************************************************************************
2*15dc779aSAndroid Build Coastguard Worker  *                                                                            *
3*15dc779aSAndroid Build Coastguard Worker  * Copyright (C) 2023 The Android Open Source Project
4*15dc779aSAndroid Build Coastguard Worker  *
5*15dc779aSAndroid Build Coastguard Worker  * Licensed under the Apache License, Version 2.0 (the "License");
6*15dc779aSAndroid Build Coastguard Worker  * you may not use this file except in compliance with the License.
7*15dc779aSAndroid Build Coastguard Worker  * You may obtain a copy of the License at:
8*15dc779aSAndroid Build Coastguard Worker  *
9*15dc779aSAndroid Build Coastguard Worker  * http://www.apache.org/licenses/LICENSE-2.0
10*15dc779aSAndroid Build Coastguard Worker  *
11*15dc779aSAndroid Build Coastguard Worker  * Unless required by applicable law or agreed to in writing, software
12*15dc779aSAndroid Build Coastguard Worker  * distributed under the License is distributed on an "AS IS" BASIS,
13*15dc779aSAndroid Build Coastguard Worker  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14*15dc779aSAndroid Build Coastguard Worker  * See the License for the specific language governing permissions and
15*15dc779aSAndroid Build Coastguard Worker  * limitations under the License.
16*15dc779aSAndroid Build Coastguard Worker  *
17*15dc779aSAndroid Build Coastguard Worker  *****************************************************************************
18*15dc779aSAndroid Build Coastguard Worker  * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
19*15dc779aSAndroid Build Coastguard Worker  */
20*15dc779aSAndroid Build Coastguard Worker 
21*15dc779aSAndroid Build Coastguard Worker #pragma once
22*15dc779aSAndroid Build Coastguard Worker #define TEMPORAL_NOISE_SHAPING_MAX_ORDER (12)
23*15dc779aSAndroid Build Coastguard Worker #define TEMPORAL_NOISE_SHAPING_MAX_ORDER_SHORT (5)
24*15dc779aSAndroid Build Coastguard Worker #define TEMPORAL_NOISE_SHAPING_START_FREQ (1275)
25*15dc779aSAndroid Build Coastguard Worker #define TEMPORAL_NOISE_SHAPING_START_FREQ_SHORT (2750)
26*15dc779aSAndroid Build Coastguard Worker #define TEMPORAL_NOISE_SHAPING_COEF_RES (4)
27*15dc779aSAndroid Build Coastguard Worker #define TEMPORAL_NOISE_SHAPING_COEF_RES_SHORT (3)
28*15dc779aSAndroid Build Coastguard Worker #define FILTER_DIRECTION (0)
29*15dc779aSAndroid Build Coastguard Worker #define PI_BY_1000 (0.00314159265358979323f)
30*15dc779aSAndroid Build Coastguard Worker #define TEMPORAL_NOISE_SHAPING_MODIFY_BEGIN 2600 /* Hz */
31*15dc779aSAndroid Build Coastguard Worker #define RATIO_PATCH_LOWER_BORDER 380             /* Hz */
32*15dc779aSAndroid Build Coastguard Worker #define INT_BITS 32
33*15dc779aSAndroid Build Coastguard Worker typedef struct {
34*15dc779aSAndroid Build Coastguard Worker   WORD32 channel_bit_rate;
35*15dc779aSAndroid Build Coastguard Worker   WORD32 bandwidth_mono;
36*15dc779aSAndroid Build Coastguard Worker   WORD32 bandwidth_stereo;
37*15dc779aSAndroid Build Coastguard Worker } ixheaace_bandwidth_table;
38*15dc779aSAndroid Build Coastguard Worker typedef struct {
39*15dc779aSAndroid Build Coastguard Worker   FLOAT32 thresh_on;
40*15dc779aSAndroid Build Coastguard Worker   WORD32 lpc_start_freq;
41*15dc779aSAndroid Build Coastguard Worker   WORD32 lpc_stop_freq;
42*15dc779aSAndroid Build Coastguard Worker   FLOAT32 tns_time_resolution;
43*15dc779aSAndroid Build Coastguard Worker } ixheaace_temporal_noise_shaping_config_tabulated;
44*15dc779aSAndroid Build Coastguard Worker 
45*15dc779aSAndroid Build Coastguard Worker typedef struct {
46*15dc779aSAndroid Build Coastguard Worker   WORD8 tns_active;
47*15dc779aSAndroid Build Coastguard Worker   WORD32 tns_max_sfb;
48*15dc779aSAndroid Build Coastguard Worker   WORD32 max_order;
49*15dc779aSAndroid Build Coastguard Worker   WORD32 tns_start_freq;
50*15dc779aSAndroid Build Coastguard Worker   WORD32 coef_res;
51*15dc779aSAndroid Build Coastguard Worker   ixheaace_temporal_noise_shaping_config_tabulated conf_tab;
52*15dc779aSAndroid Build Coastguard Worker   FLOAT32 acf_window_float[TEMPORAL_NOISE_SHAPING_MAX_ORDER + 1];
53*15dc779aSAndroid Build Coastguard Worker   WORD32 tns_start_band;
54*15dc779aSAndroid Build Coastguard Worker   WORD32 tns_start_line;
55*15dc779aSAndroid Build Coastguard Worker   WORD32 tns_stop_band;
56*15dc779aSAndroid Build Coastguard Worker   WORD32 tns_stop_line;
57*15dc779aSAndroid Build Coastguard Worker   WORD32 lpc_start_band;
58*15dc779aSAndroid Build Coastguard Worker   WORD32 lpc_start_line;
59*15dc779aSAndroid Build Coastguard Worker   WORD32 lpc_stop_band;
60*15dc779aSAndroid Build Coastguard Worker   WORD32 lpc_stop_line;
61*15dc779aSAndroid Build Coastguard Worker   WORD32 tns_ratio_patch_lowest_cb;
62*15dc779aSAndroid Build Coastguard Worker   WORD32 tns_modify_begin_cb;
63*15dc779aSAndroid Build Coastguard Worker   FLOAT32 threshold;
64*15dc779aSAndroid Build Coastguard Worker } ixheaace_temporal_noise_shaping_config;
65*15dc779aSAndroid Build Coastguard Worker 
66*15dc779aSAndroid Build Coastguard Worker typedef struct {
67*15dc779aSAndroid Build Coastguard Worker   WORD8 tns_active;
68*15dc779aSAndroid Build Coastguard Worker   FLOAT32 parcor[TEMPORAL_NOISE_SHAPING_MAX_ORDER];
69*15dc779aSAndroid Build Coastguard Worker   FLOAT32 prediction_gain;
70*15dc779aSAndroid Build Coastguard Worker } ixheaace_temporal_noise_shaping_subblock_info_long;
71*15dc779aSAndroid Build Coastguard Worker 
72*15dc779aSAndroid Build Coastguard Worker typedef struct {
73*15dc779aSAndroid Build Coastguard Worker   WORD8 tns_active;
74*15dc779aSAndroid Build Coastguard Worker   FLOAT32 parcor[TEMPORAL_NOISE_SHAPING_MAX_ORDER];
75*15dc779aSAndroid Build Coastguard Worker   FLOAT32 prediction_gain;
76*15dc779aSAndroid Build Coastguard Worker } ixheaace_temporal_noise_shaping_subblock_info_short;
77*15dc779aSAndroid Build Coastguard Worker 
78*15dc779aSAndroid Build Coastguard Worker typedef struct {
79*15dc779aSAndroid Build Coastguard Worker   ixheaace_temporal_noise_shaping_subblock_info_short sub_block_info[TRANS_FAC];
80*15dc779aSAndroid Build Coastguard Worker } ixheaace_temporal_noise_shaping_data_short;
81*15dc779aSAndroid Build Coastguard Worker 
82*15dc779aSAndroid Build Coastguard Worker typedef struct {
83*15dc779aSAndroid Build Coastguard Worker   ixheaace_temporal_noise_shaping_subblock_info_long sub_block_info;
84*15dc779aSAndroid Build Coastguard Worker } ixheaace_temporal_noise_shaping_data_long;
85*15dc779aSAndroid Build Coastguard Worker 
86*15dc779aSAndroid Build Coastguard Worker typedef struct {
87*15dc779aSAndroid Build Coastguard Worker   ixheaace_temporal_noise_shaping_data_long tns_data_long;
88*15dc779aSAndroid Build Coastguard Worker   ixheaace_temporal_noise_shaping_data_short tns_data_short;
89*15dc779aSAndroid Build Coastguard Worker } ixheaace_temporal_noise_shaping_data_raw;
90*15dc779aSAndroid Build Coastguard Worker 
91*15dc779aSAndroid Build Coastguard Worker typedef struct {
92*15dc779aSAndroid Build Coastguard Worker   WORD32 numOfSubblocks;
93*15dc779aSAndroid Build Coastguard Worker   ixheaace_temporal_noise_shaping_data_raw data_raw;
94*15dc779aSAndroid Build Coastguard Worker } ixheaace_temporal_noise_shaping_data;
95*15dc779aSAndroid Build Coastguard Worker 
96*15dc779aSAndroid Build Coastguard Worker typedef struct {
97*15dc779aSAndroid Build Coastguard Worker   WORD8 tns_active[TRANS_FAC];
98*15dc779aSAndroid Build Coastguard Worker   WORD8 coef_res[TRANS_FAC];
99*15dc779aSAndroid Build Coastguard Worker   WORD32 length[TRANS_FAC];
100*15dc779aSAndroid Build Coastguard Worker   WORD32 order[TRANS_FAC];
101*15dc779aSAndroid Build Coastguard Worker   WORD32 coef[TRANS_FAC * TEMPORAL_NOISE_SHAPING_MAX_ORDER_SHORT];
102*15dc779aSAndroid Build Coastguard Worker } ixheaace_temporal_noise_shaping_params;
103