diff mbox series

[FFmpeg-devel,v2,3/6] avcodec: add API for automatic handling of icc profiles

Message ID 20220629101251.13236-4-ffmpeg@haasn.xyz
State New
Headers show
Series ICC profile support in avcodec | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished

Commit Message

Niklas Haas June 29, 2022, 10:12 a.m. UTC
From: Niklas Haas <git@haasn.dev>

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 option 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 <git@haasn.dev>
---
 doc/APIchanges       |  4 ++++
 libavcodec/avcodec.h | 10 ++++++++++
 libavcodec/version.h |  2 +-
 3 files changed, 15 insertions(+), 1 deletion(-)

Comments

Anton Khirnov July 6, 2022, 1:34 p.m. UTC | #1
Quoting Niklas Haas (2022-06-29 12:12:48)
> From: Niklas Haas <git@haasn.dev>
> 
> 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 option 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 <git@haasn.dev>
> ---
>  doc/APIchanges       |  4 ++++
>  libavcodec/avcodec.h | 10 ++++++++++
>  libavcodec/version.h |  2 +-
>  3 files changed, 15 insertions(+), 1 deletion(-)
> 
> diff --git a/doc/APIchanges b/doc/APIchanges
> index 20b944933a..b8acf86352 100644
> --- a/doc/APIchanges
> +++ b/doc/APIchanges
> @@ -14,6 +14,10 @@ libavutil:     2021-04-27
>  
>  API changes, most recent first:
>  
> +2022-06-28 - xxxxxxxxx - lavc 59.35.100 - avcodec.h
> +  Add the icc_profiles option to AVCodecContext, to enable automatic reading
> +  and writing of embedded ICC profiles in image files.
> +
>  2022-06-12 - xxxxxxxxxx - lavf 59.25.100 - avio.h
>    Add avio_vprintf(), similar to avio_printf() but allow to use it
>    from within a function taking a variable argument list as input.
> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> index 4dae23d06e..8ee9be22d0 100644
> --- a/libavcodec/avcodec.h
> +++ b/libavcodec/avcodec.h
> @@ -979,6 +979,16 @@ typedef struct AVCodecContext {
>       */
>      enum AVChromaLocation chroma_sample_location;
>  
> +    /**
> +     * Whether to decode/encode ICC profiles. If set, libavcodec will
> +     * generate/parse ICC profiles as appropriate for the type of file. No
> +     * effect on codecs which cannot contain embedded ICC profiles, or when
> +     * compiled without support for lcms2.
> +     * - encoding: Set by user
> +     * - decoding: Set by user
> +     */
> +    int icc_profiles;

This is an ABI break. You could also just add a new AV_CODEC_FLAG
instead.

Also, why should this not be enabled by default?
diff mbox series

Patch

diff --git a/doc/APIchanges b/doc/APIchanges
index 20b944933a..b8acf86352 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -14,6 +14,10 @@  libavutil:     2021-04-27
 
 API changes, most recent first:
 
+2022-06-28 - xxxxxxxxx - lavc 59.35.100 - avcodec.h
+  Add the icc_profiles option to AVCodecContext, to enable automatic reading
+  and writing of embedded ICC profiles in image files.
+
 2022-06-12 - xxxxxxxxxx - lavf 59.25.100 - avio.h
   Add avio_vprintf(), similar to avio_printf() but allow to use it
   from within a function taking a variable argument list as input.
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 4dae23d06e..8ee9be22d0 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -979,6 +979,16 @@  typedef struct AVCodecContext {
      */
     enum AVChromaLocation chroma_sample_location;
 
+    /**
+     * Whether to decode/encode ICC profiles. If set, libavcodec will
+     * generate/parse ICC profiles as appropriate for the type of file. No
+     * effect on codecs which cannot contain embedded ICC profiles, or when
+     * compiled without support for lcms2.
+     * - encoding: Set by user
+     * - decoding: Set by user
+     */
+    int icc_profiles;
+
     /**
      * Number of slices.
      * Indicates number of picture subdivisions. Used for parallelized
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 0ef6c991f3..1008fead27 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -29,7 +29,7 @@ 
 
 #include "version_major.h"
 
-#define LIBAVCODEC_VERSION_MINOR  34
+#define LIBAVCODEC_VERSION_MINOR  35
 #define LIBAVCODEC_VERSION_MICRO 100
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \