Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Niklas Haas <ffmpeg@haasn.xyz>
To: ffmpeg-devel@ffmpeg.org
Cc: Niklas Haas <git@haasn.dev>
Subject: [FFmpeg-devel] [PATCH v4 4/7] avcodec: add common fflcms2 boilerplate
Date: Thu, 28 Jul 2022 16:49:59 +0200
Message-ID: <20220728145002.102600-5-ffmpeg@haasn.xyz> (raw)
In-Reply-To: <20220728145002.102600-1-ffmpeg@haasn.xyz>

From: Niklas Haas <git@haasn.dev>

Handling this in general code makes more sense than handling it in
individual codec files, because it would be a lot of unnecessary code
duplication for the plenty of formats that support exporting ICC
profiles (jpg, png, tiff, webp, jxl, ...).

encode.c and decode.c will be in charge of initializing this state as
needed, so we merely need to make sure to uninit it afterwards from the
common destructor path.

Signed-off-by: Niklas Haas <git@haasn.dev>
---
 configure             | 2 +-
 libavcodec/Makefile   | 1 +
 libavcodec/avcodec.c  | 4 ++++
 libavcodec/decode.c   | 4 ++++
 libavcodec/internal.h | 8 ++++++++
 5 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/configure b/configure
index 6629d14099..8c7e8c9d1d 100755
--- a/configure
+++ b/configure
@@ -3814,7 +3814,7 @@ swresample_suggest="libm libsoxr stdatomic"
 swscale_deps="avutil"
 swscale_suggest="libm stdatomic"
 
-avcodec_extralibs="pthreads_extralibs iconv_extralibs dxva2_extralibs"
+avcodec_extralibs="pthreads_extralibs iconv_extralibs dxva2_extralibs lcms2_extralibs"
 avfilter_extralibs="pthreads_extralibs"
 avutil_extralibs="d3d11va_extralibs nanosleep_extralibs pthreads_extralibs vaapi_drm_extralibs vaapi_x11_extralibs vdpau_x11_extralibs"
 
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 6751b6b591..aff7752856 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -114,6 +114,7 @@ OBJS-$(CONFIG_INTRAX8)                 += intrax8.o intrax8dsp.o msmpeg4data.o
 OBJS-$(CONFIG_IVIDSP)                  += ivi_dsp.o
 OBJS-$(CONFIG_JNI)                     += ffjni.o jni.o
 OBJS-$(CONFIG_JPEGTABLES)              += jpegtables.o
+OBJS-$(CONFIG_LCMS2)                   += fflcms2.o
 OBJS-$(CONFIG_LLAUDDSP)                += lossless_audiodsp.o
 OBJS-$(CONFIG_LLVIDDSP)                += lossless_videodsp.o
 OBJS-$(CONFIG_LLVIDENCDSP)             += lossless_videoencdsp.o
diff --git a/libavcodec/avcodec.c b/libavcodec/avcodec.c
index 4bc18183a9..c9105c5df2 100644
--- a/libavcodec/avcodec.c
+++ b/libavcodec/avcodec.c
@@ -479,6 +479,10 @@ av_cold int avcodec_close(AVCodecContext *avctx)
 
         av_channel_layout_uninit(&avci->initial_ch_layout);
 
+#if CONFIG_LCMS2
+        ff_icc_context_uninit(&avci->icc);
+#endif
+
         av_freep(&avctx->internal);
     }
 
diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index 0613681f89..8922222271 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -49,6 +49,10 @@
 #include "internal.h"
 #include "thread.h"
 
+#if CONFIG_LCMS2
+# include "fflcms2.h"
+#endif
+
 static int apply_param_change(AVCodecContext *avctx, const AVPacket *avpkt)
 {
     int ret;
diff --git a/libavcodec/internal.h b/libavcodec/internal.h
index 6fb4e1b9af..8809a7079a 100644
--- a/libavcodec/internal.h
+++ b/libavcodec/internal.h
@@ -33,6 +33,10 @@
 #include "avcodec.h"
 #include "config.h"
 
+#if CONFIG_LCMS2
+# include "fflcms2.h"
+#endif
+
 #define FF_SANE_NB_CHANNELS 512U
 
 #if HAVE_SIMD_ALIGN_64
@@ -146,6 +150,10 @@ typedef struct AVCodecInternal {
     uint64_t initial_channel_layout;
 #endif
     AVChannelLayout initial_ch_layout;
+
+#if CONFIG_LCMS2
+    FFIccContext icc; /* used to read and write embedded ICC profiles */
+#endif
 } AVCodecInternal;
 
 /**
-- 
2.37.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

  parent reply	other threads:[~2022-07-28 14:51 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-28 14:49 [FFmpeg-devel] [PATCH v4 0/7] ICC profile support in avcodec Niklas Haas
2022-07-28 14:49 ` [FFmpeg-devel] [PATCH v4 1/7] fflcms2: move to libavcodec Niklas Haas
2022-07-28 14:49 ` [FFmpeg-devel] [PATCH v4 2/7] avcodec/codec_internal: add cap for ICC profile support Niklas Haas
2022-07-28 14:49 ` [FFmpeg-devel] [PATCH v4 3/7] avcodec: add API for automatic handling of icc profiles Niklas Haas
2022-07-28 14:49 ` Niklas Haas [this message]
2022-07-28 14:50 ` [FFmpeg-devel] [PATCH v4 5/7] avcodec/decode: parse ICC profiles Niklas Haas
2022-07-28 14:50 ` [FFmpeg-devel] [PATCH v4 6/7] avcodec/encode:: generate " Niklas Haas
2022-07-28 14:50 ` [FFmpeg-devel] [PATCH v4 7/7] fate/png: add test for ICC profile parsing Niklas Haas
2022-07-30  9:59 ` [FFmpeg-devel] [PATCH v4 0/7] ICC profile support in avcodec Niklas Haas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220728145002.102600-5-ffmpeg@haasn.xyz \
    --to=ffmpeg@haasn.xyz \
    --cc=ffmpeg-devel@ffmpeg.org \
    --cc=git@haasn.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git