diff mbox series

[FFmpeg-devel,1/9] avcodec/encode: Fix check for allowed LJPEG pixel formats

Message ID HE1PR0301MB2154E897519F994A48B4C01C8F769@HE1PR0301MB2154.eurprd03.prod.outlook.com
State Accepted
Commit 6e8e9b7633d8b755e7a464a10ba5047f31cbd84d
Headers show
Series [FFmpeg-devel,1/9] avcodec/encode: Fix check for allowed LJPEG pixel formats
Related show


Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Andreas Rheinhardt April 6, 2021, 5:35 a.m. UTC
The pix_fmts of the LJPEG encoder already contain all supported pixel
formats (including the ones only supported when strictness is unofficial
or less); yet the check in ff_encode_preinit() ignored this list in case
strictness is unofficial or less. But the encoder presumed that it is
always applied and blacklists some of the entries in pix_fmts when
strictness is > unofficial. The result is that if one uses an entry not
on that list and sets strictness to unofficial, said entry passes both
checks and this can lead to segfaults lateron (e.g. when using gray).

Fix this by removing the exception for LJPEG in ff_encode_preinit().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
 libavcodec/encode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series


diff --git a/libavcodec/encode.c b/libavcodec/encode.c
index a93bb3ccf7..89df5235da 100644
--- a/libavcodec/encode.c
+++ b/libavcodec/encode.c
             if (avctx->pix_fmt == avctx->codec->pix_fmts[i])
         if (avctx->codec->pix_fmts[i] == AV_PIX_FMT_NONE
-            && !((avctx->codec_id == AV_CODEC_ID_MJPEG || avctx->codec_id == AV_CODEC_ID_LJPEG)
+            && !(avctx->codec_id == AV_CODEC_ID_MJPEG
                  && avctx->strict_std_compliance <= FF_COMPLIANCE_UNOFFICIAL)) {
             char buf[128];
             snprintf(buf, sizeof(buf), "%d", avctx->pix_fmt);