Skip to content

Commit c688ddc

Browse files
committed
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 <[email protected]>
1 parent e1a0f2d commit c688ddc

File tree

5 files changed

+18
-1
lines changed

5 files changed

+18
-1
lines changed

configure

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3814,7 +3814,7 @@ swresample_suggest="libm libsoxr stdatomic"
38143814
swscale_deps="avutil"
38153815
swscale_suggest="libm stdatomic"
38163816

3817-
avcodec_extralibs="pthreads_extralibs iconv_extralibs dxva2_extralibs"
3817+
avcodec_extralibs="pthreads_extralibs iconv_extralibs dxva2_extralibs lcms2_extralibs"
38183818
avfilter_extralibs="pthreads_extralibs"
38193819
avutil_extralibs="d3d11va_extralibs nanosleep_extralibs pthreads_extralibs vaapi_drm_extralibs vaapi_x11_extralibs vdpau_x11_extralibs"
38203820

libavcodec/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ OBJS-$(CONFIG_INTRAX8) += intrax8.o intrax8dsp.o msmpeg4data.o
114114
OBJS-$(CONFIG_IVIDSP) += ivi_dsp.o
115115
OBJS-$(CONFIG_JNI) += ffjni.o jni.o
116116
OBJS-$(CONFIG_JPEGTABLES) += jpegtables.o
117+
OBJS-$(CONFIG_LCMS2) += fflcms2.o
117118
OBJS-$(CONFIG_LLAUDDSP) += lossless_audiodsp.o
118119
OBJS-$(CONFIG_LLVIDDSP) += lossless_videodsp.o
119120
OBJS-$(CONFIG_LLVIDENCDSP) += lossless_videoencdsp.o

libavcodec/avcodec.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,10 @@ av_cold int avcodec_close(AVCodecContext *avctx)
479479

480480
av_channel_layout_uninit(&avci->initial_ch_layout);
481481

482+
#if CONFIG_LCMS2
483+
ff_icc_context_uninit(&avci->icc);
484+
#endif
485+
482486
av_freep(&avctx->internal);
483487
}
484488

libavcodec/decode.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@
4949
#include "internal.h"
5050
#include "thread.h"
5151

52+
#if CONFIG_LCMS2
53+
# include "fflcms2.h"
54+
#endif
55+
5256
static int apply_param_change(AVCodecContext *avctx, const AVPacket *avpkt)
5357
{
5458
int ret;

libavcodec/internal.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@
3333
#include "avcodec.h"
3434
#include "config.h"
3535

36+
#if CONFIG_LCMS2
37+
# include "fflcms2.h"
38+
#endif
39+
3640
#define FF_SANE_NB_CHANNELS 512U
3741

3842
#if HAVE_SIMD_ALIGN_64
@@ -146,6 +150,10 @@ typedef struct AVCodecInternal {
146150
uint64_t initial_channel_layout;
147151
#endif
148152
AVChannelLayout initial_ch_layout;
153+
154+
#if CONFIG_LCMS2
155+
FFIccContext icc; /* used to read and write embedded ICC profiles */
156+
#endif
149157
} AVCodecInternal;
150158

151159
/**

0 commit comments

Comments
 (0)