diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2014-02-15 15:06:29 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2014-02-15 15:06:29 +0100 |
commit | 59279bf21fb037978626e348f58e7abb5b7fa2d7 (patch) | |
tree | 772e45c5516b0abf2df37c45be4edbd955770645 /libavcodec/huffyuvenc.c | |
parent | 776cda748d08860676ea29fa87c8c224ef0d8240 (diff) | |
download | ffmpeg-59279bf21fb037978626e348f58e7abb5b7fa2d7.tar.gz |
avcodec/huffyuvenc: only allocate stats_out when it will be used
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/huffyuvenc.c')
-rw-r--r-- | libavcodec/huffyuvenc.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/libavcodec/huffyuvenc.c b/libavcodec/huffyuvenc.c index 2a69cc09d9..aa5e2cbb20 100644 --- a/libavcodec/huffyuvenc.c +++ b/libavcodec/huffyuvenc.c @@ -217,11 +217,13 @@ static av_cold int encode_init(AVCodecContext *avctx) ff_huffyuv_common_init(avctx); avctx->extradata = av_mallocz(3*MAX_N + 4); -#define STATS_OUT_SIZE 21*MAX_N*3 + 4 - avctx->stats_out = av_mallocz(STATS_OUT_SIZE); // 21*256*3(%llu ) + 3(\n) + 1(0) = 16132 - if (!avctx->extradata || !avctx->stats_out) { - av_freep(&avctx->stats_out); + if (!avctx->extradata) return AVERROR(ENOMEM); + if (s->flags&CODEC_FLAG_PASS1) { +#define STATS_OUT_SIZE 21*MAX_N*3 + 4 + avctx->stats_out = av_mallocz(STATS_OUT_SIZE); // 21*256*3(%llu ) + 3(\n) + 1(0) = 16132 + if (!avctx->stats_out) + return AVERROR(ENOMEM); } s->version = 2; @@ -956,7 +958,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, if (end <= p) return AVERROR(ENOMEM); } - } else + } else if (avctx->stats_out) avctx->stats_out[0] = '\0'; if (!(s->avctx->flags2 & CODEC_FLAG2_NO_OUTPUT)) { flush_put_bits(&s->pb); |