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

Christophe Gisquet christophe.gisquet at gmail.com
Tue Aug 12 12:38:50 CEST 2014


2014-08-12 12:26 GMT+02:00 Michael Niedermayer <michaelni at gmx.at>:
> On Tue, Aug 12, 2014 at 11:56:21AM +0200, Christophe Gisquet wrote:
>> Hi,
>> 2014-08-12 10:19 GMT+02:00 Michael Niedermayer <michaelni at gmx.at>:
>> > the "serious undersizing" check already depends on the assumtation
>> > that FF_MIN_BUFFER_SIZE is larger than a slice,
>> Yes, and here lies the issue: if we haven't been able to guess it
>> correctly previously, how likely are we to guess it correctly here?
>> Take 2*max(previous_slice_size) ?
> I think if we allocate based on a upper bound and that turns out
> not enough, its better to fail and tell the user to report a bug
> than to try to reallocate.

Hopefully, the warning should incite the user to report it, but I
agree that trying to handle it may cut us for those reports. As you
like, but if you prefer failing, then maybe something like:
if (pkt_size <= buf - orig_buf + 2*max_slice_size)
is enough?

> for the per slice check we could take 2 or 3 times the upper bound
> of a slice and allocate more by that. And then check that we still
> have that amount before we start each slice. This should give us
> a 2-3 times saftey factor for underestimating slice sizes. While only
> slightly increasing the overall buffer size

I chose 2 times in the attached patch. I have no strong opinion on
which solution is best, though reallocating was a specific request I

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-proresenc_kostya-realloc-if-buffer-too-small.patch
Type: text/x-patch
Size: 3735 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20140812/81b9e2a1/attachment.bin>

More information about the ffmpeg-devel mailing list