Skip to content

Commit 61ffa23

Browse files
committed
avcodec/codec_internal: add cap for ICC profile support
Codecs that can read/write ICC profiles deserve a special capability so the common logic in encode.c/decode.c can decide whether or not there needs to be any special handling for ICC profiles. The motivation here is to be able to use it to decide whether or not an ICC profile needs to be generated in the encode path, but it might as well get added to decoders as well for purely informative reasons. It's not entirely clear to me whether the "thp" and "smvjpeg" variants of "mjpeg" should have this capability set or not, given that the code technically supports it but I somehow doubt these files may contain them. In either case, this cap is purely informative for decoders so it doesn't matter too much either way. It's also not entirely clear whether the "amv" encoder should signal ICC profile support, but again erring on the side of caution, we probably *shouldn't* be generating (and encoding!) ICC profiles for this type of media file. Signed-off-by: Niklas Haas <[email protected]>
1 parent 1cbd455 commit 61ffa23

File tree

9 files changed

+20
-7
lines changed

9 files changed

+20
-7
lines changed

libavcodec/codec_internal.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@
7575
* internal logic derive them from AVCodecInternal.last_pkt_props.
7676
*/
7777
#define FF_CODEC_CAP_SETS_FRAME_PROPS (1 << 8)
78+
/**
79+
* Codec supports embedded ICC profiles (AV_FRAME_DATA_ICC_PROFILE).
80+
*/
81+
#define FF_CODEC_CAP_ICC_PROFILES (1 << 9)
7882

7983
/**
8084
* FFCodec.codec_tags termination value

libavcodec/libjxldec.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,7 @@ const FFCodec ff_libjxl_decoder = {
456456
.close = libjxl_decode_close,
457457
.p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_OTHER_THREADS,
458458
.caps_internal = FF_CODEC_CAP_NOT_INIT_THREADSAFE |
459-
FF_CODEC_CAP_AUTO_THREADS | FF_CODEC_CAP_INIT_CLEANUP,
459+
FF_CODEC_CAP_AUTO_THREADS | FF_CODEC_CAP_INIT_CLEANUP |
460+
FF_CODEC_CAP_ICC_PROFILES,
460461
.p.wrapper_name = "libjxl",
461462
};

libavcodec/libjxlenc.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,8 @@ const FFCodec ff_libjxl_encoder = {
469469
.close = libjxl_encode_close,
470470
.p.capabilities = AV_CODEC_CAP_OTHER_THREADS,
471471
.caps_internal = FF_CODEC_CAP_NOT_INIT_THREADSAFE |
472-
FF_CODEC_CAP_AUTO_THREADS | FF_CODEC_CAP_INIT_CLEANUP,
472+
FF_CODEC_CAP_AUTO_THREADS | FF_CODEC_CAP_INIT_CLEANUP |
473+
FF_CODEC_CAP_ICC_PROFILES,
473474
.p.pix_fmts = (const enum AVPixelFormat[]) {
474475
AV_PIX_FMT_RGB24, AV_PIX_FMT_RGBA,
475476
AV_PIX_FMT_RGB48, AV_PIX_FMT_RGBA64,

libavcodec/mjpegdec.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3027,7 +3027,9 @@ const FFCodec ff_mjpeg_decoder = {
30273027
.p.priv_class = &mjpegdec_class,
30283028
.p.profiles = NULL_IF_CONFIG_SMALL(ff_mjpeg_profiles),
30293029
.caps_internal = FF_CODEC_CAP_INIT_CLEANUP |
3030-
FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM | FF_CODEC_CAP_SETS_PKT_DTS,
3030+
FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM |
3031+
FF_CODEC_CAP_SETS_PKT_DTS |
3032+
FF_CODEC_CAP_ICC_PROFILES,
30313033
.hw_configs = (const AVCodecHWConfigInternal *const []) {
30323034
#if CONFIG_MJPEG_NVDEC_HWACCEL
30333035
HWACCEL_NVDEC(mjpeg),

libavcodec/mjpegenc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,7 @@ const FFCodec ff_mjpeg_encoder = {
652652
FF_CODEC_ENCODE_CB(ff_mpv_encode_picture),
653653
.close = mjpeg_encode_close,
654654
.p.capabilities = AV_CODEC_CAP_SLICE_THREADS | AV_CODEC_CAP_FRAME_THREADS,
655-
.caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
655+
.caps_internal = FF_CODEC_CAP_INIT_CLEANUP | FF_CODEC_CAP_ICC_PROFILES,
656656
.p.pix_fmts = (const enum AVPixelFormat[]) {
657657
AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUVJ444P,
658658
AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV444P,

libavcodec/pngdec.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1727,7 +1727,8 @@ const FFCodec ff_apng_decoder = {
17271727
.update_thread_context = ONLY_IF_THREADS_ENABLED(update_thread_context),
17281728
.p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS /*| AV_CODEC_CAP_DRAW_HORIZ_BAND*/,
17291729
.caps_internal = FF_CODEC_CAP_INIT_CLEANUP |
1730-
FF_CODEC_CAP_ALLOCATE_PROGRESS,
1730+
FF_CODEC_CAP_ALLOCATE_PROGRESS |
1731+
FF_CODEC_CAP_ICC_PROFILES,
17311732
};
17321733
#endif
17331734

@@ -1744,6 +1745,7 @@ const FFCodec ff_png_decoder = {
17441745
.update_thread_context = ONLY_IF_THREADS_ENABLED(update_thread_context),
17451746
.p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS /*| AV_CODEC_CAP_DRAW_HORIZ_BAND*/,
17461747
.caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM |
1747-
FF_CODEC_CAP_ALLOCATE_PROGRESS | FF_CODEC_CAP_INIT_CLEANUP,
1748+
FF_CODEC_CAP_ALLOCATE_PROGRESS | FF_CODEC_CAP_INIT_CLEANUP |
1749+
FF_CODEC_CAP_ICC_PROFILES,
17481750
};
17491751
#endif

libavcodec/pngenc.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,6 +1210,7 @@ const FFCodec ff_png_encoder = {
12101210
AV_PIX_FMT_MONOBLACK, AV_PIX_FMT_NONE
12111211
},
12121212
.p.priv_class = &pngenc_class,
1213+
.caps_internal = FF_CODEC_CAP_ICC_PROFILES,
12131214
};
12141215

12151216
const FFCodec ff_apng_encoder = {
@@ -1231,4 +1232,5 @@ const FFCodec ff_apng_encoder = {
12311232
AV_PIX_FMT_NONE
12321233
},
12331234
.p.priv_class = &pngenc_class,
1235+
.caps_internal = FF_CODEC_CAP_ICC_PROFILES,
12341236
};

libavcodec/tiff.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2193,6 +2193,6 @@ const FFCodec ff_tiff_decoder = {
21932193
.close = tiff_end,
21942194
FF_CODEC_DECODE_CB(decode_frame),
21952195
.p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS,
2196-
.caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
2196+
.caps_internal = FF_CODEC_CAP_INIT_CLEANUP | FF_CODEC_CAP_ICC_PROFILES,
21972197
.p.priv_class = &tiff_decoder_class,
21982198
};

libavcodec/webp.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1565,4 +1565,5 @@ const FFCodec ff_webp_decoder = {
15651565
FF_CODEC_DECODE_CB(webp_decode_frame),
15661566
.close = webp_decode_close,
15671567
.p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS,
1568+
.caps_internal = FF_CODEC_CAP_ICC_PROFILES,
15681569
};

0 commit comments

Comments
 (0)