1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

nellymoserdec: drop support for s16 output.

It internally decodes as float and then converts to s16 by a call to
float_to_int16(). The caller can do this just as well by using lavr.
This commit is contained in:
Anton Khirnov 2012-07-22 11:19:01 +02:00
parent 8b78c2969a
commit 66f52d0c3d

View File

@ -48,13 +48,11 @@
typedef struct NellyMoserDecodeContext { typedef struct NellyMoserDecodeContext {
AVCodecContext* avctx; AVCodecContext* avctx;
AVFrame frame; AVFrame frame;
float *float_buf;
AVLFG random_state; AVLFG random_state;
GetBitContext gb; GetBitContext gb;
float scale_bias; float scale_bias;
DSPContext dsp; DSPContext dsp;
FFTContext imdct_ctx; FFTContext imdct_ctx;
FmtConvertContext fmt_conv;
DECLARE_ALIGNED(32, float, imdct_buf)[2][NELLY_BUF_LEN]; DECLARE_ALIGNED(32, float, imdct_buf)[2][NELLY_BUF_LEN];
float *imdct_out; float *imdct_out;
float *imdct_prev; float *imdct_prev;
@ -124,19 +122,8 @@ static av_cold int decode_init(AVCodecContext * avctx) {
ff_dsputil_init(&s->dsp, avctx); ff_dsputil_init(&s->dsp, avctx);
if (avctx->request_sample_fmt == AV_SAMPLE_FMT_FLT) { s->scale_bias = 1.0/(32768*8);
s->scale_bias = 1.0/(32768*8); avctx->sample_fmt = AV_SAMPLE_FMT_FLT;
avctx->sample_fmt = AV_SAMPLE_FMT_FLT;
} else {
s->scale_bias = 1.0/(1*8);
avctx->sample_fmt = AV_SAMPLE_FMT_S16;
ff_fmt_convert_init(&s->fmt_conv, avctx);
s->float_buf = av_mallocz(NELLY_SAMPLES * sizeof(*s->float_buf));
if (!s->float_buf) {
av_log(avctx, AV_LOG_ERROR, "error allocating float buffer\n");
return AVERROR(ENOMEM);
}
}
/* Generate overlap window */ /* Generate overlap window */
if (!ff_sine_128[127]) if (!ff_sine_128[127])
@ -157,7 +144,6 @@ static int decode_tag(AVCodecContext *avctx, void *data,
int buf_size = avpkt->size; int buf_size = avpkt->size;
NellyMoserDecodeContext *s = avctx->priv_data; NellyMoserDecodeContext *s = avctx->priv_data;
int blocks, i, ret; int blocks, i, ret;
int16_t *samples_s16;
float *samples_flt; float *samples_flt;
blocks = buf_size / NELLY_BLOCK_LEN; blocks = buf_size / NELLY_BLOCK_LEN;
@ -183,18 +169,11 @@ static int decode_tag(AVCodecContext *avctx, void *data,
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return ret; return ret;
} }
samples_s16 = (int16_t *)s->frame.data[0];
samples_flt = (float *)s->frame.data[0]; samples_flt = (float *)s->frame.data[0];
for (i=0 ; i<blocks ; i++) { for (i=0 ; i<blocks ; i++) {
if (avctx->sample_fmt == AV_SAMPLE_FMT_FLT) { nelly_decode_block(s, buf, samples_flt);
nelly_decode_block(s, buf, samples_flt); samples_flt += NELLY_SAMPLES;
samples_flt += NELLY_SAMPLES;
} else {
nelly_decode_block(s, buf, s->float_buf);
s->fmt_conv.float_to_int16(samples_s16, s->float_buf, NELLY_SAMPLES);
samples_s16 += NELLY_SAMPLES;
}
buf += NELLY_BLOCK_LEN; buf += NELLY_BLOCK_LEN;
} }
@ -207,7 +186,6 @@ static int decode_tag(AVCodecContext *avctx, void *data,
static av_cold int decode_end(AVCodecContext * avctx) { static av_cold int decode_end(AVCodecContext * avctx) {
NellyMoserDecodeContext *s = avctx->priv_data; NellyMoserDecodeContext *s = avctx->priv_data;
av_freep(&s->float_buf);
ff_mdct_end(&s->imdct_ctx); ff_mdct_end(&s->imdct_ctx);
return 0; return 0;
@ -224,6 +202,5 @@ AVCodec ff_nellymoser_decoder = {
.capabilities = CODEC_CAP_DR1 | CODEC_CAP_PARAM_CHANGE, .capabilities = CODEC_CAP_DR1 | CODEC_CAP_PARAM_CHANGE,
.long_name = NULL_IF_CONFIG_SMALL("Nellymoser Asao"), .long_name = NULL_IF_CONFIG_SMALL("Nellymoser Asao"),
.sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLT, .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLT,
AV_SAMPLE_FMT_S16,
AV_SAMPLE_FMT_NONE }, AV_SAMPLE_FMT_NONE },
}; };