X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fnellymoserenc.c;h=98c2b390cc477ca45696dcf62b75e61a198f4e01;hb=18f4fa251b0eb36392839f5bf6180f280dc04d8d;hp=122282623cdea5b5a81fdcfbba39ea6b3decda1f;hpb=1d7ffd06e41e44d8932d0dd62caa2da17947d8c4;p=ffmpeg diff --git a/libavcodec/nellymoserenc.c b/libavcodec/nellymoserenc.c index 122282623cd..98c2b390cc4 100644 --- a/libavcodec/nellymoserenc.c +++ b/libavcodec/nellymoserenc.c @@ -35,14 +35,15 @@ * http://wiki.multimedia.cx/index.php?title=Nellymoser */ +#include "libavutil/common.h" #include "libavutil/float_dsp.h" #include "libavutil/mathematics.h" -#include "nellymoser.h" -#include "avcodec.h" + #include "audio_frame_queue.h" -#include "dsputil.h" +#include "avcodec.h" #include "fft.h" #include "internal.h" +#include "nellymoser.h" #include "sinewin.h" #define BITSTREAM_WRITER_LE @@ -55,15 +56,14 @@ typedef struct NellyMoserEncodeContext { AVCodecContext *avctx; int last_frame; - DSPContext dsp; AVFloatDSPContext fdsp; FFTContext mdct_ctx; AudioFrameQueue afq; DECLARE_ALIGNED(32, float, mdct_out)[NELLY_SAMPLES]; DECLARE_ALIGNED(32, float, in_buff)[NELLY_SAMPLES]; DECLARE_ALIGNED(32, float, buf)[3 * NELLY_BUF_LEN]; ///< sample buffer - float (*opt )[NELLY_BANDS]; - uint8_t (*path)[NELLY_BANDS]; + float (*opt )[OPT_SIZE]; + uint8_t (*path)[OPT_SIZE]; } NellyMoserEncodeContext; static float pow_table[POW_TABLE_SIZE]; ///< -pow(2, -i / 2048.0 - 3.0); @@ -122,12 +122,12 @@ static void apply_mdct(NellyMoserEncodeContext *s) float *in1 = s->buf + NELLY_BUF_LEN; float *in2 = s->buf + 2 * NELLY_BUF_LEN; - s->fdsp.vector_fmul (s->in_buff, in0, ff_sine_128, NELLY_BUF_LEN); - s->dsp.vector_fmul_reverse(s->in_buff + NELLY_BUF_LEN, in1, ff_sine_128, NELLY_BUF_LEN); + s->fdsp.vector_fmul (s->in_buff, in0, ff_sine_128, NELLY_BUF_LEN); + s->fdsp.vector_fmul_reverse(s->in_buff + NELLY_BUF_LEN, in1, ff_sine_128, NELLY_BUF_LEN); s->mdct_ctx.mdct_calc(&s->mdct_ctx, s->mdct_out, s->in_buff); - s->fdsp.vector_fmul (s->in_buff, in1, ff_sine_128, NELLY_BUF_LEN); - s->dsp.vector_fmul_reverse(s->in_buff + NELLY_BUF_LEN, in2, ff_sine_128, NELLY_BUF_LEN); + s->fdsp.vector_fmul (s->in_buff, in1, ff_sine_128, NELLY_BUF_LEN); + s->fdsp.vector_fmul_reverse(s->in_buff + NELLY_BUF_LEN, in2, ff_sine_128, NELLY_BUF_LEN); s->mdct_ctx.mdct_calc(&s->mdct_ctx, s->mdct_out + NELLY_BUF_LEN, s->in_buff); } @@ -142,9 +142,6 @@ static av_cold int encode_end(AVCodecContext *avctx) av_free(s->path); } ff_af_queue_close(&s->afq); -#if FF_API_OLD_ENCODE_AUDIO - av_freep(&avctx->coded_frame); -#endif return 0; } @@ -168,12 +165,11 @@ static av_cold int encode_init(AVCodecContext *avctx) } avctx->frame_size = NELLY_SAMPLES; - avctx->delay = NELLY_BUF_LEN; + avctx->initial_padding = NELLY_BUF_LEN; ff_af_queue_init(avctx, &s->afq); s->avctx = avctx; if ((ret = ff_mdct_init(&s->mdct_ctx, 8, 0, 32768.0)) < 0) goto error; - ff_dsputil_init(&s->dsp, avctx); avpriv_float_dsp_init(&s->fdsp, avctx->flags & CODEC_FLAG_BITEXACT); /* Generate overlap window */ @@ -190,14 +186,6 @@ static av_cold int encode_init(AVCodecContext *avctx) } } -#if FF_API_OLD_ENCODE_AUDIO - avctx->coded_frame = avcodec_alloc_frame(); - if (!avctx->coded_frame) { - ret = AVERROR(ENOMEM); - goto error; - } -#endif - return 0; error: encode_end(avctx); @@ -240,10 +228,10 @@ static void get_exponent_dynamic(NellyMoserEncodeContext *s, float *cand, int *i int i, j, band, best_idx; float power_candidate, best_val; - float (*opt )[NELLY_BANDS] = s->opt ; - uint8_t(*path)[NELLY_BANDS] = s->path; + float (*opt )[OPT_SIZE] = s->opt ; + uint8_t(*path)[OPT_SIZE] = s->path; - for (i = 0; i < NELLY_BANDS * OPT_SIZE; i++) { + for (i = 0; i < OPT_SIZE; i++) { opt[0][i] = INFINITY; } @@ -420,6 +408,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *avpkt, AVCodec ff_nellymoser_encoder = { .name = "nellymoser", + .long_name = NULL_IF_CONFIG_SMALL("Nellymoser Asao"), .type = AVMEDIA_TYPE_AUDIO, .id = AV_CODEC_ID_NELLYMOSER, .priv_data_size = sizeof(NellyMoserEncodeContext), @@ -427,7 +416,6 @@ AVCodec ff_nellymoser_encoder = { .encode2 = encode_frame, .close = encode_end, .capabilities = CODEC_CAP_SMALL_LAST_FRAME | CODEC_CAP_DELAY, - .long_name = NULL_IF_CONFIG_SMALL("Nellymoser Asao"), .sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_NONE }, };