[FFmpeg-devel] [PATCH 1/3] avcodec/encode: add checks for custom inter/intra/chroma matrices
Marton Balint
cus at passwd.hu
Sat Jan 11 13:17:11 EET 2025
On Thu, 9 Jan 2025, Michael Niedermayer wrote:
> Hi
>
> On Tue, Jan 07, 2025 at 12:08:39AM +0100, Marton Balint wrote:
>> All elements should be within 1-255.
>> ---
>> libavcodec/encode.c | 16 ++++++++++++++++
>> 1 file changed, 16 insertions(+)
>
> this breaks:
>
> ./ffmpeg -i lena.pnm -qscale 4 -intra_matrix 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10 -chroma_intra_matrix 400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400 -bitexact custommatrix10,400.jpg
>
> I have not double checked the spec, but the resulting file worked fine
> before the patch
Hmm, apparenly JPEG does not write directly the matrices to the file but
the qscale corrected variants, so values larger than 255 can be OK. And
even if there is an overflow, it uses clipping, so any positive value
seems OK there.
I will rework this and use a codec specific check instead of a generic
one...
Regards,
Marton
>
> thx
>
> [...]
>
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> He who knows, does not speak. He who speaks, does not know. -- Lao Tsu
>
More information about the ffmpeg-devel
mailing list