aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/g722enc.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-02-26 04:47:56 +0100
committerMichael Niedermayer <michaelni@gmx.at>2012-02-26 05:11:21 +0100
commit305e4b35ea7b643ab3ce8a37fa8cb464e8adeb3f (patch)
tree9e3773a72155b936e1ca66d4f089fa1b7eeeb791 /libavcodec/g722enc.c
parent8e039121335f482234214bc4e0322ac72c1089ef (diff)
parent0a9efe4c6eb48bf863e2e630b3ad907a198961c5 (diff)
downloadffmpeg-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/g722enc.c')
-rw-r--r--libavcodec/g722enc.c32
1 files changed, 20 insertions, 12 deletions
diff --git a/libavcodec/g722enc.c b/libavcodec/g722enc.c
index 1cb0070649..a5ae0a5153 100644
--- a/libavcodec/g722enc.c
+++ b/libavcodec/g722enc.c
@@ -41,9 +41,22 @@
#define MIN_TRELLIS 0
#define MAX_TRELLIS 16
+static av_cold int g722_encode_close(AVCodecContext *avctx)
+{
+ G722Context *c = avctx->priv_data;
+ int i;
+ for (i = 0; i < 2; i++) {
+ av_freep(&c->paths[i]);
+ av_freep(&c->node_buf[i]);
+ av_freep(&c->nodep_buf[i]);
+ }
+ return 0;
+}
+
static av_cold int g722_encode_init(AVCodecContext * avctx)
{
G722Context *c = avctx->priv_data;
+ int ret;
if (avctx->channels != 1) {
av_log(avctx, AV_LOG_ERROR, "Only mono tracks are allowed.\n");
@@ -62,6 +75,10 @@ static av_cold int g722_encode_init(AVCodecContext * avctx)
c->paths[i] = av_mallocz(max_paths * sizeof(**c->paths));
c->node_buf[i] = av_mallocz(2 * frontier * sizeof(**c->node_buf));
c->nodep_buf[i] = av_mallocz(2 * frontier * sizeof(**c->nodep_buf));
+ if (!c->paths[i] || !c->node_buf[i] || !c->nodep_buf[i]) {
+ ret = AVERROR(ENOMEM);
+ goto error;
+ }
}
}
@@ -100,18 +117,9 @@ static av_cold int g722_encode_init(AVCodecContext * avctx)
}
return 0;
-}
-
-static av_cold int g722_encode_close(AVCodecContext *avctx)
-{
- G722Context *c = avctx->priv_data;
- int i;
- for (i = 0; i < 2; i++) {
- av_freep(&c->paths[i]);
- av_freep(&c->node_buf[i]);
- av_freep(&c->nodep_buf[i]);
- }
- return 0;
+error:
+ g722_encode_close(avctx);
+ return ret;
}
static const int16_t low_quant[33] = {