[FFmpeg-devel] [PATCH v2 08/12] lavc/frame_thread_encoder: avoid assigning a whole AVCodecContext

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Sun Mar 24 13:10:24 EET 2024


Anton Khirnov:
> Quoting Andreas Rheinhardt (2024-03-24 11:19:19)
>> Anton Khirnov:
>>> Quoting Andreas Rheinhardt (2024-03-23 15:11:59)
>>>> 1. The earlier code would just work in case the user used a smaller
>>>> number of elements for the matrices if these matrices were not used at
>>>> all (which happens for the majority of encoders). This is no longer true
>>>> with this patch.
>>>
>>> So?
>>>
>>
>> It means there is a scenario where you break something.
> 
> There is no way for the caller to know whether, and how much, will lavc
> read from those tables, so it's invalid API use.
> 

Incorrect: Given that these fields do not a length field, it is legal to
put pointers to matrices of arbitrary length in the relevant
AVCodecContext field. Just because the current code presumes this to
have at least 64 elements for certain mpegvideo encoders and just
because there are no other encoders using different values does not make
it illegal.
The reason we are in this predicament is of course that the API itself
is broken.

- Andreas



More information about the ffmpeg-devel mailing list