aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/vc2enc.c
diff options
context:
space:
mode:
authorChristophe Gisquet <christophe.gisquet@gmail.com>2016-05-05 11:06:08 +0200
committerRostislav Pehlivanov <rpehlivanov@obe.tv>2016-05-06 01:12:51 +0100
commit9c1aa14bf0b88da9f91dc114519e725cbd69180e (patch)
tree98d3564350b84d3465d970d0278275d0bbc2c512 /libavcodec/vc2enc.c
parent7a679e4ac099d05850d923dee235496f12ffdfa1 (diff)
downloadffmpeg-9c1aa14bf0b88da9f91dc114519e725cbd69180e.tar.gz
vc2enc: prevent random data
The slice prefix is 0 in the reference encoder and the decoder ignores it. Writing 0 there seems like the best temporary solution. The padding could have contained uninitialized data, but reference VC2 encoders put 0xFF there, hence the memset value. Overall this allows producing bistreams with no random data for use by fate.
Diffstat (limited to 'libavcodec/vc2enc.c')
-rw-r--r--libavcodec/vc2enc.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/libavcodec/vc2enc.c b/libavcodec/vc2enc.c
index 6d24552dc5..bbbeaa090e 100644
--- a/libavcodec/vc2enc.c
+++ b/libavcodec/vc2enc.c
@@ -777,7 +777,10 @@ static int encode_hq_slice(AVCodecContext *avctx, void *arg)
uint8_t quants[MAX_DWT_LEVELS][4];
int p, level, orientation;
+ /* The reference decoder ignores it, and its typical length is 0 */
+ memset(put_bits_ptr(pb), 0, s->prefix_bytes);
skip_put_bytes(pb, s->prefix_bytes);
+
put_bits(pb, 8, quant_idx);
/* Slice quantization (slice_quantizers() in the specs) */
@@ -809,6 +812,8 @@ static int encode_hq_slice(AVCodecContext *avctx, void *arg)
}
pb->buf[bytes_start] = pad_s;
flush_put_bits(pb);
+ /* vc2-reference uses that padding that decodes to '0' coeffs */
+ memset(put_bits_ptr(pb), 0xFF, pad_c);
skip_put_bytes(pb, pad_c);
}