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:
		
							parent
							
								
									8b78c2969a
								
							
						
					
					
						commit
						66f52d0c3d
					
				@ -48,13 +48,11 @@
 | 
			
		||||
typedef struct NellyMoserDecodeContext {
 | 
			
		||||
    AVCodecContext* avctx;
 | 
			
		||||
    AVFrame         frame;
 | 
			
		||||
    float          *float_buf;
 | 
			
		||||
    AVLFG           random_state;
 | 
			
		||||
    GetBitContext   gb;
 | 
			
		||||
    float           scale_bias;
 | 
			
		||||
    DSPContext      dsp;
 | 
			
		||||
    FFTContext      imdct_ctx;
 | 
			
		||||
    FmtConvertContext fmt_conv;
 | 
			
		||||
    DECLARE_ALIGNED(32, float, imdct_buf)[2][NELLY_BUF_LEN];
 | 
			
		||||
    float          *imdct_out;
 | 
			
		||||
    float          *imdct_prev;
 | 
			
		||||
@ -124,19 +122,8 @@ static av_cold int decode_init(AVCodecContext * avctx) {
 | 
			
		||||
 | 
			
		||||
    ff_dsputil_init(&s->dsp, avctx);
 | 
			
		||||
 | 
			
		||||
    if (avctx->request_sample_fmt == AV_SAMPLE_FMT_FLT) {
 | 
			
		||||
        s->scale_bias = 1.0/(32768*8);
 | 
			
		||||
        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);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    s->scale_bias = 1.0/(32768*8);
 | 
			
		||||
    avctx->sample_fmt = AV_SAMPLE_FMT_FLT;
 | 
			
		||||
 | 
			
		||||
    /* Generate overlap window */
 | 
			
		||||
    if (!ff_sine_128[127])
 | 
			
		||||
@ -157,7 +144,6 @@ static int decode_tag(AVCodecContext *avctx, void *data,
 | 
			
		||||
    int buf_size = avpkt->size;
 | 
			
		||||
    NellyMoserDecodeContext *s = avctx->priv_data;
 | 
			
		||||
    int blocks, i, ret;
 | 
			
		||||
    int16_t *samples_s16;
 | 
			
		||||
    float   *samples_flt;
 | 
			
		||||
 | 
			
		||||
    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");
 | 
			
		||||
        return ret;
 | 
			
		||||
    }
 | 
			
		||||
    samples_s16 = (int16_t *)s->frame.data[0];
 | 
			
		||||
    samples_flt = (float   *)s->frame.data[0];
 | 
			
		||||
 | 
			
		||||
    for (i=0 ; i<blocks ; i++) {
 | 
			
		||||
        if (avctx->sample_fmt == AV_SAMPLE_FMT_FLT) {
 | 
			
		||||
            nelly_decode_block(s, buf, samples_flt);
 | 
			
		||||
            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;
 | 
			
		||||
        }
 | 
			
		||||
        nelly_decode_block(s, buf, samples_flt);
 | 
			
		||||
        samples_flt += NELLY_SAMPLES;
 | 
			
		||||
        buf += NELLY_BLOCK_LEN;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -207,7 +186,6 @@ static int decode_tag(AVCodecContext *avctx, void *data,
 | 
			
		||||
static av_cold int decode_end(AVCodecContext * avctx) {
 | 
			
		||||
    NellyMoserDecodeContext *s = avctx->priv_data;
 | 
			
		||||
 | 
			
		||||
    av_freep(&s->float_buf);
 | 
			
		||||
    ff_mdct_end(&s->imdct_ctx);
 | 
			
		||||
 | 
			
		||||
    return 0;
 | 
			
		||||
@ -224,6 +202,5 @@ AVCodec ff_nellymoser_decoder = {
 | 
			
		||||
    .capabilities   = CODEC_CAP_DR1 | CODEC_CAP_PARAM_CHANGE,
 | 
			
		||||
    .long_name      = NULL_IF_CONFIG_SMALL("Nellymoser Asao"),
 | 
			
		||||
    .sample_fmts    = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLT,
 | 
			
		||||
                                                      AV_SAMPLE_FMT_S16,
 | 
			
		||||
                                                      AV_SAMPLE_FMT_NONE },
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user