From patchwork Wed Jun 29 10:12:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 36526 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:8b27:b0:88:1bbf:7fd2 with SMTP id l39csp207126pzh; Wed, 29 Jun 2022 03:13:49 -0700 (PDT) X-Google-Smtp-Source: AGRyM1u9NE1NioDhWZZIJ88Fvl9jyZL+Ex2o4eVDB5livuw5nzP1mxcrljL0zQbLPboyYfGDcFUd X-Received: by 2002:a17:906:9755:b0:722:f1e3:ec1a with SMTP id o21-20020a170906975500b00722f1e3ec1amr2539994ejy.709.1656497629225; Wed, 29 Jun 2022 03:13:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656497629; cv=none; d=google.com; s=arc-20160816; b=AwFFqzhpctMgAeSZxA0KrwsQQ8yBpmG1iq3P42sbOvapk4mCx/ea91liH2xxszlw5+ AHB15UrVVUDvCHuy8C2WHMauJ6bjbkze6nAm41crhVyTPvuh9bwuVYFc/I8/kwOrmKZl r9t+vqhF9CUW3aVzEVaOoBGV3FMolHx4j/M/7KqE1hS/jbMKWUCfrPH2ifI39Z9jaBDR P+2vywut1g27qxgJuYOtuxEFV1sAKjNq+AWRL3U+bVU8M5Q/rXUsWU2kqDxK/NtSaMf9 supzoSzoYF6zJ72YYalVrv4K6LKkfLYNlpDYDb92VPV9YUn2XfhQ//5RNZoH49T2opHZ gUBg== 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=oVPFwVeKb43qQm2IVyet+guFknVNYC07G2HstuB3VwM=; b=oHLYu9OVrshByljHCRbokNVpR7qUlmpc9JLqo6lU9kRfO4/fMPdcT8TrPW7CHsZKLu QdwxrGhSKoqTlogYr4xhNU7E6aVLuK/9VV0dAc1eceRIFKXXJSaFPTANoHdsITlBF8CC 95u7gXqFkCRIbTo/6KO3LP8iZyT9iHpQ3h8I3hShA5pTK6vYf8ZLQs2yfiZFMVbo0gjF yeNyGEtu0AFwi9CfdB94Wx97tMEA6Vn7PfA8eysITSzGRIw7Akm7ktycho/mkCpLFByc MmcPgcRIr3LhRcxGmc0w80JcUlYQmATTjTbb0YK/ddLNWGpKXKULxhNuoY4+H77L3m4l woGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@haasn.xyz header.s=mail header.b=OSUPYeAZ; 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 js3-20020a17090797c300b007263057e377si18060214ejc.863.2022.06.29.03.13.48; Wed, 29 Jun 2022 03:13:49 -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=OSUPYeAZ; 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 C663A68B737; Wed, 29 Jun 2022 13:13:07 +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 BDAD568B6D1 for ; Wed, 29 Jun 2022 13:12:58 +0300 (EEST) Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id 8789A4A7ED; Wed, 29 Jun 2022 12:12:58 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1656497578; bh=DVZDjOhTpdpj1f1R+avj3own3DR0iL7Twdn/JypCtSU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OSUPYeAZYTDUo0eB98Gw72nLrMEl+PmySijVeTwn2cSvdNZ6wanZwexXEt5U4phgj mocdISPI3+fHjREeVxQdxnpMsnf1bc8qlrmnNDj68dOmgoh13zX1C7jNmR8DjIsm3T nTsjUMKn14NI2ThitBCpdQ0ILKbnlB0JsO86NDO4= From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Wed, 29 Jun 2022 12:12:49 +0200 Message-Id: <20220629101251.13236-5-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220629101251.13236-1-ffmpeg@haasn.xyz> References: <20220629101251.13236-1-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 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: coE17fVdkT8N 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 0de9b2abcb..d3f151e246 100755 --- a/configure +++ b/configure @@ -3807,7 +3807,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 5c4f62c631..d2f969ba52 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 5f6e71a39e..3524214546 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 1893caa6a6..d1414c599b 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; /**