From patchwork Thu Jul 28 14:49:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 37024 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:1649:b0:8b:613a:194d with SMTP id no9csp326668pzb; Thu, 28 Jul 2022 07:51:11 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vpBOai+/ap/NPzMehOW9QFtfpdWhASwww6UIBPrMJotsW91FyqpHzu4GZBdF0zNNeQNG4x X-Received: by 2002:a17:907:7e87:b0:72f:18d7:6094 with SMTP id qb7-20020a1709077e8700b0072f18d76094mr21603470ejc.77.1659019871140; Thu, 28 Jul 2022 07:51:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659019871; cv=none; d=google.com; s=arc-20160816; b=pW+ZAA9wJAyjTilBSup9ls4x1gkGuWrLhABrs3wKahOkYt8obcOKD1XeZHHtbGSHKx AM5E71keYOm6+nliOblPJ4BbkhMyzjJlcqZduF8pwyLHmArJrr5q2hjuMEhM5qEC/LtQ E3YKaHc92gN/zdfN5GjJO+U3x6RSVdpxXjOf7yjLWxO9hiYA+IY3cSXnnsqgiIoCJ9Qt IyCXzW0BP663K7rpH54ZMlfux4OoOS+yNI+fKrIleBXY3KVDKvn+9b2o5EZAkZZXtlUA jo8M1628VNYkKKlQqs9DD9J8kAewPMBkXtepCLsGmP/pDpkQS8vu8zI2VfZ9bbUMaZQM af9A== 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=87eQAf2plHOVVQMGDVQVy9J8NQSmpvGullwRf7kSbFE=; b=Cl8hofOSP1XkeOYrwR0TjjO/uzBkgDTBlji509TTVuHK5luUJBEtHQFgJhu+a3AG9Z FsQSMw1c9FKCq1aNiKG9tSFHaQYTi9xbOum5awwbMK7ElJnH2u9LMu8QJKEC8tpbiBSk bs9wpnYXcw4SE+2okCX3H975JM2OJnGSnak762tKslcwokDkYqSzxRNSBDh6i1Sfgzfj KIr1K5zRBgJzu8MO1Plwq4UHt3cZuKg1nGByGDQ+WWqWINsxmF9MhRHiO9hTyIpTgvmk ojLQXZUUoVmx7rbKj3eQKbi9NOnyF9cqQluxU75Ug5ko1NyHfGh89Pzu2hB7/RfqmZaK XqhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@haasn.xyz header.s=mail header.b="nR9RoFs/"; 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 q22-20020a50aa96000000b0043574c5a72fsi904800edc.360.2022.07.28.07.51.10; Thu, 28 Jul 2022 07:51:11 -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="nR9RoFs/"; 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 5444D68B9A6; Thu, 28 Jul 2022 17:50:19 +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 2C4CE68B9A9 for ; Thu, 28 Jul 2022 17:50:07 +0300 (EEST) Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id DB4E64AA72; Thu, 28 Jul 2022 16:50:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1659019806; bh=N8/nkCWDJiPfcQkHlFDOoJ6UB8mbcFVQn9ELubRIfLg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nR9RoFs/ZqJgLAnOaqbVb0xV30fvO8ycDTzxdUC7dKWXSYyeN66qYNcTCph5vzV9x Ud4aEet76Dxn/dmdiVBO/wMqjmnuw5DOoaM1qPr8cziO9nYEdZzdhhpLUf+kUQ2mOm LWp53BvkfxgBLFJ7opg0hJ1gxWDD2ztU5ec6uO04= From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Thu, 28 Jul 2022 16:49:58 +0200 Message-Id: <20220728145002.102600-4-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220728145002.102600-1-ffmpeg@haasn.xyz> References: <20220728145002.102600-1-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v4 3/7] avcodec: add API for automatic handling of icc profiles 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: zSge7o08JwNa From: Niklas Haas This functionally already exists, but as pointed out in #9672 and #9673, requiring users to manually include filters is clumsy, error-prone and hard to use together with tools like ffplay. To streamline ICC profile support, add a new AVCodecContext flag to globally enable reading and writing ICC profiles, automatically, for all appropriate media types. Note that this commit only includes the new API. The implementation is split off to separate commits for readability. Signed-off-by: Niklas Haas --- doc/APIchanges | 5 +++++ doc/codecs.texi | 2 ++ libavcodec/avcodec.h | 6 ++++++ libavcodec/options_table.h | 1 + libavcodec/version.h | 2 +- 5 files changed, 15 insertions(+), 1 deletion(-) diff --git a/doc/APIchanges b/doc/APIchanges index b3563cd528..e374f3ca81 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -14,6 +14,11 @@ libavutil: 2021-04-27 API changes, most recent first: +2022-07-xx - xxxxxxxxx - lavc 59.40.100 - avcodec.h + Add the AV_CODEC_FLAG2_ICC_PROFILES flag to AVCodecContext, to enable + automatic reading and writing of embedded ICC profiles in image files. + The "flags2" option now supports the corresponding flag "icc_profiles". + 2022-07-xx - xxxxxxxxxx - lavu 57.30.100 - frame.h Add AVFrame.duration, deprecate AVFrame.pkt_duration. diff --git a/doc/codecs.texi b/doc/codecs.texi index 5e10020900..1adacd2b59 100644 --- a/doc/codecs.texi +++ b/doc/codecs.texi @@ -644,6 +644,8 @@ for codecs that support it. See also @file{doc/examples/export_mvs.c}. Do not skip samples and export skip information as frame side data. @item ass_ro_flush_noop Do not reset ASS ReadOrder field on flush. +@item icc_profiles +Generate/parse embedded ICC profiles from/to colorimetry tags. @end table @item export_side_data @var{flags} (@emph{decoding/encoding,audio,video,subtitles}) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index cb5c25bf63..60b215d2e9 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -331,6 +331,12 @@ typedef struct RcOverride{ * Do not reset ASS ReadOrder field on flush (subtitles decoding) */ #define AV_CODEC_FLAG2_RO_FLUSH_NOOP (1 << 30) +/** + * Generate/parse ICC profiles on encode/decode, as appropriate for the type of + * file. No effect on codecs which cannot contain embedded ICC profiles, or + * when compiled without support for lcms2. + */ +#define AV_CODEC_FLAG2_ICC_PROFILES (1U << 31) /* Unsupported options : * Syntax Arithmetic coding (SAC) diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h index e72b4d12b6..a72085ac90 100644 --- a/libavcodec/options_table.h +++ b/libavcodec/options_table.h @@ -83,6 +83,7 @@ static const AVOption avcodec_options[] = { {"export_mvs", "export motion vectors through frame side data", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG2_EXPORT_MVS}, INT_MIN, INT_MAX, V|D, "flags2"}, {"skip_manual", "do not skip samples and export skip information as frame side data", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG2_SKIP_MANUAL}, INT_MIN, INT_MAX, A|D, "flags2"}, {"ass_ro_flush_noop", "do not reset ASS ReadOrder field on flush", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG2_RO_FLUSH_NOOP}, INT_MIN, INT_MAX, S|D, "flags2"}, +{"icc_profiles", "generate/parse embedded ICC profiles from/to colorimetry tags", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG2_ICC_PROFILES}, INT_MIN, INT_MAX, S|D, "flags2"}, {"export_side_data", "Export metadata as side data", OFFSET(export_side_data), AV_OPT_TYPE_FLAGS, {.i64 = DEFAULT}, 0, UINT_MAX, A|V|S|D|E, "export_side_data"}, {"mvs", "export motion vectors through frame side data", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_EXPORT_DATA_MVS}, INT_MIN, INT_MAX, V|D, "export_side_data"}, {"prft", "export Producer Reference Time through packet side data", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_EXPORT_DATA_PRFT}, INT_MIN, INT_MAX, A|V|S|E, "export_side_data"}, diff --git a/libavcodec/version.h b/libavcodec/version.h index f2f14eaed1..19f3f4a272 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -29,7 +29,7 @@ #include "version_major.h" -#define LIBAVCODEC_VERSION_MINOR 39 +#define LIBAVCODEC_VERSION_MINOR 40 #define LIBAVCODEC_VERSION_MICRO 100 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \