aboutsummaryrefslogtreecommitdiff
path: root/encoder/ixheaace_api.h
blob: 3bd594a0f571b4e67b978dc780e38b0368800d32 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
/******************************************************************************
 *                                                                            *
 * Copyright (C) 2023 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at:
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 *****************************************************************************
 * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
 */

#pragma once

/* read only memory, intra frame */
#define IA_MEMTYPE_INPUT 0x02
/* read-write memory, for usable output, intra frame */
#define IA_MEMTYPE_OUTPUT 0x03

#define DEFAULT_MEM_ALIGN_8 (8)
#define IXHEAACE_MEM_ALLOC_CNT (6)
/* 1 <ixheaace_api_struct>  2 <ixheaace_mem_info_struct>  3 <Persistent>  4 <Scratch>  5 <Input>
 * 6 <Output> */

/* Audio Object Type */
#define AOT_AAC_LC (2)
#define AOT_SBR (5)
#define AOT_AAC_LD (23)
#define AOT_AAC_ELD (39)
#define AOT_USAC (42)
#define AOT_PS (29)

/* standard memory table descriptor for libraries */
typedef struct {
  UWORD32 ui_size;         /* size of the memory in bytes	*/
  UWORD32 ui_alignment;    /* alignment in bytes 			*/
  UWORD32 ui_type;         /* type of memory 				*/
  UWORD32 ui_placement[2]; /* 64 bit placement info		*/
  UWORD32 ui_priority;     /* the importance for placement	*/
  UWORD32 ui_placed[2];    /* the o_red location for placement	*/
} ixheaace_mem_info_struct;

typedef struct {
  UWORD32 ui_size;
  UWORD32 ui_alignment;
  UWORD32 ui_type;
  pVOID mem_ptr;
} ixheaace_mem_info_table;

typedef struct {
  WORD32 sample_rate;               /* audio file sample rate */
  WORD32 bitrate;                   /* encoder bit rate in bits/sec */
  WORD32 num_channels_in;           /* number of channels on input (1,2) */
  WORD32 num_channels_out;          /* number of channels on output (1,2) */
  WORD32 bandwidth;                 /* targeted audio bandwidth in Hz */
  WORD32 dual_mono;                 /* flag: make 2 SCEs for stereo input files */
  WORD32 use_tns;                   /* flag: use temporal noise shaping */
  WORD32 noise_filling;             /* flag: use noise filling */
  WORD32 use_adts;                  /* flag: use ADTS instead of ADIF */
  WORD32 private_bit;               /* private bit of MPEG Header */
  WORD32 copyright_bit;             /* copyright bit of MPEG Header */
  WORD32 original_copy_bit;         /* original bit of MPEG Header */
  WORD32 f_no_stereo_preprocessing; /* forbid usage of stereo prerpocessing */
  WORD32 inv_quant;                 /* improve distortion by inverse quantization */
  WORD32 full_bandwidth;            /* improve distortion by inverse quantization */
  WORD32 bitreservoir_size;         /* size of bit reservoir (default:0; max 6144)*/
  WORD32 length;
} ixheaace_aac_enc_config;

typedef struct {
  UWORD32 ui_pcm_wd_sz;
  WORD32 i_bitrate;
  WORD32 frame_length;
  WORD32 frame_cmd_flag;
  WORD32 out_bytes_flag;
  WORD32 user_tns_flag;
  WORD32 user_esbr_flag;
  WORD32 aot;
  WORD32 i_mps_tree_config;
  WORD32 esbr_flag;
  WORD32 i_channels;
  UWORD32 i_samp_freq;
  WORD32 i_native_samp_freq;
  WORD32 i_channels_mask;
  WORD32 i_num_coupling_chan;
  /* Add config params here */
  WORD32 i_use_mps;
  WORD32 i_use_adts;
  WORD32 i_use_es;
  WORD32 usac_en;
  WORD32 codec_mode;
  WORD32 cplx_pred;
  WORD32 ccfl_idx;
  WORD32 pvc_active;
  WORD32 harmonic_sbr;
  WORD32 inter_tes_active;
  pVOID pv_drc_cfg;
  FLAG use_drc_element;
  WORD32 drc_frame_size;
  WORD32 hq_esbr;
  FLAG write_program_config_element;
  ixheaace_aac_enc_config aac_config;
} ixheaace_input_config;

typedef struct {
  WORD8 *p_lib_name;
  WORD8 *p_version_num;

} ixheaace_version;
typedef struct {
  WORD32 i_out_bytes;
  WORD32 i_bytes_consumed;
  UWORD32 ui_inp_buf_size;
  UWORD32 malloc_count;
  SIZE_T ui_rem;
  UWORD32 ui_proc_mem_tabs_size;
  pVOID pv_ia_process_api_obj;
  pVOID arr_alloc_memory[IXHEAACE_MEM_ALLOC_CNT];
  pVOID (*malloc_xheaace)(UWORD32, UWORD32);
  VOID (*free_xheaace)(pVOID);
  ixheaace_version version;
  ixheaace_mem_info_table mem_info_table[4];
  WORD32 input_size;
  WORD32 samp_freq;
  WORD32 header_samp_freq;
  WORD32 audio_profile;
  FLOAT32 down_sampling_ratio;
  pWORD32 pb_inp_buf_32;
} ixheaace_output_config;

typedef struct {
  ixheaace_input_config input_config;
  ixheaace_output_config output_config;
} ixheaace_user_config_struct;

typedef struct {
  WORD32 codec_mode;
} ia_input_config;

/* gets the encoder library name and version number details */
IA_ERRORCODE ixheaace_get_lib_id_strings(pVOID pv_output);

/* handles memory requirements and initialization*/
IA_ERRORCODE ixheaace_create(pVOID pv_input, pVOID pv_output);

/* encodes the input frame data */
IA_ERRORCODE ixheaace_process(pVOID pv_ia_process_api_obj, pVOID pstr_in_cfg, pVOID pstr_out_cfg);

/* frees the allocated memories for the encoder*/
IA_ERRORCODE ixheaace_delete(pVOID pv_output);