mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-02-09 14:14:39 +02:00
nellymoserenc: take float input samples instead of int16
This avoids having to convert all input data from int16 to float, which is used internally for encoding.
This commit is contained in:
parent
77c8ef9a36
commit
f3db0f7403
@ -146,7 +146,7 @@ static av_cold int encode_init(AVCodecContext *avctx)
|
|||||||
|
|
||||||
avctx->frame_size = NELLY_SAMPLES;
|
avctx->frame_size = NELLY_SAMPLES;
|
||||||
s->avctx = avctx;
|
s->avctx = avctx;
|
||||||
ff_mdct_init(&s->mdct_ctx, 8, 0, 1.0);
|
ff_mdct_init(&s->mdct_ctx, 8, 0, 32768.0);
|
||||||
dsputil_init(&s->dsp, avctx);
|
dsputil_init(&s->dsp, avctx);
|
||||||
|
|
||||||
/* Generate overlap window */
|
/* Generate overlap window */
|
||||||
@ -352,17 +352,15 @@ static void encode_block(NellyMoserEncodeContext *s, unsigned char *output, int
|
|||||||
static int encode_frame(AVCodecContext *avctx, uint8_t *frame, int buf_size, void *data)
|
static int encode_frame(AVCodecContext *avctx, uint8_t *frame, int buf_size, void *data)
|
||||||
{
|
{
|
||||||
NellyMoserEncodeContext *s = avctx->priv_data;
|
NellyMoserEncodeContext *s = avctx->priv_data;
|
||||||
const int16_t *samples = data;
|
const float *samples = data;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (s->last_frame)
|
if (s->last_frame)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (data) {
|
if (data) {
|
||||||
for (i = 0; i < avctx->frame_size; i++) {
|
memcpy(s->buf[s->bufsel], samples, avctx->frame_size * sizeof(*samples));
|
||||||
s->buf[s->bufsel][i] = samples[i];
|
for (i = avctx->frame_size; i < NELLY_SAMPLES; i++) {
|
||||||
}
|
|
||||||
for (; i < NELLY_SAMPLES; i++) {
|
|
||||||
s->buf[s->bufsel][i] = 0;
|
s->buf[s->bufsel][i] = 0;
|
||||||
}
|
}
|
||||||
s->bufsel = 1 - s->bufsel;
|
s->bufsel = 1 - s->bufsel;
|
||||||
@ -393,5 +391,5 @@ AVCodec ff_nellymoser_encoder = {
|
|||||||
.close = encode_end,
|
.close = encode_end,
|
||||||
.capabilities = CODEC_CAP_SMALL_LAST_FRAME | CODEC_CAP_DELAY,
|
.capabilities = CODEC_CAP_SMALL_LAST_FRAME | CODEC_CAP_DELAY,
|
||||||
.long_name = NULL_IF_CONFIG_SMALL("Nellymoser Asao"),
|
.long_name = NULL_IF_CONFIG_SMALL("Nellymoser Asao"),
|
||||||
.sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE},
|
.sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_FLT,AV_SAMPLE_FMT_NONE},
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user