From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id CE88E47E3B for ; Fri, 27 Oct 2023 21:42:53 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A901E68CBAA; Sat, 28 Oct 2023 00:42:50 +0300 (EEST) Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D92B168CA7F for ; Sat, 28 Oct 2023 00:42:43 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id F2A0A1BF203 for ; Fri, 27 Oct 2023 21:42:42 +0000 (UTC) Date: Fri, 27 Oct 2023 23:42:41 +0200 From: Michael Niedermayer To: FFmpeg development discussions and patches Message-ID: <20231027214241.GB3543730@pb2> References: <20231027170446.63684-1-ffmpeg@haasn.xyz> MIME-Version: 1.0 In-Reply-To: <20231027170446.63684-1-ffmpeg@haasn.xyz> X-GND-Sasl: michael@niedermayer.cc Subject: Re: [FFmpeg-devel] [PATCH 1/8] swscale: fix sws_setColorspaceDetails after sws_init_context 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 Content-Type: multipart/mixed; boundary="===============5608102842336348367==" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --===============5608102842336348367== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="U0blWO7FHY8PxXnG" Content-Disposition: inline --U0blWO7FHY8PxXnG Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Oct 27, 2023 at 07:04:39PM +0200, Niklas Haas wrote: > From: Niklas Haas >=20 > More commonly, this fixes the case of sws_setColorspaceDetails after > sws_getContext, since the latter implies sws_init_context. >=20 > The problem here is that sws_init_context sets up the range conversion > and fast path tables based on the values of srcRange/dstRange at init > time. This may result in locking in a "wrong" path (either using > unscaled fast path when range conversion later required, or using > scaled slow path when range conversion becomes no longer required). >=20 > There are two way outs: >=20 > 1. Always initialize range conversion and unscaled converters, even if > they will be unused, and extend the runtime check. > 2. Re-do initialization if the values change after > sws_setColorspaceDetails. >=20 > I opted for approach 1 because it was simpler and easier to reason > about. > --- > libswscale/swscale.c | 2 +- > libswscale/utils.c | 5 +---- > 2 files changed, 2 insertions(+), 5 deletions(-) >=20 > diff --git a/libswscale/swscale.c b/libswscale/swscale.c > index 90e5b299ab..46ba68fe6a 100644 > --- a/libswscale/swscale.c > +++ b/libswscale/swscale.c > @@ -1016,7 +1016,7 @@ static int scale_internal(SwsContext *c, > reset_ptr(src2, c->srcFormat); > reset_ptr((void*)dst2, c->dstFormat); > =20 > - if (c->convert_unscaled) { > + if (c->convert_unscaled && !c->lumConvertRange && !c->chrConvertRang= e) { > int offset =3D srcSliceY_internal; > int slice_h =3D srcSliceH; > =20 > diff --git a/libswscale/utils.c b/libswscale/utils.c > index e1ad685972..455955e907 100644 > --- a/libswscale/utils.c > +++ b/libswscale/utils.c > @@ -1728,9 +1728,7 @@ static av_cold int sws_init_single_context(SwsConte= xt *c, SwsFilter *srcFilter, > } > =20 > /* unscaled special cases */ > - if (unscaled && !usesHFilter && !usesVFilter && > - (c->srcRange =3D=3D c->dstRange || isAnyRGB(dstFormat) || > - isFloat(srcFormat) || isFloat(dstFormat))){ > + if (unscaled && !usesHFilter && !usesVFilter) { > ff_get_unscaled_swscale(c); > =20 > if (c->convert_unscaled) { > @@ -1738,7 +1736,6 @@ static av_cold int sws_init_single_context(SwsConte= xt *c, SwsFilter *srcFilter, > av_log(c, AV_LOG_INFO, > "using unscaled %s -> %s special converter\n", > av_get_pix_fmt_name(srcFormat), av_get_pix_fmt_na= me(dstFormat)); > - return 0; > } > } the av_log() message will be wrong if this path is unused also this ties convert_unscaled to never do range conversion, if thats intended, i guess thats ok. Otherwise that maybe is a restriction we dont want to add. thx [...] --=20 Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB "I am not trying to be anyone's saviour, I'm trying to think about the future and not be sad" - Elon Musk --U0blWO7FHY8PxXnG Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABEIAB0WIQSf8hKLFH72cwut8TNhHseHBAsPqwUCZTwuzgAKCRBhHseHBAsP q0E7AKCJhy1CQA0ZFKVZEekxaiLTWsPU6QCfe77WcjiL7HpqZV+sb6p1kepU9QE= =yzRb -----END PGP SIGNATURE----- --U0blWO7FHY8PxXnG-- --===============5608102842336348367== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". --===============5608102842336348367==--