summaryrefslogtreecommitdiff
path: root/libavcodec/hapdec.c
diff options
context:
space:
mode:
authorTom Butterworth <bangnoise@gmail.com>2015-07-21 01:21:38 +0100
committerVittorio Giovara <vittorio.giovara@gmail.com>2015-07-23 13:35:16 +0100
commit083cbc930d077651ea7e3fbc32ec45352cfed7e7 (patch)
tree80029690588869a1d9609d4c4ac6bd6ab880bcfe /libavcodec/hapdec.c
parent7f388c0fabc51eca3106e7cc443393269435ab52 (diff)
snappy: Refactor so ff_snappy_uncompress() uses an existing buffer
Some uses of Snappy require uncompressing to positions within an existing buffer. Also adds a function to get the uncompressed length of Snappy data.
Diffstat (limited to 'libavcodec/hapdec.c')
-rw-r--r--libavcodec/hapdec.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/libavcodec/hapdec.c b/libavcodec/hapdec.c
index a4880cd3e7..0398efe6ca 100644
--- a/libavcodec/hapdec.c
+++ b/libavcodec/hapdec.c
@@ -108,8 +108,13 @@ static int setup_texture(AVCodecContext *avctx, size_t length)
compressorstr = "none";
break;
case HAP_COMP_SNAPPY:
+ snappy_size = ff_snappy_peek_uncompressed_length(gbc);
+ ret = av_reallocp(&ctx->snappied, snappy_size);
+ if (ret < 0) {
+ return ret;
+ }
/* Uncompress the frame */
- ret = ff_snappy_uncompress(gbc, &ctx->snappied, &snappy_size);
+ ret = ff_snappy_uncompress(gbc, ctx->snappied, &snappy_size);
if (ret < 0) {
av_log(avctx, AV_LOG_ERROR, "Snappy uncompress error\n");
return ret;