[FFmpeg-devel] [PATCH 3/4] proresenc_kostya: realloc if buffer too small

Christophe Gisquet christophe.gisquet at gmail.com
Tue Aug 12 07:56:36 CEST 2014


Hi,

2014-08-12 2:34 GMT+02:00 Michael Niedermayer <michaelni at gmx.at>:
>> +                if (pkt_size <= buf - orig_buf) {
>
> this isnt sufficient, there could be 1 byte space left, then the
> reallocate wouldnt run and encode_slice() would run into the extra
> padding and fail

Yeah, you're right. I have no idea how big a slice can be, as that
seems the extra size check here. How about FF_MIN_BUFFER_SIZE ?
Then the growth would be FFMAX(FF_MIN_BUFFER_SIZE, buf - orig_buf) ?

> I think either enough space should be allocated to begin with (like
> your patch 4) then the reallocation shouldnt be needed

Yes, the intent of that code is to try and catch bugs like the one
fixed by patch 4. Even if it catches it, we want to fix the original
bug.

> or the buffer could be allocated to an average size and reallocated
> when the encoder gets close to its end
> in which case reallocation also would not need a warning
> as it would be a normal operation

I have mixed feeling over not warning (and asking a sample). Sure we
may catch most issues with reallocating, but we can't get a guarantee
that the encode can complete (hence patch 1) in case of a serious
undersizing. Case in point: I had used a growth that was the maximum
between the quarter of the allocated size and twice the needed size,
and it crashed without patch 2.

-- 
Christophe


More information about the ffmpeg-devel mailing list