From patchwork Tue Jul 19 12:26:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 36836 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:1649:b0:8b:613a:194d with SMTP id no9csp1714643pzb; Tue, 19 Jul 2022 05:26:56 -0700 (PDT) X-Google-Smtp-Source: AGRyM1ucm2wv8ExuSaRMOJdpYKJc9nbNsCf0GCxxhynCvNrmAE4OjElPdeIFX+Vd27mfG9DCgZUR X-Received: by 2002:a05:6402:190b:b0:43a:c95d:ec93 with SMTP id e11-20020a056402190b00b0043ac95dec93mr42595383edz.44.1658233616084; Tue, 19 Jul 2022 05:26:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658233616; cv=none; d=google.com; s=arc-20160816; b=YhofblZsoJs14Mw1OObgaqsihRpS09clhPl59NA7OMZ4xOw9BtMgQMq4xgtQ93D+zg BRmmhcrXJGIqxCjVmlkIdmwhmddbvdeJkHM7aocm2YCIRIYv7x91gwy6KtTtSaKSQKeO 3hsrIc6K/pFcMOla7Jw37d6/Mbk+A0BJxnooejPdfJgdCLsEiw9x6LimHmaQcusSGyVM JtU22gs1pcoj5RZWU+j7Rv2192GbJXpSwbBVj2o/ESzrpK6pBbKA56bXqX3G10nDKxVe kS69cHw3riLnQRmlqpiB/QfcopCPenSLyZVc5y3so2wrK+hCDOI3Kj01K59wX3tEMA19 8+6A== 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=ij1+/c7Hgrhn7MMTmBo5HVvissFz+fKI69E/puJ3cwM=; b=aTVLEVA0kGi078pDIzug9/2hd5mTwRK7cA/prdbkER+xlFGe7+8zvFJv4TVg4Lks2+ qp6QN/OuiQ1Y1Sk94mei6w8eY/vj107LPYBzxvcJSAo2NL4L4qAd3F53Dv18y+waSbTg UqKVVXmrqx5U70GcKX0LxVIeEDjgdgB8VcuCtUEJsgXljB45x5WZrHgmbvNZ4BNTjT60 AMvuaKScaXElG34dV+/NI7jSuKuBeCs1Qe/WjLs6xmhATmiwdSDzIHg3zflygSRFqnAb NMaaFzDdnKa6/RgDBSd+CKexF2VuqX9YI5SXhl1bcz8fk5oGrCduxy/mEVs6OwnzMtR8 Z5bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@haasn.xyz header.s=mail header.b=Xt1UuDm6; 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 o8-20020a170906974800b0072a9ec4c1fdsi22885854ejy.594.2022.07.19.05.26.55; Tue, 19 Jul 2022 05:26:56 -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=Xt1UuDm6; 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 2639D68B6EC; Tue, 19 Jul 2022 15:26:21 +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 D71C668B590 for ; Tue, 19 Jul 2022 15:26:10 +0300 (EEST) Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id 7F2B24A9CF; Tue, 19 Jul 2022 14:26:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1658233570; bh=yQ4UbZitGbuh8cPYgqDh2k2OdPjCdHDXTVy0bS3MfWI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Xt1UuDm6mzfbxSb82go5XqqoAhfzKRRD9joFJn+7lZ7U9cOdWPdoxefgRC44Ed+bx mmO3eAYKW9Ofuf3K0YrsllOTQcZcQOFYePSzqK9GBOpx51omoufyb+UtJkDZtgxv26 ewbKdcCmK8VgDHvIPiJXsGOC8tTqZtqXaH+VX3+E= From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Tue, 19 Jul 2022 14:26:06 +0200 Message-Id: <20220719122608.43974-5-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220719122608.43974-1-ffmpeg@haasn.xyz> References: <20220719122608.43974-1-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v3 4/6] avcodec: add common fflcms2 boilerplate 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: mYTzxBQVsrDR From: Niklas Haas 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 --- 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 91444cdc53..f7dbe29bfb 100755 --- a/configure +++ b/configure @@ -3813,7 +3813,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 ac9fb575c5..b9a612558d 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 fb11440e5d..7098a28b76 100644 --- a/libavcodec/avcodec.c +++ b/libavcodec/avcodec.c @@ -481,6 +481,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 14ce4c2e2f..cc4fe3b1d5 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 17e1de8127..e284816705 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 @@ -148,6 +152,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; /**