aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2025-03-10 04:02:06 +0100
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2025-03-13 02:20:06 +0100
commit958c46800e68809bd47d9bff5d55c99ed943ca41 (patch)
tree482085fa05a356479bb2aeb9a524b9398f3c94fe
parented1b76cdb79cf0f6023010a151712350b8b81f37 (diff)
downloadffmpeg-958c46800e68809bd47d9bff5d55c99ed943ca41.tar.gz
avcodec/mjpegenc: Reconstify mjpeg encoder
It has been deconstified in 2c2dfd914902d0b41b4bd30d4b19ae08af1d7bc1 because the FFCodec is touched in av_codec_init_static because of its get_supported_config callback. Yet this is easily remedied: Only call get_supported_config to set pix_fmts if the codec does not already have it set. This also fixes a mismatch between the declaration of ff_mjpeg_encoder in allcodecs.c and the definition in mjpegenc.c. Said mismatch is actually undefined behaviour. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
-rw-r--r--libavcodec/allcodecs.c9
-rw-r--r--libavcodec/mjpegenc.c2
2 files changed, 6 insertions, 5 deletions
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 9820455b38..f10519617e 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -937,10 +937,11 @@ static void av_codec_init_static(void)
FF_DISABLE_DEPRECATION_WARNINGS
switch (codec->p.type) {
case AVMEDIA_TYPE_VIDEO:
- codec->get_supported_config(NULL, &codec->p,
- AV_CODEC_CONFIG_PIX_FORMAT, 0,
- (const void **) &codec->p.pix_fmts,
- &dummy);
+ if (!codec->p.pix_fmts)
+ codec->get_supported_config(NULL, &codec->p,
+ AV_CODEC_CONFIG_PIX_FORMAT, 0,
+ (const void **) &codec->p.pix_fmts,
+ &dummy);
break;
case AVMEDIA_TYPE_AUDIO:
codec->get_supported_config(NULL, &codec->p,
diff --git a/libavcodec/mjpegenc.c b/libavcodec/mjpegenc.c
index 3ac1010e4f..30f2c9900d 100644
--- a/libavcodec/mjpegenc.c
+++ b/libavcodec/mjpegenc.c
@@ -675,7 +675,7 @@ static int mjpeg_get_supported_config(const AVCodecContext *avctx,
return ff_default_get_supported_config(avctx, codec, config, flags, out, out_num);
}
-FFCodec ff_mjpeg_encoder = {
+const FFCodec ff_mjpeg_encoder = {
.p.name = "mjpeg",
CODEC_LONG_NAME("MJPEG (Motion JPEG)"),
.p.type = AVMEDIA_TYPE_VIDEO,