xref: /aosp_15_r20/external/libxaac/encoder/ixheaace_mps_bitstream.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 typedef struct {
23   UWORD8 bs_smooth_mode[MAX_NUM_PARAMS];
24   UWORD8 bs_smooth_time[MAX_NUM_PARAMS];
25   UWORD8 bs_freq_res_stride[MAX_NUM_PARAMS];
26   UWORD8 bs_smg_data[MAX_NUM_PARAMS][MAX_NUM_BINS];
27 
28 } ixheaace_mps_smg_data;
29 
30 typedef struct {
31   UWORD8 bs_framing_type;
32   WORD32 num_param_sets;
33   WORD32 bs_param_slots[MAX_NUM_PARAMS];
34 
35 } ixheaace_mps_framing_info;
36 
37 typedef struct {
38   WORD8 cld[IXHEAACE_MPS_MAX_NUM_BOXES][MAX_NUM_PARAMS][MAX_NUM_BINS];
39   WORD8 icc[IXHEAACE_MPS_MAX_NUM_BOXES][MAX_NUM_PARAMS][MAX_NUM_BINS];
40 
41 } ixheaace_mps_ott_data;
42 
43 typedef struct {
44   UWORD8 bs_env_shape_channel[MAX_NUM_OUTPUTCHANNELS];
45   UWORD8 bs_env_shape_data[MAX_NUM_OUTPUTCHANNELS][MAX_TIME_SLOTS];
46 
47 } ixheaace_mps_temp_shape_data;
48 
49 typedef struct {
50   WORD32 num_ott_boxes;
51   WORD32 num_in_chan;
52   WORD32 num_out_chan;
53 
54 } ixheaace_mps_tree_description;
55 
56 typedef struct {
57   WORD32 bs_ott_bands;
58 
59 } ixheaace_mps_ott_config;
60 
61 typedef struct {
62   WORD32 bs_sampling_frequency;
63   WORD32 bs_frame_length;
64   WORD32 num_bands;
65   WORD32 bs_tree_config;
66   WORD32 bs_quant_mode;
67   WORD32 bs_fixed_gain_dmx;
68   WORD32 bs_env_quant_mode;
69   WORD32 bs_decorr_config;
70   ixheaace_mps_tree_description tree_description;
71   ixheaace_mps_ott_config ott_config[IXHEAACE_MPS_MAX_NUM_BOXES];
72 
73 } ixheaace_mps_spatial_specific_config;
74 typedef struct {
75   UWORD8 bs_xxx_data_mode[IXHEAACE_MPS_MAX_NUM_BOXES][MAX_NUM_PARAMS];
76   UWORD8 bs_data_pair[IXHEAACE_MPS_MAX_NUM_BOXES][MAX_NUM_PARAMS];
77   UWORD8 bs_quant_coarse_xxx[IXHEAACE_MPS_MAX_NUM_BOXES][MAX_NUM_PARAMS];
78   UWORD8 bs_freq_res_stride_xxx[IXHEAACE_MPS_MAX_NUM_BOXES][MAX_NUM_PARAMS];
79 
80 } ixheaace_mps_lossless_data;
81 typedef struct {
82   ixheaace_mps_framing_info framing_info;
83   WORD32 bs_independency_flag;
84   ixheaace_mps_ott_data ott_data;
85   ixheaace_mps_smg_data smg_data;
86   ixheaace_mps_temp_shape_data temp_shape_data;
87   ixheaace_mps_lossless_data cld_lossless_data;
88   ixheaace_mps_lossless_data icc_lossless_data;
89   UWORD8 b_use_bb_cues;
90 
91 } ixheaace_mps_spatial_frame;
92 
93 typedef struct {
94   WORD8 cld_old[IXHEAACE_MPS_MAX_NUM_BOXES][MAX_NUM_BINS];
95   WORD8 icc_old[IXHEAACE_MPS_MAX_NUM_BOXES][MAX_NUM_BINS];
96   UWORD8 quant_coarse_cld_prev[IXHEAACE_MPS_MAX_NUM_BOXES][MAX_NUM_PARAMS];
97   UWORD8 quant_coarse_icc_prev[IXHEAACE_MPS_MAX_NUM_BOXES][MAX_NUM_PARAMS];
98 
99 } ixheaace_mps_prev_ott_data;
100 
101 typedef struct {
102   ixheaace_mps_prev_ott_data prev_ott_data;
103 
104 } ixheaace_mps_static_spatial_frame;
105 
106 typedef struct ixheaace_mps_bsf_instance {
107   ixheaace_mps_spatial_specific_config spatial_specific_config;
108   ixheaace_mps_spatial_frame frame;
109   ixheaace_mps_static_spatial_frame prev_frame_data;
110 
111 } ixheaace_mps_bsf_instance;
112 
113 typedef struct ixheaace_mps_bsf_instance *ixheaace_mps_pstr_bsf_instance;
114 
115 IA_ERRORCODE ixheaace_mps_212_write_spatial_specific_config(
116     ixheaace_mps_spatial_specific_config *const pstr_spatial_specific_config,
117     UWORD8 *const ptr_output_buffer, const WORD32 output_buffer_size,
118     WORD32 *const ptr_output_bits, WORD32 aot);
119 
120 IA_ERRORCODE ixheaace_mps_212_write_spatial_frame(
121     UWORD8 *const ptr_output_buffer, const WORD32 output_buffer_size,
122     WORD32 *const ptr_output_bits, ixheaace_mps_pstr_bsf_instance pstr_bsf_instance, WORD32 aot);
123