summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiklas Haas <git@haasn.dev>2022-06-28 15:13:04 +0200
committerNiklas Haas <git@haasn.dev>2022-07-30 11:42:06 +0200
commitc688ddc067e0d9ade731b3adb5c6fde259cbc5f6 (patch)
treebcd91c7df14d55ecebde29425ee1af4c6b0b509c
parente1a0f2df3d8c150016bfa2f0dfde7d6b56c6bf3f (diff)
avcodec: add common fflcms2 boilerplate
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>
-rwxr-xr-xconfigure2
-rw-r--r--libavcodec/Makefile1
-rw-r--r--libavcodec/avcodec.c4
-rw-r--r--libavcodec/decode.c4
-rw-r--r--libavcodec/internal.h8
5 files changed, 18 insertions, 1 deletions
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;
/**