From patchwork Thu Sep 28 15:10:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 44000 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:2a18:b0:15d:8365:d4b8 with SMTP id e24csp3350757pzh; Thu, 28 Sep 2023 08:11:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHimUBlxahsrmFxuFr5rHexDsYG/zSnS6gtdWMaBqyccs/AkZytHirU7l+/OeYE5X01t1R0 X-Received: by 2002:a05:6402:12c1:b0:533:12b1:ebe7 with SMTP id k1-20020a05640212c100b0053312b1ebe7mr1645162edx.15.1695913900653; Thu, 28 Sep 2023 08:11:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695913900; cv=none; d=google.com; s=arc-20160816; b=MjSbu9FmNLLAyS4+uxlFVQ6b75alvzupVkPmqiHXpKxuVgLqHzg4o2vM9pQZqNYowy Lo9bVl8tqxUnKCzRZ/0fU3ZqwoSsBn6gumYL3RpF5NHdM+w7mVgKWj+1i/D+LdIwxcNp u04Vm+Eaag11nuVgLej42uASFW1xqAy/Ap6O8qHW5+FbwDNS8S3Lerv3xUXAbN5gTLGN 1b6d7AF5/ghI6ZDla8+ucRllpwcMGwvbpRtU4OV50namPfAD00Ryszzm3JTTxWgjz6xt HvELOO75YjF+fYjGIKoyBglHbswyCCRF+Wn/PFrPGjBIg9s2gLdYxF7f3+tV+RJMxtjm qecQ== 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:message-id:date:to:from :dkim-signature:delivered-to; bh=9GU/BCGwRknThuAAXv34ZhstiAMTJYIZgwNjPn0y8rM=; fh=xmAeKtysnShNOmkhiJmYkS30uw4Fu2hvBJ7qlIwukxQ=; b=MIXXcYaAs2BZSG9MBzl9eG+sxsOLA4OLGESgxuSK2APh7UhryqPzBlncbPPKic1KjW eXYoqhKfYrOxuG3LmGJU1jFWAXEJIMuG9ZBdwshmBBhl16DND9tVx9zprrZ+7N142L2D 3KKOs1iP/8qCFEyoZtw1jsMKzusrj4d40Xs8AXRFq1Q3NSEYE0gT/NSuna3C9+pbLpzg P88wRtTDPjj84iuKZjq6cQDwvmGJM7R+gZivXWokJuFAqAvG43JwR/2yC6kZ2tfgIVZ/ JXWKFC3DqKKJw66KxtXfpNmE8eOr5I/NjZBkjxaR/oWfRhMTHg2TewijAWKI3yGZOuXo Xl/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@haasn.xyz header.s=mail header.b="LN5+/mUn"; 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 n26-20020a056402061a00b0053637a8d4desi296155edv.288.2023.09.28.08.11.16; Thu, 28 Sep 2023 08:11:40 -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="LN5+/mUn"; 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 C72D068CB84; Thu, 28 Sep 2023 18:10:53 +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 25A8068CB75 for ; Thu, 28 Sep 2023 18:10:45 +0300 (EEST) Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id 1367040486; Thu, 28 Sep 2023 17:10:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1695913844; bh=Dp/jkmviEPfa2DbrtlCngk76CFMswXfkm1SRqnX+5EU=; h=From:To:Cc:Subject:Date:From; b=LN5+/mUniKdAzy5WE8FYfY4ZRIL4bu4I+n+KwQIH/DTJf7jbd4ORCpjfEOjhs0rma a1TTW/5t2Nbd7oFbHUm9IYW9i5c1iyOHJIM8K6W2jho6MceC5KLlxSI5jFVj6piuWS OWL3Gj6PkxLfq0bFydSlF4jaLCPOFLdUsL5BHM/s= From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Thu, 28 Sep 2023 17:10:39 +0200 Message-ID: <20230928151041.57953-1-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 1/3] avcodec/fflcms2: add ff_icc_profile_sanitize 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: qIEC8yyGgM1v From: Niklas Haas Buggy ICCv4 profiles are unfortunately used in the wild, and it's quite easy to work around them by just forcing the white point to the correct value. Display a warning just in case. See-Also: https://trac.ffmpeg.org/ticket/9673 --- libavcodec/fflcms2.c | 51 ++++++++++++++++++++++++++++++++++++++++++++ libavcodec/fflcms2.h | 7 ++++++ 2 files changed, 58 insertions(+) diff --git a/libavcodec/fflcms2.c b/libavcodec/fflcms2.c index 5443f178bc9..3b67e62d3af 100644 --- a/libavcodec/fflcms2.c +++ b/libavcodec/fflcms2.c @@ -201,6 +201,57 @@ static av_always_inline void XYZ_xy(cmsCIEXYZ XYZ, AVCIExy *xy) xy->y = av_d2q(k * XYZ.Y, 100000); } +static av_always_inline AVRational abs_sub_q(AVRational r1, AVRational r2) +{ + AVRational diff = av_sub_q(r1, r2); + /* denominator assumed to be positive */ + return av_make_q(abs(diff.num), diff.den); +} + +static const AVCIExy wp_d50 = { {3457, 10000}, {3585, 10000} }; /* CIE D50 */ + +int ff_icc_profile_sanitize(FFIccContext *s, cmsHPROFILE profile) +{ + cmsCIEXYZ *white, fixed; + AVCIExy wpxy; + AVRational diff, z; + if (!profile) + return 0; + + if (cmsGetEncodedICCversion(profile) >= 0x4000000) { // ICC v4 + switch (cmsGetHeaderRenderingIntent(profile)) { + case INTENT_RELATIVE_COLORIMETRIC: + case INTENT_ABSOLUTE_COLORIMETRIC: ; + /* ICC v4 colorimetric profiles are specified to always use D50 + * media white point, anything else is a violation of the spec. + * Sadly, such profiles are incredibly common (Apple...), so make + * an effort to fix them. */ + if (!(white = cmsReadTag(profile, cmsSigMediaWhitePointTag))) + return AVERROR_INVALIDDATA; + XYZ_xy(*white, &wpxy); + diff = av_add_q(abs_sub_q(wpxy.x, wp_d50.x), abs_sub_q(wpxy.y, wp_d50.y)); + if (av_cmp_q(diff, av_make_q(1, 1000)) > 0) { + av_log(s->avctx, AV_LOG_WARNING, "Invalid colorimetric ICCv4 " + "profile media white point tag (expected %.4f %.4f, " + "got %.4f %.4f)\n", + av_q2d(wp_d50.x), av_q2d(wp_d50.y), + av_q2d(wpxy.x), av_q2d(wpxy.y)); + /* x+y+z = 1 */ + z = av_sub_q(av_sub_q(av_make_q(1, 1), wp_d50.x), wp_d50.y); + fixed.X = av_q2d(av_div_q(wp_d50.x, wp_d50.y)) * white->Y; + fixed.Y = white->Y; + fixed.Z = av_q2d(av_div_q(z, wp_d50.y)) * white->Y; + if (!cmsWriteTag(profile, cmsSigMediaWhitePointTag, &fixed)) + return AVERROR_EXTERNAL; + } + break; + default: break; + } + } + + return 0; +} + int ff_icc_profile_read_primaries(FFIccContext *s, cmsHPROFILE profile, AVColorPrimariesDesc *out_primaries) { diff --git a/libavcodec/fflcms2.h b/libavcodec/fflcms2.h index af63c9a13c8..b54173e50e2 100644 --- a/libavcodec/fflcms2.h +++ b/libavcodec/fflcms2.h @@ -65,6 +65,13 @@ int ff_icc_profile_generate(FFIccContext *s, */ int ff_icc_profile_attach(FFIccContext *s, cmsHPROFILE profile, AVFrame *frame); +/** + * Sanitize an ICC profile to try and fix badly broken values. + * + * Returns 0 on success, or a negative error code. + */ +int ff_icc_profile_sanitize(FFIccContext *s, cmsHPROFILE profile); + /** * Read the color primaries and white point coefficients encoded by an ICC * profile, and return the raw values in `out_primaries`. From patchwork Thu Sep 28 15:10:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 43999 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:2a18:b0:15d:8365:d4b8 with SMTP id e24csp3350582pzh; Thu, 28 Sep 2023 08:11:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFNwj2erIVsnnUThGXx9N0xZiK8H4XWLm4wc0VyrtvCsP2o9uUpOa89IPWAfnfPgyNZSMbD X-Received: by 2002:a17:906:7696:b0:9a9:f239:d874 with SMTP id o22-20020a170906769600b009a9f239d874mr1661847ejm.58.1695913886286; Thu, 28 Sep 2023 08:11:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695913886; cv=none; d=google.com; s=arc-20160816; b=izabyFHDswqzvfLCvdUzlu9KjE6MQiGzQQKTXrlgtuN52BdUhp0aiBnxi7FvX/ssVh R4Ttru0zB1hQWbY8IqjX3m2q1uiaobcjIJxjj3VZw7SbbVHBlcd+nd/9v4JCyK947p3r Id/RNE0XXP9uX63phxmADKth0EWhQv3w6iSWa5CfrTb/YttrsbYjKg7swSljGo4ZPBDU WpfhFTbH/XFYarnpDMinX3hJtDhP+sHezIc4nSbGNRafOKfv2WfxBj2d7Hals6a1EF0Q bwvro5zz9YTxncf5lIqMl2nFlp4o07QEC34/sd+dxehbEn9ksgLgpgnGLf6qFogwm0Xy mH+g== 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=nSvSVyS/QcjzerIBVYfh6ilcR8rPZREnqjvWZOzG0sU=; fh=xmAeKtysnShNOmkhiJmYkS30uw4Fu2hvBJ7qlIwukxQ=; b=f0Gznya40TyiuPFbnoRpMNB/1SFukxw+VgH1o43mzXJ1lYBF8bhsqGaLWXtUviu4T5 GuvFkDEBwWS3LT2tBEdq315+q2tjzx2bfnaw2btT7YPG5Lw0FDfR8vRTr4LGJ+w37jbh m0vlbDRzdi0+PN4cfyXSUzpUzV2rc+9YNrvHyicKbGliWi8182urZUfmzMYf3/HnYJae sAkWAaAjDbqvsL/unGfLWjvlCyQYHKnMfqbsJ+qB3OWFJwUWPV13jL7QuMW6Ogh8xvGs hc7722GASfzA0QmomkZ9eeGmBidlaMdPGG34AbxMWSpfhxnWRJJH8RG3D2PtaUNjYtCW zG7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@haasn.xyz header.s=mail header.b=DjYGuIp1; 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 h11-20020a170906590b00b00993150ec3c4si15594804ejq.970.2023.09.28.08.11.09; Thu, 28 Sep 2023 08:11:26 -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=DjYGuIp1; 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 CBBCF68CB39; Thu, 28 Sep 2023 18:10:50 +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 A11F668C9EE for ; Thu, 28 Sep 2023 18:10:44 +0300 (EEST) Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id 555D3408F8; Thu, 28 Sep 2023 17:10:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1695913844; bh=tYYhgSpMaB35HuIZ/CW7jUYOwD8PTXPHDtLUWzsOTD8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DjYGuIp10q93UCJiuVYt5YOzsJdwBH7r2ppDnI7eWi1hSlbBZyYe4AvlWjzXO6zIj HxbDFbTOQplQPRElWAwhESCri67YanMhHq/dVQblAD570TiZoYax5lDoG4JXDhVoQt NPfEcmZOJyM0SuvkTAPH185lm6XkAMs1tJZ4PaU8= From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Thu, 28 Sep 2023 17:10:40 +0200 Message-ID: <20230928151041.57953-2-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230928151041.57953-1-ffmpeg@haasn.xyz> References: <20230928151041.57953-1-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 2/3] avfilter/vf_iccdetect: use ff_icc_profile_sanitize 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: +FSdxglb00Ef From: Niklas Haas --- libavfilter/vf_iccdetect.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libavfilter/vf_iccdetect.c b/libavfilter/vf_iccdetect.c index 5288b0320d2..16eacbbb560 100644 --- a/libavfilter/vf_iccdetect.c +++ b/libavfilter/vf_iccdetect.c @@ -93,7 +93,9 @@ static int iccdetect_filter_frame(AVFilterLink *inlink, AVFrame *frame) if (!profile) return AVERROR_INVALIDDATA; - ret = ff_icc_profile_read_primaries(&s->icc, profile, &coeffs); + ret = ff_icc_profile_sanitize(&s->icc, profile); + if (!ret) + ret = ff_icc_profile_read_primaries(&s->icc, profile, &coeffs); if (!ret) ret = ff_icc_profile_detect_transfer(&s->icc, profile, &s->profile_trc); cmsCloseProfile(profile); From patchwork Thu Sep 28 15:10:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 43998 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:2a18:b0:15d:8365:d4b8 with SMTP id e24csp3350435pzh; Thu, 28 Sep 2023 08:11:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFIp0a+zUQvITrYJgh+MHZenWK5wZmkd5dNSAOL3ia3dX1SbWGWxM3YjtXBALNMuojJU8Qz X-Received: by 2002:a05:6402:d2:b0:523:3f1e:68c4 with SMTP id i18-20020a05640200d200b005233f1e68c4mr1571379edu.34.1695913875247; Thu, 28 Sep 2023 08:11:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695913875; cv=none; d=google.com; s=arc-20160816; b=Wcb4VaoJlX2oAR1vPEoUuo01/GU+C3ZZlygyVY+YQqjgx1g1pghc5VSSQOWyunpPkj 2eVXkoD0pBf4CeRlG19eG5wIj/V2Ka5CzOZwyA9RanklSz3+Z3OSkGDYj0RqDCff9pBY 769lrjH9xSARuIuHOW3N6rJdIzLTzLpdBxV7vaMW1rVaMxUpRFEJBkPuMb+QFZxNLJZc FE1mjVLBtelC2YdvYiCTdH46cZ8M+hDxhA29G45PXj5T4S9yMtse9avfJJ1PExEfd5bI 2KE/K5PRRe9vEO3qpi77y0sB5IgA1xKYXp5dZjMYW+V3kUMZ/CFlRDDzx+U3xnSGdAR8 dPtQ== 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=qCATyj8GcQ+HFjZFrvfWNcRxUYxwlaiv53EfPNrEwik=; fh=xmAeKtysnShNOmkhiJmYkS30uw4Fu2hvBJ7qlIwukxQ=; b=vVPZORxVauyF5xUeR/SP7u7I0UzHsFY7yY8lbS04awbgo3GizeBgBJguv1CcwvasSV xEcPIYRRdj0k7KkuW3F8xxb10tlW/NEcm1VfTXzw317xCRSE8nxLkd7ny4/DSmREMZ1z WCaLkLddJhKvOxMuzpJWMgSkEJqUOVLsfuEBv4vkt9dUyUfPZWFKAH4EXkkhAE9Yq2HG HLwveMNOILtBhs5d5FYTPYYVXm49tOdY6d+tOcRWBtlqs6FJXQTu+acMtFDobf1T0Slu 8cl9gKTMdi/CposRsl+j00qQWKaoxE2oLSdcpwpy8jQGtMWYc50VsElnd3NrPtMl8bor gRXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@haasn.xyz header.s=mail header.b="mPtE8C/z"; 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 d19-20020a05640208d300b005329f1aa075si4247576edz.211.2023.09.28.08.11.05; Thu, 28 Sep 2023 08:11:15 -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="mPtE8C/z"; 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 BDF4968CB7F; Thu, 28 Sep 2023 18:10:51 +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 D8BB268C9EE for ; Thu, 28 Sep 2023 18:10:44 +0300 (EEST) Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id 99D3B43600; Thu, 28 Sep 2023 17:10:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1695913844; bh=xYGIxu1nb9iUxBrPDglbb37NKRlHV8Cub7Wf/fge4oY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mPtE8C/zwUe2dLukaEs27PukjVXKxSE5hVhT5e/AvI+p3DZgfI6YX3Y2YrCNLpPo3 RwqvhY3W4pfzs2QptzdtIvDfH3plf+Y0maUNTy1TbGwdsOyRBCvBG5v1AIab7cJQmq LG8uXnTbHJq1dI4tch3yw9bEuKOF4O3DZB6dkjos= From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Thu, 28 Sep 2023 17:10:41 +0200 Message-ID: <20230928151041.57953-3-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230928151041.57953-1-ffmpeg@haasn.xyz> References: <20230928151041.57953-1-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 3/3] avcodec/decode: use ff_icc_profile_sanitize 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: rmtlmVDm613D From: Niklas Haas Fixes: https://trac.ffmpeg.org/ticket/9673 --- libavcodec/decode.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libavcodec/decode.c b/libavcodec/decode.c index 466c393c1e2..6f4ef7da0c2 100644 --- a/libavcodec/decode.c +++ b/libavcodec/decode.c @@ -536,7 +536,9 @@ static int detect_colorspace(AVCodecContext *avctx, AVFrame *frame) if (!profile) return AVERROR_INVALIDDATA; - ret = ff_icc_profile_read_primaries(&avci->icc, profile, &coeffs); + ret = ff_icc_profile_sanitize(&avci->icc, profile); + if (!ret) + ret = ff_icc_profile_read_primaries(&avci->icc, profile, &coeffs); if (!ret) ret = ff_icc_profile_detect_transfer(&avci->icc, profile, &trc); cmsCloseProfile(profile);