diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2005-01-31 12:16:21 +0000 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2005-01-31 12:16:21 +0000 |
commit | a3a5f4d6c3bf996c727061df2d394aa7bc10f30e (patch) | |
tree | 521fd2b57500fee258b54c9d150c223e2f094224 | |
parent | b696d2a67667cacce204943a7d283560a53f7874 (diff) | |
download | ffmpeg-a3a5f4d6c3bf996c727061df2d394aa7bc10f30e.tar.gz |
support 32bit output for the mpeg audio decoder
Originally committed as revision 3910 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r-- | libavcodec/avcodec.h | 18 | ||||
-rw-r--r-- | libavcodec/mpegaudiodec.c | 50 |
2 files changed, 45 insertions, 23 deletions
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 503a04e083..0b62582a65 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -17,7 +17,7 @@ extern "C" { #define FFMPEG_VERSION_INT 0x000409 #define FFMPEG_VERSION "0.4.9-pre1" -#define LIBAVCODEC_BUILD 4738 +#define LIBAVCODEC_BUILD 4739 #define LIBAVCODEC_VERSION_INT FFMPEG_VERSION_INT #define LIBAVCODEC_VERSION FFMPEG_VERSION @@ -224,6 +224,9 @@ enum PixelFormat { /* currently unused, may be used if 24/32 bits samples ever supported */ enum SampleFormat { SAMPLE_FMT_S16 = 0, ///< signed 16 bits + SAMPLE_FMT_S32, ///< signed 32 bits + SAMPLE_FMT_FLT, ///< float + SAMPLE_FMT_DBL, ///< double }; /* in bytes */ @@ -734,10 +737,7 @@ typedef struct AVCodecContext { /** * pixel format, see PIX_FMT_xxx. - * - encoding: FIXME: used by ffmpeg to decide whether an pix_fmt - * conversion is in order. This only works for - * codecs with one supported pix_fmt, we should - * do something for a generic case as well. + * - encoding: set by user. * - decoding: set by lavc. */ enum PixelFormat pix_fmt; @@ -769,7 +769,13 @@ typedef struct AVCodecContext { /* audio only */ int sample_rate; ///< samples per sec int channels; - int sample_fmt; ///< sample format, currenly unused + + /** + * audio sample format. + * - encoding: set by user. + * - decoding: set by lavc. + */ + enum SampleFormat sample_fmt; ///< sample format, currenly unused /* the following data should not be initialized */ int frame_size; ///< in samples, initialized when calling 'init' diff --git a/libavcodec/mpegaudiodec.c b/libavcodec/mpegaudiodec.c index cd48e8422f..ab533e1a31 100644 --- a/libavcodec/mpegaudiodec.c +++ b/libavcodec/mpegaudiodec.c @@ -48,6 +48,18 @@ #define WFRAC_BITS 14 /* fractional bits for window */ #endif +#if defined(USE_HIGHPRECISION) && defined(CONFIG_AUDIO_NONSHORT) +typedef int32_t OUT_INT; +#define OUT_MAX INT32_MAX +#define OUT_MIN INT32_MIN +#define OUT_SHIFT (WFRAC_BITS + FRAC_BITS - 31) +#else +typedef int16_t OUT_INT; +#define OUT_MAX INT16_MAX +#define OUT_MIN INT16_MIN +#define OUT_SHIFT (WFRAC_BITS + FRAC_BITS - 15) +#endif + #define FRAC_ONE (1 << FRAC_BITS) #define MULL(a,b) (((int64_t)(a) * (int64_t)(b)) >> FRAC_BITS) @@ -324,6 +336,12 @@ static int decode_init(AVCodecContext * avctx) static int init=0; int i, j, k; +#if defined(USE_HIGHPRECISION) && defined(CONFIG_AUDIO_NONSHORT) + avctx->sample_fmt= SAMPLE_FMT_S32; +#else + avctx->sample_fmt= SAMPLE_FMT_S16; +#endif + if(avctx->antialias_algo == FF_AA_INT) s->compute_antialias= compute_antialias_integer; else @@ -748,8 +766,6 @@ static void dct32(int32_t *out, int32_t *tab) out[31] = tab[31]; } -#define OUT_SHIFT (WFRAC_BITS + FRAC_BITS - 15) - #if FRAC_BITS <= 15 static inline int round_sample(int *sum) @@ -757,10 +773,10 @@ static inline int round_sample(int *sum) int sum1; sum1 = (*sum) >> OUT_SHIFT; *sum &= (1<<OUT_SHIFT)-1; - if (sum1 < -32768) - sum1 = -32768; - else if (sum1 > 32767) - sum1 = 32767; + if (sum1 < OUT_MIN) + sum1 = OUT_MIN; + else if (sum1 > OUT_MAX) + sum1 = OUT_MAX; return sum1; } @@ -791,10 +807,10 @@ static inline int round_sample(int64_t *sum) int sum1; sum1 = (int)((*sum) >> OUT_SHIFT); *sum &= (1<<OUT_SHIFT)-1; - if (sum1 < -32768) - sum1 = -32768; - else if (sum1 > 32767) - sum1 = 32767; + if (sum1 < OUT_MIN) + sum1 = OUT_MIN; + else if (sum1 > OUT_MAX) + sum1 = OUT_MAX; return sum1; } @@ -867,14 +883,14 @@ void ff_mpa_synth_init(MPA_INT *window) /* XXX: optimize by avoiding ring buffer usage */ void ff_mpa_synth_filter(MPA_INT *synth_buf_ptr, int *synth_buf_offset, MPA_INT *window, int *dither_state, - int16_t *samples, int incr, + OUT_INT *samples, int incr, int32_t sb_samples[SBLIMIT]) { int32_t tmp[32]; register MPA_INT *synth_buf; register const MPA_INT *w, *w2, *p; int j, offset, v; - int16_t *samples2; + OUT_INT *samples2; #if FRAC_BITS <= 15 int sum, sum2; #else @@ -2455,10 +2471,10 @@ static int mp_decode_layer3(MPADecodeContext *s) } static int mp_decode_frame(MPADecodeContext *s, - short *samples) + OUT_INT *samples) { int i, nb_frames, ch; - short *samples_ptr; + OUT_INT *samples_ptr; init_get_bits(&s->gb, s->inbuf + HEADER_SIZE, (s->inbuf_ptr - s->inbuf - HEADER_SIZE)*8); @@ -2505,7 +2521,7 @@ static int mp_decode_frame(MPADecodeContext *s, #ifdef DEBUG s->frame_count++; #endif - return nb_frames * 32 * sizeof(short) * s->nb_channels; + return nb_frames * 32 * sizeof(OUT_INT) * s->nb_channels; } static int decode_frame(AVCodecContext * avctx, @@ -2516,7 +2532,7 @@ static int decode_frame(AVCodecContext * avctx, uint32_t header; uint8_t *buf_ptr; int len, out_size; - short *out_samples = data; + OUT_INT *out_samples = data; buf_ptr = buf; while (buf_size > 0) { @@ -2674,7 +2690,7 @@ static int decode_frame_adu(AVCodecContext * avctx, MPADecodeContext *s = avctx->priv_data; uint32_t header; int len, out_size; - short *out_samples = data; + OUT_INT *out_samples = data; len = buf_size; |