diff options
author | Mans Rullgard <mans@mansr.com> | 2011-03-21 18:07:59 +0000 |
---|---|---|
committer | Mans Rullgard <mans@mansr.com> | 2011-04-03 19:01:53 +0100 |
commit | 79997def65fd2313b48a5f3c3a884c6149ae9b5d (patch) | |
tree | e137d4180c580bc28ada1bcb60a4aea66ac01729 /libavcodec/ac3enc.c | |
parent | aadfc9ee747eeb37f9ea77c0cc56a88226b9d21b (diff) | |
download | ffmpeg-79997def65fd2313b48a5f3c3a884c6149ae9b5d.tar.gz |
ac3enc: use generic fixed-point mdct
This makes the AC3 encoder use the shared fixed-point MDCT rather
than its own implementation. The checksum changes are due to
different rounding in the MDCT.
Signed-off-by: Mans Rullgard <mans@mansr.com>
Diffstat (limited to 'libavcodec/ac3enc.c')
-rw-r--r-- | libavcodec/ac3enc.c | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c index a869d7de9d..372f019f64 100644 --- a/libavcodec/ac3enc.c +++ b/libavcodec/ac3enc.c @@ -29,6 +29,8 @@ //#define DEBUG //#define ASSERT_LEVEL 2 +#include <stdint.h> + #include "libavutil/audioconvert.h" #include "libavutil/avassert.h" #include "libavutil/crc.h" @@ -39,6 +41,7 @@ #include "ac3dsp.h" #include "ac3.h" #include "audioconvert.h" +#include "fft.h" #ifndef CONFIG_AC3ENC_FLOAT @@ -55,16 +58,22 @@ #define AC3_REMATRIXING_NONE 1 #define AC3_REMATRIXING_ALWAYS 3 -/** Scale a float value by 2^bits and convert to an integer. */ -#define SCALE_FLOAT(a, bits) lrintf((a) * (float)(1 << (bits))) - - #if CONFIG_AC3ENC_FLOAT -#include "ac3enc_float.h" +#define MAC_COEF(d,a,b) ((d)+=(a)*(b)) +typedef float SampleType; +typedef float CoefType; +typedef float CoefSumType; #else -#include "ac3enc_fixed.h" +#define MAC_COEF(d,a,b) MAC64(d,a,b) +typedef int16_t SampleType; +typedef int32_t CoefType; +typedef int64_t CoefSumType; #endif +typedef struct AC3MDCTContext { + const SampleType *window; ///< MDCT window function + FFTContext fft; ///< FFT context for MDCT calculation +} AC3MDCTContext; /** * Encoding Options used by AVOption. @@ -279,8 +288,6 @@ static av_cold void mdct_end(AC3MDCTContext *mdct); static av_cold int mdct_init(AVCodecContext *avctx, AC3MDCTContext *mdct, int nbits); -static void mdct512(AC3MDCTContext *mdct, CoefType *out, SampleType *in); - static void apply_window(DSPContext *dsp, SampleType *output, const SampleType *input, const SampleType *window, unsigned int len); @@ -386,7 +393,8 @@ static void apply_mdct(AC3EncodeContext *s) block->coeff_shift[ch] = normalize_samples(s); - mdct512(&s->mdct, block->mdct_coef[ch], s->windowed_samples); + s->mdct.fft.mdct_calcw(&s->mdct.fft, block->mdct_coef[ch], + s->windowed_samples); } } } |