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 "avcodec.h"
00034 #include "dsputil.h"
00035 #include "fft.h"
00036 #include "mpeg4audio.h"
00037 #include "sbr.h"
00038
00039 #include <stdint.h>
00040
00041 #define AAC_INIT_VLC_STATIC(num, size) \
00042 INIT_VLC_STATIC(&vlc_spectral[num], 8, ff_aac_spectral_sizes[num], \
00043 ff_aac_spectral_bits[num], sizeof( ff_aac_spectral_bits[num][0]), sizeof( ff_aac_spectral_bits[num][0]), \
00044 ff_aac_spectral_codes[num], sizeof(ff_aac_spectral_codes[num][0]), sizeof(ff_aac_spectral_codes[num][0]), \
00045 size);
00046
00047 #define MAX_CHANNELS 64
00048 #define MAX_ELEM_ID 16
00049
00050 #define TNS_MAX_ORDER 20
00051
00052 enum RawDataBlockType {
00053 TYPE_SCE,
00054 TYPE_CPE,
00055 TYPE_CCE,
00056 TYPE_LFE,
00057 TYPE_DSE,
00058 TYPE_PCE,
00059 TYPE_FIL,
00060 TYPE_END,
00061 };
00062
00063 enum ExtensionPayloadID {
00064 EXT_FILL,
00065 EXT_FILL_DATA,
00066 EXT_DATA_ELEMENT,
00067 EXT_DYNAMIC_RANGE = 0xb,
00068 EXT_SBR_DATA = 0xd,
00069 EXT_SBR_DATA_CRC = 0xe,
00070 };
00071
00072 enum WindowSequence {
00073 ONLY_LONG_SEQUENCE,
00074 LONG_START_SEQUENCE,
00075 EIGHT_SHORT_SEQUENCE,
00076 LONG_STOP_SEQUENCE,
00077 };
00078
00079 enum BandType {
00080 ZERO_BT = 0,
00081 FIRST_PAIR_BT = 5,
00082 ESC_BT = 11,
00083 NOISE_BT = 13,
00084 INTENSITY_BT2 = 14,
00085 INTENSITY_BT = 15,
00086 };
00087
00088 #define IS_CODEBOOK_UNSIGNED(x) ((x - 1) & 10)
00089
00090 enum ChannelPosition {
00091 AAC_CHANNEL_FRONT = 1,
00092 AAC_CHANNEL_SIDE = 2,
00093 AAC_CHANNEL_BACK = 3,
00094 AAC_CHANNEL_LFE = 4,
00095 AAC_CHANNEL_CC = 5,
00096 };
00097
00101 enum CouplingPoint {
00102 BEFORE_TNS,
00103 BETWEEN_TNS_AND_IMDCT,
00104 AFTER_IMDCT = 3,
00105 };
00106
00110 enum OCStatus {
00111 OC_NONE,
00112 OC_TRIAL_PCE,
00113 OC_TRIAL_FRAME,
00114 OC_GLOBAL_HDR,
00115 OC_LOCKED,
00116 };
00117
00121 typedef struct {
00122 float cor0;
00123 float cor1;
00124 float var0;
00125 float var1;
00126 float r0;
00127 float r1;
00128 } PredictorState;
00129
00130 #define MAX_PREDICTORS 672
00131
00132 #define SCALE_DIV_512 36
00133 #define SCALE_ONE_POS 140
00134 #define SCALE_MAX_POS 255
00135 #define SCALE_MAX_DIFF 60
00136 #define SCALE_DIFF_ZERO 60
00137
00138
00141 typedef struct {
00142 uint8_t max_sfb;
00143 enum WindowSequence window_sequence[2];
00144 uint8_t use_kb_window[2];
00145 int num_window_groups;
00146 uint8_t group_len[8];
00147 const uint16_t *swb_offset;
00148 const uint8_t *swb_sizes;
00149 int num_swb;
00150 int num_windows;
00151 int tns_max_bands;
00152 int predictor_present;
00153 int predictor_initialized;
00154 int predictor_reset_group;
00155 uint8_t prediction_used[41];
00156 } IndividualChannelStream;
00157
00161 typedef struct {
00162 int present;
00163 int n_filt[8];
00164 int length[8][4];
00165 int direction[8][4];
00166 int order[8][4];
00167 float coef[8][4][TNS_MAX_ORDER];
00168 } TemporalNoiseShaping;
00169
00173 typedef struct {
00174 int pce_instance_tag;
00175 int dyn_rng_sgn[17];
00176 int dyn_rng_ctl[17];
00177 int exclude_mask[MAX_CHANNELS];
00178 int band_incr;
00179 int interpolation_scheme;
00180 int band_top[17];
00181 int prog_ref_level;
00184 } DynamicRangeControl;
00185
00186 typedef struct {
00187 int num_pulse;
00188 int start;
00189 int pos[4];
00190 int amp[4];
00191 } Pulse;
00192
00196 typedef struct {
00197 enum CouplingPoint coupling_point;
00198 int num_coupled;
00199 enum RawDataBlockType type[8];
00200 int id_select[8];
00201 int ch_select[8];
00204 float gain[16][120];
00205 } ChannelCoupling;
00206
00210 typedef struct {
00211 IndividualChannelStream ics;
00212 TemporalNoiseShaping tns;
00213 Pulse pulse;
00214 enum BandType band_type[128];
00215 int band_type_run_end[120];
00216 float sf[120];
00217 int sf_idx[128];
00218 uint8_t zeroes[128];
00219 DECLARE_ALIGNED(16, float, coeffs)[1024];
00220 DECLARE_ALIGNED(16, float, saved)[1024];
00221 DECLARE_ALIGNED(16, float, ret)[2048];
00222 PredictorState predictor_state[MAX_PREDICTORS];
00223 } SingleChannelElement;
00224
00228 typedef struct {
00229
00230 int common_window;
00231 int ms_mode;
00232 uint8_t ms_mask[128];
00233
00234 SingleChannelElement ch[2];
00235
00236 ChannelCoupling coup;
00237 SpectralBandReplication sbr;
00238 } ChannelElement;
00239
00243 typedef struct {
00244 AVCodecContext * avccontext;
00245
00246 MPEG4AudioConfig m4ac;
00247
00248 int is_saved;
00249 DynamicRangeControl che_drc;
00250
00255 enum ChannelPosition che_pos[4][MAX_ELEM_ID];
00258 ChannelElement * che[4][MAX_ELEM_ID];
00259 ChannelElement * tag_che_map[4][MAX_ELEM_ID];
00260 int tags_mapped;
00267 DECLARE_ALIGNED(16, float, buf_mdct)[1024];
00274 FFTContext mdct;
00275 FFTContext mdct_small;
00276 DSPContext dsp;
00277 int random_state;
00284 float *output_data[MAX_CHANNELS];
00285 float add_bias;
00286 float sf_scale;
00287 int sf_offset;
00288
00290 DECLARE_ALIGNED(16, float, temp)[128];
00291
00292 enum OCStatus output_configured;
00293 } AACContext;
00294
00295 #endif