Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Michael Niedermayer authored on 2014/02/15 23:06:29... | ... |
@@ -217,11 +217,13 @@ static av_cold int encode_init(AVCodecContext *avctx) |
217 | 217 |
ff_huffyuv_common_init(avctx); |
218 | 218 |
|
219 | 219 |
avctx->extradata = av_mallocz(3*MAX_N + 4); |
220 |
-#define STATS_OUT_SIZE 21*MAX_N*3 + 4 |
|
221 |
- avctx->stats_out = av_mallocz(STATS_OUT_SIZE); // 21*256*3(%llu ) + 3(\n) + 1(0) = 16132 |
|
222 |
- if (!avctx->extradata || !avctx->stats_out) { |
|
223 |
- av_freep(&avctx->stats_out); |
|
220 |
+ if (!avctx->extradata) |
|
224 | 221 |
return AVERROR(ENOMEM); |
222 |
+ if (s->flags&CODEC_FLAG_PASS1) { |
|
223 |
+#define STATS_OUT_SIZE 21*MAX_N*3 + 4 |
|
224 |
+ avctx->stats_out = av_mallocz(STATS_OUT_SIZE); // 21*256*3(%llu ) + 3(\n) + 1(0) = 16132 |
|
225 |
+ if (!avctx->stats_out) |
|
226 |
+ return AVERROR(ENOMEM); |
|
225 | 227 |
} |
226 | 228 |
s->version = 2; |
227 | 229 |
|
... | ... |
@@ -956,7 +958,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, |
956 | 956 |
if (end <= p) |
957 | 957 |
return AVERROR(ENOMEM); |
958 | 958 |
} |
959 |
- } else |
|
959 |
+ } else if (avctx->stats_out) |
|
960 | 960 |
avctx->stats_out[0] = '\0'; |
961 | 961 |
if (!(s->avctx->flags2 & CODEC_FLAG2_NO_OUTPUT)) { |
962 | 962 |
flush_put_bits(&s->pb); |