summaryrefslogtreecommitdiff
path: root/libavcodec/aac.h
diff options
context:
space:
mode:
Diffstat (limited to 'libavcodec/aac.h')
-rw-r--r--libavcodec/aac.h104
1 files changed, 77 insertions, 27 deletions
diff --git a/libavcodec/aac.h b/libavcodec/aac.h
index fed6bf4214..3e3e479986 100644
--- a/libavcodec/aac.h
+++ b/libavcodec/aac.h
@@ -3,20 +3,20 @@
* Copyright (c) 2005-2006 Oded Shimon ( ods15 ods15 dyndns org )
* Copyright (c) 2006-2007 Maxim Gavrilov ( maxim.gavrilov gmail com )
*
- * This file is part of Libav.
+ * This file is part of FFmpeg.
*
- * Libav is free software; you can redistribute it and/or
+ * FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
- * Libav is distributed in the hope that it will be useful,
+ * FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
+ * License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
@@ -30,9 +30,14 @@
#ifndef AVCODEC_AAC_H
#define AVCODEC_AAC_H
+
+#include "aac_defines.h"
#include "libavutil/float_dsp.h"
+#include "libavutil/fixed_dsp.h"
#include "avcodec.h"
+#if !USE_FIXED
#include "imdct15.h"
+#endif
#include "fft.h"
#include "mpeg4audio.h"
#include "sbr.h"
@@ -45,6 +50,8 @@
#define TNS_MAX_ORDER 20
#define MAX_LTP_LONG_SFB 40
+#define CLIP_AVOIDANCE_FACTOR 0.95f
+
enum RawDataBlockType {
TYPE_SCE,
TYPE_CPE,
@@ -76,12 +83,13 @@ enum BandType {
ZERO_BT = 0, ///< Scalefactors and spectral data are all zero.
FIRST_PAIR_BT = 5, ///< This and later band types encode two values (rather than four) with one code word.
ESC_BT = 11, ///< Spectral data are coded with an escape sequence.
+ RESERVED_BT = 12, ///< Band types following are encoded differently from others.
NOISE_BT = 13, ///< Spectral data are scaled white noise not coded in the bitstream.
- INTENSITY_BT2 = 14, ///< Scalefactor data are intensity stereo positions.
- INTENSITY_BT = 15, ///< Scalefactor data are intensity stereo positions.
+ INTENSITY_BT2 = 14, ///< Scalefactor data are intensity stereo positions (out of phase).
+ INTENSITY_BT = 15, ///< Scalefactor data are intensity stereo positions (in phase).
};
-#define IS_CODEBOOK_UNSIGNED(x) ((x - 1) & 10)
+#define IS_CODEBOOK_UNSIGNED(x) (((x) - 1) & 10)
enum ChannelPosition {
AAC_CHANNEL_OFF = 0,
@@ -125,12 +133,12 @@ typedef struct OutputConfiguration {
* Predictor State
*/
typedef struct PredictorState {
- float cor0;
- float cor1;
- float var0;
- float var1;
- float r0;
- float r1;
+ AAC_FLOAT cor0;
+ AAC_FLOAT cor1;
+ AAC_FLOAT var0;
+ AAC_FLOAT var1;
+ AAC_FLOAT r0;
+ AAC_FLOAT r1;
} PredictorState;
#define MAX_PREDICTORS 672
@@ -141,13 +149,17 @@ typedef struct PredictorState {
#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 NOISE_PRE 256 ///< preamble for NOISE_BT, put in bitstream with the first noise band
+#define NOISE_PRE_BITS 9 ///< length of preamble
+#define NOISE_OFFSET 90 ///< subtracted from global gain, used as offset for the preamble
+
/**
* Long Term Prediction
*/
typedef struct LongTermPrediction {
int8_t present;
int16_t lag;
- float coef;
+ INTFLOAT coef;
int8_t used[MAX_LTP_LONG_SFB];
} LongTermPrediction;
@@ -170,6 +182,8 @@ typedef struct IndividualChannelStream {
int predictor_initialized;
int predictor_reset_group;
uint8_t prediction_used[41];
+ uint8_t window_clipping[8]; ///< set if a certain window is near clipping
+ float clip_avoidance_factor; ///< set if any window is near clipping to the necessary atennuation factor to avoid it
} IndividualChannelStream;
/**
@@ -181,7 +195,7 @@ typedef struct TemporalNoiseShaping {
int length[8][4];
int direction[8][4];
int order[8][4];
- float coef[8][4][TNS_MAX_ORDER];
+ INTFLOAT coef[8][4][TNS_MAX_ORDER];
} TemporalNoiseShaping;
/**
@@ -218,7 +232,7 @@ typedef struct ChannelCoupling {
int ch_select[8]; /**< [0] shared list of gains; [1] list of gains for right channel;
* [2] list of gains for left channel; [3] lists of gains for both channels
*/
- float gain[16][120];
+ INTFLOAT gain[16][120];
} ChannelCoupling;
/**
@@ -230,25 +244,31 @@ typedef struct SingleChannelElement {
Pulse pulse;
enum BandType band_type[128]; ///< band types
int band_type_run_end[120]; ///< band type run end points
- float sf[120]; ///< scalefactors
+ INTFLOAT sf[120]; ///< scalefactors
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)[1536]; ///< overlap
- DECLARE_ALIGNED(32, float, ret_buf)[2048]; ///< PCM output buffer
- DECLARE_ALIGNED(16, float, ltp_state)[3072]; ///< time signal for LTP
+ float is_ener[128]; ///< Intensity stereo pos (used by encoder)
+ float pns_ener[128]; ///< Noise energy values (used by encoder)
+ DECLARE_ALIGNED(32, INTFLOAT, pcoeffs)[1024]; ///< coefficients for IMDCT, pristine
+ DECLARE_ALIGNED(32, INTFLOAT, coeffs)[1024]; ///< coefficients for IMDCT, maybe processed
+ DECLARE_ALIGNED(32, INTFLOAT, saved)[1536]; ///< overlap
+ DECLARE_ALIGNED(32, INTFLOAT, ret_buf)[2048]; ///< PCM output buffer
+ DECLARE_ALIGNED(16, INTFLOAT, ltp_state)[3072]; ///< time signal for LTP
PredictorState predictor_state[MAX_PREDICTORS];
- float *ret; ///< PCM output
+ INTFLOAT *ret; ///< PCM output
} SingleChannelElement;
/**
* channel element - generic struct for SCE/CPE/CCE/LFE
*/
typedef struct ChannelElement {
+ int present;
// 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)
+ uint8_t is_mode; ///< Set if any bands have been encoded using intensity stereo (used by encoder)
uint8_t ms_mask[128]; ///< Set if mid/side stereo is used for each scalefactor window band
+ uint8_t is_mask[128]; ///< Set if intensity stereo is used (used by encoder)
// shared
SingleChannelElement ch[2];
// CCE specific
@@ -259,7 +279,8 @@ typedef struct ChannelElement {
/**
* main AAC context
*/
-typedef struct AACContext {
+struct AACContext {
+ AVClass *class;
AVCodecContext *avctx;
AVFrame *frame;
@@ -273,6 +294,7 @@ typedef struct AACContext {
ChannelElement *che[4][MAX_ELEM_ID];
ChannelElement *tag_che_map[4][MAX_ELEM_ID];
int tags_mapped;
+ int warned_remapping_once;
/** @} */
/**
@@ -280,7 +302,7 @@ typedef struct AACContext {
* (We do not want to have these on the stack.)
* @{
*/
- DECLARE_ALIGNED(32, float, buf_mdct)[1024];
+ DECLARE_ALIGNED(32, INTFLOAT, buf_mdct)[1024];
/** @} */
/**
@@ -291,8 +313,12 @@ typedef struct AACContext {
FFTContext mdct_small;
FFTContext mdct_ld;
FFTContext mdct_ltp;
+#if USE_FIXED
+ AVFixedDSPContext *fdsp;
+#else
IMDCT15Context *mdct480;
- AVFloatDSPContext fdsp;
+ AVFloatDSPContext *fdsp;
+#endif /* USE_FIXED */
int random_state;
/** @} */
@@ -303,9 +329,33 @@ typedef struct AACContext {
SingleChannelElement *output_element[MAX_CHANNELS]; ///< Points to each SingleChannelElement
/** @} */
- DECLARE_ALIGNED(32, float, temp)[128];
+
+ /**
+ * @name Japanese DTV specific extension
+ * @{
+ */
+ int force_dmono_mode;///< 0->not dmono, 1->use first channel, 2->use second channel
+ int dmono_mode; ///< 0->not dmono, 1->use first channel, 2->use second channel
+ /** @} */
+
+ DECLARE_ALIGNED(32, INTFLOAT, temp)[128];
OutputConfiguration oc[2];
-} AACContext;
+ int warned_num_aac_frames;
+
+ /* aacdec functions pointers */
+ void (*imdct_and_windowing)(AACContext *ac, SingleChannelElement *sce);
+ void (*apply_ltp)(AACContext *ac, SingleChannelElement *sce);
+ void (*apply_tns)(INTFLOAT coef[1024], TemporalNoiseShaping *tns,
+ IndividualChannelStream *ics, int decode);
+ void (*windowing_and_mdct_ltp)(AACContext *ac, INTFLOAT *out,
+ INTFLOAT *in, IndividualChannelStream *ics);
+ void (*update_ltp)(AACContext *ac, SingleChannelElement *sce);
+ void (*vector_pow43)(int *coefs, int len);
+ void (*subband_scale)(int *dst, int *src, int scale, int offset, int len);
+
+};
+
+void ff_aacdec_init_mips(AACContext *c);
#endif /* AVCODEC_AAC_H */