diff options
author | Djordje Pesut <djordje.pesut@imgtec.com> | 2015-06-30 11:53:05 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2015-07-09 14:41:31 +0200 |
commit | b04f46cb4bc07e41345f360e184ea4b3eab6e43f (patch) | |
tree | f39eb060d72fe39219b2dcbc7d7a51b7a35c7570 /libavcodec/aac.h | |
parent | 08be74ac8154e4a8936b7023cc3a7f5396fb182c (diff) | |
download | ffmpeg-b04f46cb4bc07e41345f360e184ea4b3eab6e43f.tar.gz |
libavcodec: Implementation of AAC_fixed_decoder (LC-module) [3/4]
Add fixed point implementation
Signed-off-by: Nedeljko Babic <nedeljko.babic@imgtec.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/aac.h')
-rw-r--r-- | libavcodec/aac.h | 80 |
1 files changed, 59 insertions, 21 deletions
diff --git a/libavcodec/aac.h b/libavcodec/aac.h index 04553e7a46..f6fd446952 100644 --- a/libavcodec/aac.h +++ b/libavcodec/aac.h @@ -41,21 +41,53 @@ #define FFT_FLOAT 0 #define FFT_FIXED_32 1 +#define AAC_RENAME(x) x ## _fixed +#define AAC_RENAME_32(x) x ## _fixed_32 +#define AAC_FLOAT SoftFloat +#define INTFLOAT int +#define SHORTFLOAT int16_t +#define AAC_SIGNE int +#define FIXR(a) ((int)((a) * 1 + 0.5)) +#define FIXR10(a) ((int)((a) * 1024.0 + 0.5)) +#define Q23(a) (int)((a) * 8388608.0 + 0.5) #define Q30(x) (int)((x)*1073741824.0 + 0.5) #define Q31(x) (int)((x)*2147483648.0 + 0.5) +#define RANGE15(x) x +#define GET_GAIN(x, y) (-(y) << (x)) + 1024 +#define AAC_MUL26(x, y) (int)(((int64_t)(x) * (y) + 0x2000000) >> 26) +#define AAC_MUL30(x, y) (int)(((int64_t)(x) * (y) + 0x20000000) >> 30) +#define AAC_MUL31(x, y) (int)(((int64_t)(x) * (y) + 0x40000000) >> 31) #else #define FFT_FLOAT 1 #define FFT_FIXED_32 0 +#define AAC_RENAME(x) x +#define AAC_RENAME_32(x) x +#define AAC_FLOAT float +#define INTFLOAT float +#define SHORTFLOAT float +#define AAC_SIGNE unsigned +#define FIXR(x) ((float)(x)) +#define FIXR10(x) ((float)(x)) +#define Q23(x) x #define Q30(x) x #define Q31(x) x +#define RANGE15(x) (32768.0 * (x)) +#define GET_GAIN(x, y) powf((x), -(y)) +#define AAC_MUL26(x, y) ((x) * (y)) +#define AAC_MUL30(x, y) ((x) * (y)) +#define AAC_MUL31(x, y) ((x) * (y)) + #endif /* USE_FIXED */ #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" @@ -149,12 +181,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 @@ -175,7 +207,7 @@ typedef struct PredictorState { typedef struct LongTermPrediction { int8_t present; int16_t lag; - float coef; + INTFLOAT coef; int8_t used[MAX_LTP_LONG_SFB]; } LongTermPrediction; @@ -209,7 +241,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; /** @@ -246,7 +278,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; /** @@ -258,18 +290,18 @@ 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) float is_ener[128]; ///< Intensity stereo pos (used by encoder) float pns_ener[128]; ///< Noise energy values (used by encoder) - DECLARE_ALIGNED(32, float, pcoeffs)[1024]; ///< coefficients for IMDCT, pristine - DECLARE_ALIGNED(32, float, coeffs)[1024]; ///< coefficients for IMDCT, maybe processed - 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 + 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; /** @@ -316,7 +348,7 @@ 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]; /** @} */ /** @@ -327,8 +359,12 @@ struct AACContext { FFTContext mdct_small; FFTContext mdct_ld; FFTContext mdct_ltp; +#if USE_FIXED + AVFixedDSPContext *fdsp; +#else IMDCT15Context *mdct480; AVFloatDSPContext *fdsp; +#endif /* USE_FIXED */ int random_state; /** @} */ @@ -348,7 +384,7 @@ struct AACContext { int dmono_mode; ///< 0->not dmono, 1->use first channel, 2->use second channel /** @} */ - DECLARE_ALIGNED(32, float, temp)[128]; + DECLARE_ALIGNED(32, INTFLOAT, temp)[128]; OutputConfiguration oc[2]; int warned_num_aac_frames; @@ -356,11 +392,13 @@ struct AACContext { /* aacdec functions pointers */ void (*imdct_and_windowing)(AACContext *ac, SingleChannelElement *sce); void (*apply_ltp)(AACContext *ac, SingleChannelElement *sce); - void (*apply_tns)(float coef[1024], TemporalNoiseShaping *tns, + void (*apply_tns)(INTFLOAT coef[1024], TemporalNoiseShaping *tns, IndividualChannelStream *ics, int decode); - void (*windowing_and_mdct_ltp)(AACContext *ac, float *out, - float *in, IndividualChannelStream *ics); + 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); }; |