[FFmpeg-devel] ffv1enc: question about "Cannot allocate worst case packet size, the encoding could fail"

Jerome Martinez jerome at mediaarea.net
Fri Oct 12 12:59:39 EEST 2018


On 12/10/2018 11:15, Carl Eugen Hoyos wrote:
> 2018-10-11 14:01 GMT+02:00, Jerome Martinez <jerome at mediaarea.net>:
>
>> - why is having a number > INT_MAX an issue? modern machines
>> are 64-bit and have 8+ GB of RAM
> So where is the issue?


The issue is that vanilla FFmpeg shows a warning in the scenario I 
indicate (a 128 MB frame, far less than 2 GB), without obvious reason of 
this warning (the multiplier used and the underlying limitation to 2 GB, 
lower than the available RAM, are hard coded without comments about the 
reason).


> If above is true for you, can can simply remove the check locally, no?

My goal is that **others** don't have this warning when they use a 
vanilla version of FFmpeg.
Before sending a patch for removing the limitation I don't understand 
(or lowering a number I don't understand), I ask if there is a reason 
for it (I guess that if this code is here, there is a reason and I 
imagined that FFmpeg developers could kindly explain the reason), isn't 
it the right thing to do? Do you prefer that I send directly a patch?

> (I hope you agree that what you write is not generally true.)

I don't catch what you want to indicate: do you mean that the only way 
in FFmpeg to be compatible with all machines is to set an hard coded 
limit to 2 GB?
I don't catch the goal, as you can have machines with 1 GB so this test 
would be useless on them (it will not prevent other parts of the code to 
have to do checks about RAM allocations) as well for machines having lot 
of RAM (they can handle big frames).

As I understand, the following test:
     if ((ret = ff_alloc_packet2(avctx, pkt, maxsize, 0)) < 0)
         return ret;

permits to check that FFmpeg has enough RAM for storing the max encoded 
frame size, whatever is the size of the RAM (1 GB or 8 GB), so I don't 
understand the reason maxsize is limited to 2 GB before the call to 
ff_alloc_packet2.

I kindly request more details about how hard coding 2 GB in the code 
helps, for both machines having 1 GB & machines having 8 GB. Looks like 
I am personally not smart enough for understanding that alone.

Jérôme




More information about the ffmpeg-devel mailing list