[FFmpeg-devel] [PATCH v6] avcodec: add farbfeld encoder

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Wed Jun 5 16:22:55 EEST 2024


Stefano Sabatini:
> On date Wednesday 2024-06-05 13:14:01 +0200, Andreas Rheinhardt wrote:
>> Stefano Sabatini:
> [...]
>>>> One does not need two checks as long as int is 32 bits (because then one
>>>> can just perform the addition in 64bits).
>>>
>>> sizeof(int) is not defined by the C standard, so you cannot assume it
>>> is 32 bits (even if on most platforms/compilers it will be)
>>>
>>
> 
>> Did you even read the following? It handles the case where simply using
>> 64bits is not enough.
> 
> Yes, but there is no need to mix types, introduce ifdeffery and make
> more assumptions when there is a simpler solution, please let's stick
> at that.
>  

Your "simpler solution" adds a (mostly) avoidable branch.

>>>> Just use the following (#if
>>>> has been used because compilers have a tendency to emit warnings if a
>>>> particular check is tautologically false):
>>>>
>>>> #if INT_MAX > INT64_MAX - HEADER_SIZE
>>>>     if (raw_img_size > INT64_MAX - HEADER_SIZE)
>>>>         return AVERROR(ERANGE);
>>>> #endif



More information about the ffmpeg-devel mailing list