Mercurial > libavcodec.hg
changeset 2479:dfdb6bf4b90f libavcodec
support 32bit output for the mpeg audio decoder
author | michael |
---|---|
date | Mon, 31 Jan 2005 12:16:21 +0000 |
parents | 6744ea5ff950 |
children | 5252700f61df |
files | avcodec.h mpegaudiodec.c |
diffstat | 2 files changed, 45 insertions(+), 23 deletions(-) [+] |
line wrap: on
line diff
--- a/avcodec.h Mon Jan 31 04:06:47 2005 +0000 +++ b/avcodec.h Mon Jan 31 12:16:21 2005 +0000 @@ -17,7 +17,7 @@ #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 @@ /* 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 @@ /** * 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 @@ /* 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'
--- a/mpegaudiodec.c Mon Jan 31 04:06:47 2005 +0000 +++ b/mpegaudiodec.c Mon Jan 31 12:16:21 2005 +0000 @@ -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 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 @@ 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 @@ 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 @@ 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 @@ /* 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_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 @@ #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 @@ 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 @@ MPADecodeContext *s = avctx->priv_data; uint32_t header; int len, out_size; - short *out_samples = data; + OUT_INT *out_samples = data; len = buf_size;