#ifndef AVCODEC_AAC_H
#define AVCODEC_AAC_H
+#include "libavutil/float_dsp.h"
#include "avcodec.h"
-#include "dsputil.h"
+#include "imdct15.h"
#include "fft.h"
#include "mpeg4audio.h"
#include "sbr.h"
-#include "fmtconvert.h"
#include <stdint.h>
#define IS_CODEBOOK_UNSIGNED(x) ((x - 1) & 10)
enum ChannelPosition {
+ AAC_CHANNEL_OFF = 0,
AAC_CHANNEL_FRONT = 1,
AAC_CHANNEL_SIDE = 2,
AAC_CHANNEL_BACK = 3,
OC_LOCKED, ///< Output configuration locked in place
};
+typedef struct OutputConfiguration {
+ MPEG4AudioConfig m4ac;
+ uint8_t layout_map[MAX_ELEM_ID*4][3];
+ int layout_map_tags;
+ int channels;
+ uint64_t channel_layout;
+ enum OCStatus status;
+} OutputConfiguration;
+
/**
* Predictor State
*/
-typedef struct {
+typedef struct PredictorState {
float cor0;
float cor1;
float var0;
#define SCALE_MAX_POS 255 ///< scalefactor index maximum value
#define SCALE_MAX_DIFF 60 ///< maximum scalefactor difference allowed by standard
#define SCALE_DIFF_ZERO 60 ///< codebook index corresponding to zero scalefactor indices difference
-#define POW_SF2_ZERO 200 ///< ff_aac_pow2sf_tab index corresponding to pow(2, 0);
/**
* Long Term Prediction
*/
-typedef struct {
+typedef struct LongTermPrediction {
int8_t present;
int16_t lag;
float coef;
/**
* Individual Channel Stream
*/
-typedef struct {
+typedef struct IndividualChannelStream {
uint8_t max_sfb; ///< number of scalefactor bands per group
enum WindowSequence window_sequence[2];
- uint8_t use_kb_window[2]; ///< If set, use Kaiser-Bessel window, otherwise use a sinus window.
+ uint8_t use_kb_window[2]; ///< If set, use Kaiser-Bessel window, otherwise use a sine window.
int num_window_groups;
uint8_t group_len[8];
LongTermPrediction ltp;
/**
* Temporal Noise Shaping
*/
-typedef struct {
+typedef struct TemporalNoiseShaping {
int present;
int n_filt[8];
int length[8][4];
/**
* Dynamic Range Control - decoded from the bitstream but not processed further.
*/
-typedef struct {
+typedef struct DynamicRangeControl {
int pce_instance_tag; ///< Indicates with which program the DRC info is associated.
int dyn_rng_sgn[17]; ///< DRC sign information; 0 - positive, 1 - negative
int dyn_rng_ctl[17]; ///< DRC magnitude information
*/
} DynamicRangeControl;
-typedef struct {
+typedef struct Pulse {
int num_pulse;
int start;
int pos[4];
/**
* coupling parameters
*/
-typedef struct {
+typedef struct ChannelCoupling {
enum CouplingPoint coupling_point; ///< The point during decoding at which coupling is applied.
int num_coupled; ///< number of target elements
enum RawDataBlockType type[8]; ///< Type of channel element to be coupled - SCE or CPE.
/**
* Single Channel Element - used for both SCE and LFE elements.
*/
-typedef struct {
+typedef struct SingleChannelElement {
IndividualChannelStream ics;
TemporalNoiseShaping tns;
Pulse pulse;
int sf_idx[128]; ///< scalefactor indices (used by encoder)
uint8_t zeroes[128]; ///< band is not coded (used by encoder)
DECLARE_ALIGNED(32, float, coeffs)[1024]; ///< coefficients for IMDCT
- DECLARE_ALIGNED(32, float, saved)[1024]; ///< overlap
- DECLARE_ALIGNED(32, float, ret)[2048]; ///< PCM output
+ DECLARE_ALIGNED(32, float, saved)[1536]; ///< overlap
+ DECLARE_ALIGNED(32, float, ret_buf)[2048]; ///< PCM output buffer
DECLARE_ALIGNED(16, float, ltp_state)[3072]; ///< time signal for LTP
PredictorState predictor_state[MAX_PREDICTORS];
+ float *ret; ///< PCM output
} SingleChannelElement;
/**
* channel element - generic struct for SCE/CPE/CCE/LFE
*/
-typedef struct {
+typedef struct ChannelElement {
// CPE specific
int common_window; ///< Set if channels share a common 'IndividualChannelStream' in bitstream.
int ms_mode; ///< Signals mid/side stereo flags coding mode (used by encoder)
/**
* main AAC context
*/
-typedef struct {
+typedef struct AACContext {
AVCodecContext *avctx;
-
- MPEG4AudioConfig m4ac;
+ AVFrame *frame;
int is_saved; ///< Set if elements have stored overlap from previous frame.
DynamicRangeControl che_drc;
* @name Channel element related data
* @{
*/
- enum ChannelPosition che_pos[4][MAX_ELEM_ID]; /**< channel element channel mapping with the
- * first index as the first 4 raw data block types
- */
ChannelElement *che[4][MAX_ELEM_ID];
ChannelElement *tag_che_map[4][MAX_ELEM_ID];
int tags_mapped;
*/
FFTContext mdct;
FFTContext mdct_small;
+ FFTContext mdct_ld;
FFTContext mdct_ltp;
- DSPContext dsp;
- FmtConvertContext fmt_conv;
+ IMDCT15Context *mdct480;
+ AVFloatDSPContext fdsp;
int random_state;
/** @} */
/**
- * @name Members used for output interleaving
+ * @name Members used for output
* @{
*/
- float *output_data[MAX_CHANNELS]; ///< Points to each element's 'ret' buffer (PCM output).
+ SingleChannelElement *output_element[MAX_CHANNELS]; ///< Points to each SingleChannelElement
/** @} */
DECLARE_ALIGNED(32, float, temp)[128];
- enum OCStatus output_configured;
+ OutputConfiguration oc[2];
} AACContext;
#endif /* AVCODEC_AAC_H */