diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2012-02-26 04:47:56 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2012-02-26 05:11:21 +0100 |
commit | 305e4b35ea7b643ab3ce8a37fa8cb464e8adeb3f (patch) | |
tree | 9e3773a72155b936e1ca66d4f089fa1b7eeeb791 /libavcodec/nellymoserenc.c | |
parent | 8e039121335f482234214bc4e0322ac72c1089ef (diff) | |
parent | 0a9efe4c6eb48bf863e2e630b3ad907a198961c5 (diff) | |
download | ffmpeg-305e4b35ea7b643ab3ce8a37fa8cb464e8adeb3f.tar.gz |
Merge remote-tracking branch 'qatar/master'
* qatar/master: (34 commits)
mlp_parser: fix the channel mask value used for the top surround channel
vorbisenc: check all allocations for failure
roqaudioenc: return AVERROR codes instead of -1
roqaudioenc: set correct bit rate
roqaudioenc: use AVCodecContext.frame_size correctly.
roqaudioenc: remove unneeded sample_fmt check
ra144enc: use int16_t* for input samples rather than void*
ra144enc: set AVCodecContext.coded_frame
ra144enc: remove unneeded sample_fmt check
nellymoserenc: set AVCodecContext.coded_frame
nellymoserenc: improve error checking in encode_init()
nellymoserenc: return AVERROR codes instead of -1
libvorbis: improve error checking in oggvorbis_encode_init()
mpegaudioenc: return AVERROR codes instead of -1
libfaac: improve error checking and handling in Faac_encode_init()
avutil: add AVERROR_UNKNOWN
check for coded_frame allocation failure in several audio encoders
audio encoders: do not set coded_frame->key_frame.
g722enc: check for trellis data allocation error
libspeexenc: export encoder delay through AVCodecContext.delay
...
Conflicts:
doc/APIchanges
libavcodec/avcodec.h
libavcodec/fraps.c
libavcodec/kgv1dec.c
libavcodec/libfaac.c
libavcodec/libgsm.c
libavcodec/libvorbis.c
libavcodec/mlp_parser.c
libavcodec/roqaudioenc.c
libavcodec/vorbisenc.c
libavutil/avutil.h
libavutil/error.c
libavutil/error.h
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/nellymoserenc.c')
-rw-r--r-- | libavcodec/nellymoserenc.c | 47 |
1 files changed, 31 insertions, 16 deletions
diff --git a/libavcodec/nellymoserenc.c b/libavcodec/nellymoserenc.c index 5ee1d72bcc..8e018c1b7f 100644 --- a/libavcodec/nellymoserenc.c +++ b/libavcodec/nellymoserenc.c @@ -127,14 +127,29 @@ static void apply_mdct(NellyMoserEncodeContext *s) s->mdct_ctx.mdct_calc(&s->mdct_ctx, s->mdct_out + NELLY_BUF_LEN, s->buf[s->bufsel] + NELLY_BUF_LEN); } +static av_cold int encode_end(AVCodecContext *avctx) +{ + NellyMoserEncodeContext *s = avctx->priv_data; + + ff_mdct_end(&s->mdct_ctx); + + if (s->avctx->trellis) { + av_free(s->opt); + av_free(s->path); + } + av_freep(&avctx->coded_frame); + + return 0; +} + static av_cold int encode_init(AVCodecContext *avctx) { NellyMoserEncodeContext *s = avctx->priv_data; - int i; + int i, ret; if (avctx->channels != 1) { av_log(avctx, AV_LOG_ERROR, "Nellymoser supports only 1 channel\n"); - return -1; + return AVERROR(EINVAL); } if (avctx->sample_rate != 8000 && avctx->sample_rate != 16000 && @@ -142,12 +157,13 @@ static av_cold int encode_init(AVCodecContext *avctx) avctx->sample_rate != 22050 && avctx->sample_rate != 44100 && avctx->strict_std_compliance >= FF_COMPLIANCE_NORMAL) { av_log(avctx, AV_LOG_ERROR, "Nellymoser works only with 8000, 16000, 11025, 22050 and 44100 sample rate\n"); - return -1; + return AVERROR(EINVAL); } avctx->frame_size = NELLY_SAMPLES; s->avctx = avctx; - ff_mdct_init(&s->mdct_ctx, 8, 0, 32768.0); + if ((ret = ff_mdct_init(&s->mdct_ctx, 8, 0, 32768.0)) < 0) + goto error; ff_dsputil_init(&s->dsp, avctx); /* Generate overlap window */ @@ -158,23 +174,22 @@ static av_cold int encode_init(AVCodecContext *avctx) if (s->avctx->trellis) { s->opt = av_malloc(NELLY_BANDS * OPT_SIZE * sizeof(float )); s->path = av_malloc(NELLY_BANDS * OPT_SIZE * sizeof(uint8_t)); + if (!s->opt || !s->path) { + ret = AVERROR(ENOMEM); + goto error; + } } - return 0; -} - -static av_cold int encode_end(AVCodecContext *avctx) -{ - NellyMoserEncodeContext *s = avctx->priv_data; - - ff_mdct_end(&s->mdct_ctx); - - if (s->avctx->trellis) { - av_free(s->opt); - av_free(s->path); + avctx->coded_frame = avcodec_alloc_frame(); + if (!avctx->coded_frame) { + ret = AVERROR(ENOMEM); + goto error; } return 0; +error: + encode_end(avctx); + return ret; } #define find_best(val, table, LUT, LUT_add, LUT_size) \ |