[FFmpeg-devel] [PATCH 1/2] vc2enc: prevent random data
Hendrik Leppkes
h.leppkes at gmail.com
Tue May 3 19:24:51 CEST 2016
On Tue, May 3, 2016 at 7:06 PM, Christophe Gisquet
<christophe.gisquet at gmail.com> wrote:
> 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 its standardized value
> is 0xFF, hence the memset value.
>
> Overall this allows producing bistreams with no random data for use by fate.
> ---
> libavcodec/vc2enc.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/libavcodec/vc2enc.c b/libavcodec/vc2enc.c
> index 943198b..bec513c 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);
> +
I don't suppose we have a function to just write zero bytes instead of
these shenangans of written to the buffer and skiping?
> put_bits(pb, 8, quant_idx);
>
> /* Slice quantization (slice_quantizers() in the specs) */
> @@ -809,6 +812,7 @@ static int encode_hq_slice(AVCodecContext *avctx, void *arg)
> }
> pb->buf[bytes_start] = pad_s;
> flush_put_bits(pb);
> + memset(pb->buf_ptr, 0, pad_c);
> skip_put_bytes(pb, pad_c);
Both occurances use different ways to access the buffer, once
put_bits_ptr(pb) and one pb->buf_ptr, if this is the only way to do
this, maybe stick to one?
> }
>
> --
> 2.8.1
>
More information about the ffmpeg-devel
mailing list