summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorReimar Döffinger <Reimar.Doeffinger@gmx.de>2014-09-02 20:31:39 +0200
committerReimar Döffinger <Reimar.Doeffinger@gmx.de>2014-09-03 21:22:58 +0200
commit672425411804becc64447c2b830335c1426db9a0 (patch)
tree7a3b371db3c4be626884c762cda51bef5205cd5f
parentefaa4a8dbf7f4aaf27fabe38037dad6283ac1ed1 (diff)
downloadffmpeg-streaming-672425411804becc64447c2b830335c1426db9a0.zip
ffmpeg-streaming-672425411804becc64447c2b830335c1426db9a0.tar.gz
ffv1enc: reduce stack usage.
A bit more complex than e.g. adding it to the context, but using the context for something that will be used only during initialization seemed a bit wasteful. Signed-off-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de>
-rw-r--r--libavcodec/ffv1enc.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c
index b63ed42..e2d3707 100644
--- a/libavcodec/ffv1enc.c
+++ b/libavcodec/ffv1enc.c
@@ -862,9 +862,11 @@ static av_cold int encode_init(AVCodecContext *avctx)
}
if (avctx->stats_in) {
char *p = avctx->stats_in;
- uint8_t best_state[256][256];
+ uint8_t (*best_state)[256] = av_malloc_array(256, 256);
int gob_count = 0;
char *next;
+ if (!best_state)
+ return AVERROR(ENOMEM);
av_assert0(s->version >= 2);
@@ -875,6 +877,7 @@ static av_cold int encode_init(AVCodecContext *avctx)
if (next == p) {
av_log(avctx, AV_LOG_ERROR,
"2Pass file invalid at %d %d [%s]\n", j, i, p);
+ av_freep(&best_state);
return AVERROR_INVALIDDATA;
}
p = next;
@@ -888,6 +891,7 @@ static av_cold int encode_init(AVCodecContext *avctx)
av_log(avctx, AV_LOG_ERROR,
"2Pass file invalid at %d %d %d %d [%s]\n",
i, j, k, m, p);
+ av_freep(&best_state);
return AVERROR_INVALIDDATA;
}
p = next;
@@ -896,6 +900,7 @@ static av_cold int encode_init(AVCodecContext *avctx)
gob_count = strtol(p, &next, 0);
if (next == p || gob_count <= 0) {
av_log(avctx, AV_LOG_ERROR, "2Pass file invalid\n");
+ av_freep(&best_state);
return AVERROR_INVALIDDATA;
}
p = next;
@@ -933,6 +938,7 @@ static av_cold int encode_init(AVCodecContext *avctx)
}
}
}
+ av_freep(&best_state);
}
if (s->version > 1) {
OpenPOWER on IntegriCloud