summaryrefslogtreecommitdiff
path: root/libavcodec/ffv1dec.c
diff options
context:
space:
mode:
authorReimar Döffinger <Reimar.Doeffinger@gmx.de>2014-09-02 20:55:35 +0200
committerReimar Döffinger <Reimar.Doeffinger@gmx.de>2014-11-22 19:06:12 +0100
commit8437cc72060f3fb057b96a908b33e9954074bac7 (patch)
tree98b7a842c47abcccf45782c5be022874fba4acab /libavcodec/ffv1dec.c
parent9146a476003cbf3adef88d26834928e53f9a9d8b (diff)
ffv1dec: Avoid unnecessarily large stack usage and copies.
Ideally the compiler could figure this out on its own, but it seems it can't. An alternative that would avoid the messy explicit memcpy would be to use a sub-struct for the parts that should be preserved, which can then simply be assigned. Signed-off-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de>
Diffstat (limited to 'libavcodec/ffv1dec.c')
-rw-r--r--libavcodec/ffv1dec.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c
index c408f16106..5fbe51c5a5 100644
--- a/libavcodec/ffv1dec.c
+++ b/libavcodec/ffv1dec.c
@@ -1051,12 +1051,17 @@ static int update_thread_context(AVCodecContext *dst, const AVCodecContext *src)
return 0;
{
- FFV1Context bak = *fdst;
+ ThreadFrame picture = fdst->picture, last_picture = fdst->last_picture;
+ uint8_t (*initial_states[MAX_QUANT_TABLES])[32];
+ struct FFV1Context *slice_context[MAX_SLICES];
+ memcpy(initial_states, fdst->initial_states, sizeof(fdst->initial_states));
+ memcpy(slice_context, fdst->slice_context , sizeof(fdst->slice_context));
+
memcpy(fdst, fsrc, sizeof(*fdst));
- memcpy(fdst->initial_states, bak.initial_states, sizeof(fdst->initial_states));
- memcpy(fdst->slice_context, bak.slice_context , sizeof(fdst->slice_context));
- fdst->picture = bak.picture;
- fdst->last_picture = bak.last_picture;
+ memcpy(fdst->initial_states, initial_states, sizeof(fdst->initial_states));
+ memcpy(fdst->slice_context, slice_context , sizeof(fdst->slice_context));
+ fdst->picture = picture;
+ fdst->last_picture = last_picture;
for (i = 0; i<fdst->num_h_slices * fdst->num_v_slices; i++) {
FFV1Context *fssrc = fsrc->slice_context[i];
FFV1Context *fsdst = fdst->slice_context[i];