From patchwork Tue Jun 28 13:41:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 36508 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:8b27:b0:88:1bbf:7fd2 with SMTP id l39csp2661603pzh; Tue, 28 Jun 2022 06:42:39 -0700 (PDT) X-Google-Smtp-Source: AGRyM1t+ED89gh5kcPD9M6v5J6xKD3Q9NkF06+flOIDgQiZ/1/ONvKiGKq2Q9Tnbw/FSiCV14szd X-Received: by 2002:a17:907:1314:b0:722:fc80:3b34 with SMTP id vj20-20020a170907131400b00722fc803b34mr17903663ejb.583.1656423759716; Tue, 28 Jun 2022 06:42:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656423759; cv=none; d=google.com; s=arc-20160816; b=JNHI3yW914wOJorRQBz9yhcIiptdUgHzjOwXOobK7Dp+vnkuEbYTxByM8xptbuq49t UUg0tmk6pudToBXGFLBkm0/nIHMOiDOQsjg8EChU7b1kN9L2Ar8g1eX2+iM8XpFnToNO oz6JNshWHi2/eI1D07i64XupaBp2qbz7nDrpgJqVd1htlTrrTloHQKXsWz+qmHz7PAff ctmtcNb3//6LVNiPBmsuIq8ygQvVuQVIXA+J1pN/tYJ5sYkUUduvMB1WQl0Es/XYH0/1 nftJ6K1NQEOqaQx4OXzksAPtV/Jav9Whb6S3k4Vh0JJzkCC5lNwJj0+AXdeARX5nDOG7 jcaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=xq3ufitgGDztMIkLAWAAcwP0wO7qfoTt22DuTXJig+k=; b=TtIs0zGpjawkgsg6aqnABD1GksWkvA6IyQE4/gFRCGI67oXUr4B+lAgL8N7tGgvsKg k3MhMXb7kw+PA1z2eYgVy5SHiPrtY/lkahQPVnjO/gsAXtYpp5JeVNQIpD789Ce3Azth p8FYlwbG0YQQvfz7khfdvI6XidzaoxgTQd3b3FBMQugAGRu9P+ENcLk/XeGriFCA2RIh yHfBPAIfiOwiBLUMba98RJEUbFSm6eDYoRdWjt0W1CsLuT1bVg1patcUxp8G2Jk4V2ot M4mpWoF0IMeIuEpNbCj4SFdAEEFrGwkj4yfx1jBtVAwdd7sYlp/0UTK7TCy+YaKhG1nA Ryhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@haasn.xyz header.s=mail header.b="d/WR35hJ"; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id m19-20020a50ef13000000b00437be62fa1bsi498565eds.435.2022.06.28.06.42.39; Tue, 28 Jun 2022 06:42:39 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@haasn.xyz header.s=mail header.b="d/WR35hJ"; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2D6A768B979; Tue, 28 Jun 2022 16:42:24 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from haasn.dev (haasn.dev [78.46.187.166]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D0AD068B912 for ; Tue, 28 Jun 2022 16:42:16 +0300 (EEST) Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id 8F94C4A57B; Tue, 28 Jun 2022 15:42:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1656423736; bh=EveejBhGv5Lypv4WhxZ5suOEH7ueRJkdrpN31C5uOp8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d/WR35hJUTqAMGHeuroNvZeT0Uqm2YM0WzQW2bu6+FuqUaa2GBa3+k2yiZSZ+HId+ VnG9RoulEBXx6jrGYqsHMeXhlmY5/MxC0KRmKwLaSBtKG3LrBk+KmVI0S67FazYXTj yI1Z9tz7Cabrewwvd5aTsVqWiRQ/gu2FpLL7GJE4= From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Tue, 28 Jun 2022 15:41:07 +0200 Message-Id: <20220628134110.87770-3-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220628134110.87770-1-ffmpeg@haasn.xyz> References: <20220628134110.87770-1-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/6] avcodec/codec_internal: add cap for ICC profile support X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Niklas Haas Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: MvCKPujeNtqO From: Niklas Haas 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 --- libavcodec/codec_internal.h | 4 ++++ libavcodec/libjxldec.c | 3 ++- libavcodec/libjxlenc.c | 3 ++- libavcodec/mjpegdec.c | 3 ++- libavcodec/mjpegenc.c | 3 ++- libavcodec/pngdec.c | 5 +++-- libavcodec/pngenc.c | 4 ++-- libavcodec/tiff.c | 3 ++- libavcodec/webp.c | 2 +- 9 files changed, 20 insertions(+), 10 deletions(-) diff --git a/libavcodec/codec_internal.h b/libavcodec/codec_internal.h index 5df286ce52..b4e3813353 100644 --- a/libavcodec/codec_internal.h +++ b/libavcodec/codec_internal.h @@ -73,6 +73,10 @@ * internal logic derive them from AVCodecInternal.last_pkt_props. */ #define FF_CODEC_CAP_SETS_FRAME_PROPS (1 << 8) +/** + * Codec supports embedded ICC profiles (AV_FRAME_DATA_ICC_PROFILE). + */ +#define FF_CODEC_CAP_ICC_PROFILES (1 << 9) /** * FFCodec.codec_tags termination value diff --git a/libavcodec/libjxldec.c b/libavcodec/libjxldec.c index d516d3b0ac..7c78627037 100644 --- a/libavcodec/libjxldec.c +++ b/libavcodec/libjxldec.c @@ -455,6 +455,7 @@ const FFCodec ff_libjxl_decoder = { FF_CODEC_DECODE_CB(libjxl_decode_frame), .close = libjxl_decode_close, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_OTHER_THREADS, - .caps_internal = FF_CODEC_CAP_AUTO_THREADS | FF_CODEC_CAP_INIT_CLEANUP, + .caps_internal = FF_CODEC_CAP_AUTO_THREADS | FF_CODEC_CAP_INIT_CLEANUP | + FF_CODEC_CAP_ICC_PROFILES, .p.wrapper_name = "libjxl", }; diff --git a/libavcodec/libjxlenc.c b/libavcodec/libjxlenc.c index 6a948cc3ae..3a533db8a1 100644 --- a/libavcodec/libjxlenc.c +++ b/libavcodec/libjxlenc.c @@ -463,7 +463,8 @@ const FFCodec ff_libjxl_encoder = { FF_CODEC_ENCODE_CB(libjxl_encode_frame), .close = libjxl_encode_close, .p.capabilities = AV_CODEC_CAP_OTHER_THREADS, - .caps_internal = FF_CODEC_CAP_AUTO_THREADS | FF_CODEC_CAP_INIT_CLEANUP, + .caps_internal = FF_CODEC_CAP_AUTO_THREADS | FF_CODEC_CAP_INIT_CLEANUP | + FF_CODEC_CAP_ICC_PROFILES, .p.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_RGB24, AV_PIX_FMT_RGBA, AV_PIX_FMT_RGB48, AV_PIX_FMT_RGBA64, diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c index 32874a5a19..8e5878e9ee 100644 --- a/libavcodec/mjpegdec.c +++ b/libavcodec/mjpegdec.c @@ -3027,7 +3027,8 @@ const FFCodec ff_mjpeg_decoder = { .p.priv_class = &mjpegdec_class, .p.profiles = NULL_IF_CONFIG_SMALL(ff_mjpeg_profiles), .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP | - FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM | FF_CODEC_CAP_SETS_PKT_DTS, + FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM | FF_CODEC_CAP_SETS_PKT_DTS | + FF_CODEC_CAP_ICC_PROFILES, .hw_configs = (const AVCodecHWConfigInternal *const []) { #if CONFIG_MJPEG_NVDEC_HWACCEL HWACCEL_NVDEC(mjpeg), diff --git a/libavcodec/mjpegenc.c b/libavcodec/mjpegenc.c index 27217441a3..8787528b3e 100644 --- a/libavcodec/mjpegenc.c +++ b/libavcodec/mjpegenc.c @@ -652,7 +652,8 @@ const FFCodec ff_mjpeg_encoder = { FF_CODEC_ENCODE_CB(ff_mpv_encode_picture), .close = mjpeg_encode_close, .p.capabilities = AV_CODEC_CAP_SLICE_THREADS | AV_CODEC_CAP_FRAME_THREADS, - .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP, + .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP | + FF_CODEC_CAP_ICC_PROFILES, .p.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUVJ444P, AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV444P, diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c index 6b44af59f2..5cd8a176fd 100644 --- a/libavcodec/pngdec.c +++ b/libavcodec/pngdec.c @@ -1727,7 +1727,7 @@ const FFCodec ff_apng_decoder = { .update_thread_context = ONLY_IF_THREADS_ENABLED(update_thread_context), .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS /*| AV_CODEC_CAP_DRAW_HORIZ_BAND*/, .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP | - FF_CODEC_CAP_ALLOCATE_PROGRESS, + FF_CODEC_CAP_ALLOCATE_PROGRESS | FF_CODEC_CAP_ICC_PROFILES, }; #endif @@ -1744,6 +1744,7 @@ const FFCodec ff_png_decoder = { .update_thread_context = ONLY_IF_THREADS_ENABLED(update_thread_context), .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS /*| AV_CODEC_CAP_DRAW_HORIZ_BAND*/, .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM | FF_CODEC_CAP_INIT_THREADSAFE | - FF_CODEC_CAP_ALLOCATE_PROGRESS | FF_CODEC_CAP_INIT_CLEANUP, + FF_CODEC_CAP_ALLOCATE_PROGRESS | FF_CODEC_CAP_INIT_CLEANUP | + FF_CODEC_CAP_ICC_PROFILES, }; #endif diff --git a/libavcodec/pngenc.c b/libavcodec/pngenc.c index d79b4e3895..b23ff84787 100644 --- a/libavcodec/pngenc.c +++ b/libavcodec/pngenc.c @@ -1210,7 +1210,7 @@ const FFCodec ff_png_encoder = { AV_PIX_FMT_MONOBLACK, AV_PIX_FMT_NONE }, .p.priv_class = &pngenc_class, - .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE, + .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_ICC_PROFILES, }; const FFCodec ff_apng_encoder = { @@ -1232,5 +1232,5 @@ const FFCodec ff_apng_encoder = { AV_PIX_FMT_NONE }, .p.priv_class = &pngenc_class, - .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE, + .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_ICC_PROFILES, }; diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c index e4a5d3c537..c369c12f71 100644 --- a/libavcodec/tiff.c +++ b/libavcodec/tiff.c @@ -2187,6 +2187,7 @@ const FFCodec ff_tiff_decoder = { .close = tiff_end, FF_CODEC_DECODE_CB(decode_frame), .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, - .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP, + .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP | + FF_CODEC_CAP_ICC_PROFILES, .p.priv_class = &tiff_decoder_class, }; diff --git a/libavcodec/webp.c b/libavcodec/webp.c index 1b5e943a6e..2b1242615d 100644 --- a/libavcodec/webp.c +++ b/libavcodec/webp.c @@ -1565,5 +1565,5 @@ const FFCodec ff_webp_decoder = { FF_CODEC_DECODE_CB(webp_decode_frame), .close = webp_decode_close, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, - .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE, + .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_ICC_PROFILES, };