Kostya Shishkov <[email protected]> writes:

> On Sat, Jul 28, 2012 at 01:31:33PM -0400, Derek Buitenhuis wrote:
>> On 28/07/2012 3:44 AM, Kostya Shishkov wrote:
>> >> +    ctx->swapped_buf = av_malloc(avctx->width * avctx->height * 3);
>> > 
>> > Are you sure it's always enough? Max code length is 14 bits and
>> > some space is needed for code descriptions. It's better to be
>> > pessimistic here than crash on too big input frame later.
>> 
>> You think it's possible to be larger than the raw frame? o.o
>
> Just think of some evil person faking large frame. And boom goes your
> decoder.  That's why we usually just realloc it depending on input
> frame size.

Encode a frame of random noise and see what happens.  I'm guessing it
will slightly larger than the raw data.

For any lossless compression scheme, there exist inputs it cannot
compress.  If such an input is presented to the encoder, the best it can
hope to achieve is to indicate a block of verbatim data, but such an
indication requires at least one bit, so the output is still larger than
the input.

-- 
Måns Rullgård
[email protected]
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to