00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00030 #ifndef AVCODEC_AAC_H
00031 #define AVCODEC_AAC_H
00032
00033 #include "libavutil/internal.h"
00034 #include "avcodec.h"
00035 #include "dsputil.h"
00036 #include "mpeg4audio.h"
00037
00038 #include <stdint.h>
00039
00040 #define AAC_INIT_VLC_STATIC(num, size) \
00041 INIT_VLC_STATIC(&vlc_spectral[num], 6, ff_aac_spectral_sizes[num], \
00042 ff_aac_spectral_bits[num], sizeof( ff_aac_spectral_bits[num][0]), sizeof( ff_aac_spectral_bits[num][0]), \
00043 ff_aac_spectral_codes[num], sizeof(ff_aac_spectral_codes[num][0]), sizeof(ff_aac_spectral_codes[num][0]), \
00044 size);
00045
00046 #define MAX_CHANNELS 64
00047 #define MAX_ELEM_ID 16
00048
00049 #define TNS_MAX_ORDER 20
00050
00051 enum AudioObjectType {
00052 AOT_NULL,
00053
00054 AOT_AAC_MAIN,
00055 AOT_AAC_LC,
00056 AOT_AAC_SSR,
00057 AOT_AAC_LTP,
00058 AOT_SBR,
00059 AOT_AAC_SCALABLE,
00060 AOT_TWINVQ,
00061 AOT_CELP,
00062 AOT_HVXC,
00063 AOT_TTSI = 12,
00064 AOT_MAINSYNTH,
00065 AOT_WAVESYNTH,
00066 AOT_MIDI,
00067 AOT_SAFX,
00068 AOT_ER_AAC_LC,
00069 AOT_ER_AAC_LTP = 19,
00070 AOT_ER_AAC_SCALABLE,
00071 AOT_ER_TWINVQ,
00072 AOT_ER_BSAC,
00073 AOT_ER_AAC_LD,
00074 AOT_ER_CELP,
00075 AOT_ER_HVXC,
00076 AOT_ER_HILN,
00077 AOT_ER_PARAM,
00078 AOT_SSC,
00079 };
00080
00081 enum RawDataBlockType {
00082 TYPE_SCE,
00083 TYPE_CPE,
00084 TYPE_CCE,
00085 TYPE_LFE,
00086 TYPE_DSE,
00087 TYPE_PCE,
00088 TYPE_FIL,
00089 TYPE_END,
00090 };
00091
00092 enum ExtensionPayloadID {
00093 EXT_FILL,
00094 EXT_FILL_DATA,
00095 EXT_DATA_ELEMENT,
00096 EXT_DYNAMIC_RANGE = 0xb,
00097 EXT_SBR_DATA = 0xd,
00098 EXT_SBR_DATA_CRC = 0xe,
00099 };
00100
00101 enum WindowSequence {
00102 ONLY_LONG_SEQUENCE,
00103 LONG_START_SEQUENCE,
00104 EIGHT_SHORT_SEQUENCE,
00105 LONG_STOP_SEQUENCE,
00106 };
00107
00108 enum BandType {
00109 ZERO_BT = 0,
00110 FIRST_PAIR_BT = 5,
00111 ESC_BT = 11,
00112 NOISE_BT = 13,
00113 INTENSITY_BT2 = 14,
00114 INTENSITY_BT = 15,
00115 };
00116
00117 #define IS_CODEBOOK_UNSIGNED(x) ((x - 1) & 10)
00118
00119 enum ChannelPosition {
00120 AAC_CHANNEL_FRONT = 1,
00121 AAC_CHANNEL_SIDE = 2,
00122 AAC_CHANNEL_BACK = 3,
00123 AAC_CHANNEL_LFE = 4,
00124 AAC_CHANNEL_CC = 5,
00125 };
00126
00130 enum CouplingPoint {
00131 BEFORE_TNS,
00132 BETWEEN_TNS_AND_IMDCT,
00133 AFTER_IMDCT = 3,
00134 };
00135
00139 typedef struct {
00140 float cor0;
00141 float cor1;
00142 float var0;
00143 float var1;
00144 float r0;
00145 float r1;
00146 } PredictorState;
00147
00148 #define MAX_PREDICTORS 672
00149
00153 typedef struct {
00154 uint8_t max_sfb;
00155 enum WindowSequence window_sequence[2];
00156 uint8_t use_kb_window[2];
00157 int num_window_groups;
00158 uint8_t group_len[8];
00159 const uint16_t *swb_offset;
00160 int num_swb;
00161 int num_windows;
00162 int tns_max_bands;
00163 int predictor_present;
00164 int predictor_initialized;
00165 int predictor_reset_group;
00166 uint8_t prediction_used[41];
00167 } IndividualChannelStream;
00168
00172 typedef struct {
00173 int present;
00174 int n_filt[8];
00175 int length[8][4];
00176 int direction[8][4];
00177 int order[8][4];
00178 float coef[8][4][TNS_MAX_ORDER];
00179 } TemporalNoiseShaping;
00180
00184 typedef struct {
00185 int pce_instance_tag;
00186 int dyn_rng_sgn[17];
00187 int dyn_rng_ctl[17];
00188 int exclude_mask[MAX_CHANNELS];
00189 int band_incr;
00190 int interpolation_scheme;
00191 int band_top[17];
00192 int prog_ref_level;
00195 } DynamicRangeControl;
00196
00197 typedef struct {
00198 int num_pulse;
00199 int pos[4];
00200 int amp[4];
00201 } Pulse;
00202
00206 typedef struct {
00207 enum CouplingPoint coupling_point;
00208 int num_coupled;
00209 enum RawDataBlockType type[8];
00210 int id_select[8];
00211 int ch_select[8];
00214 float gain[16][120];
00215 } ChannelCoupling;
00216
00220 typedef struct {
00221 IndividualChannelStream ics;
00222 TemporalNoiseShaping tns;
00223 enum BandType band_type[120];
00224 int band_type_run_end[120];
00225 float sf[120];
00226 DECLARE_ALIGNED_16(float, coeffs[1024]);
00227 DECLARE_ALIGNED_16(float, saved[512]);
00228 DECLARE_ALIGNED_16(float, ret[1024]);
00229 PredictorState predictor_state[MAX_PREDICTORS];
00230 } SingleChannelElement;
00231
00235 typedef struct {
00236
00237 uint8_t ms_mask[120];
00238
00239 SingleChannelElement ch[2];
00240
00241 ChannelCoupling coup;
00242 } ChannelElement;
00243
00247 typedef struct {
00248 AVCodecContext * avccontext;
00249
00250 MPEG4AudioConfig m4ac;
00251
00252 int is_saved;
00253 DynamicRangeControl che_drc;
00254
00259 enum ChannelPosition che_pos[4][MAX_ELEM_ID];
00262 ChannelElement * che[4][MAX_ELEM_ID];
00263 ChannelElement * tag_che_map[4][MAX_ELEM_ID];
00264 int tags_mapped;
00271 DECLARE_ALIGNED_16(float, buf_mdct[1024]);
00278 MDCTContext mdct;
00279 MDCTContext mdct_small;
00280 DSPContext dsp;
00281 int random_state;
00288 float *output_data[MAX_CHANNELS];
00289 float add_bias;
00290 float sf_scale;
00291 int sf_offset;
00292
00294 DECLARE_ALIGNED(16, float, temp[128]);
00295 } AACContext;
00296
00297 #endif