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 6032944A2E for ; Wed, 2 Nov 2022 21:04:11 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2FA3C68BEB4; Wed, 2 Nov 2022 23:04:10 +0200 (EET) Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 723CC68BD10 for ; Wed, 2 Nov 2022 23:04:03 +0200 (EET) Received: (Authenticated sender: michael@niedermayer.cc) by mail.gandi.net (Postfix) with ESMTPSA id 47BFD240006 for ; Wed, 2 Nov 2022 21:04:01 +0000 (UTC) Date: Wed, 2 Nov 2022 22:04:01 +0100 From: Michael Niedermayer To: FFmpeg development discussions and patches Message-ID: <20221102210401.GH1814017@pb2> References: <20221031003235.348-1-mindmark@gmail.com> <20221031003235.348-5-mindmark@gmail.com> MIME-Version: 1.0 In-Reply-To: <20221031003235.348-5-mindmark@gmail.com> Subject: Re: [FFmpeg-devel] [PATCH v2 4/4] swscale/output: add rgbaf32 output support 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="===============7989033462521780848==" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --===============7989033462521780848== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="+Z7/5fzWRHDJ0o7Q" Content-Disposition: inline --+Z7/5fzWRHDJ0o7Q Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, Oct 30, 2022 at 05:32:35PM -0700, mindmark@gmail.com wrote: > From: Mark Reid >=20 > --- > libswscale/output.c | 92 ++++++++++++++++++++++++ > libswscale/swscale_unscaled.c | 4 +- > libswscale/tests/floatimg_cmp.c | 4 +- > libswscale/utils.c | 16 +++-- > libswscale/yuv2rgb.c | 2 + > tests/ref/fate/filter-pixdesc-rgbaf32be | 1 + > tests/ref/fate/filter-pixdesc-rgbaf32le | 1 + > tests/ref/fate/filter-pixdesc-rgbf32be | 1 + > tests/ref/fate/filter-pixdesc-rgbf32le | 1 + > tests/ref/fate/filter-pixfmts-copy | 4 ++ > tests/ref/fate/filter-pixfmts-crop | 4 ++ > tests/ref/fate/filter-pixfmts-field | 4 ++ > tests/ref/fate/filter-pixfmts-fieldorder | 4 ++ > tests/ref/fate/filter-pixfmts-hflip | 4 ++ > tests/ref/fate/filter-pixfmts-il | 4 ++ > tests/ref/fate/filter-pixfmts-null | 4 ++ > tests/ref/fate/filter-pixfmts-scale | 4 ++ > tests/ref/fate/filter-pixfmts-transpose | 4 ++ > tests/ref/fate/filter-pixfmts-vflip | 4 ++ > tests/ref/fate/sws-floatimg-cmp | 16 +++++ > 20 files changed, 170 insertions(+), 8 deletions(-) > create mode 100644 tests/ref/fate/filter-pixdesc-rgbaf32be > create mode 100644 tests/ref/fate/filter-pixdesc-rgbaf32le > create mode 100644 tests/ref/fate/filter-pixdesc-rgbf32be > create mode 100644 tests/ref/fate/filter-pixdesc-rgbf32le >=20 > diff --git a/libswscale/output.c b/libswscale/output.c > index 0e1c1225a0..e2ec9cbdf5 100644 > --- a/libswscale/output.c > +++ b/libswscale/output.c > @@ -2474,6 +2474,92 @@ yuv2gbrpf32_full_X_c(SwsContext *c, const int16_t = *lumFilter, > } > } > =20 > +static void > +yuv2rgbaf32_full_X_c(SwsContext *c, const int16_t *lumFilter, > + const int16_t **lumSrcx, int lumFilterSize, > + const int16_t *chrFilter, const int16_t **chrUSrcx, > + const int16_t **chrVSrcx, int chrFilterSize, > + const int16_t **alpSrcx, uint8_t *dest, > + int dstW, int y) > +{ > + const AVPixFmtDescriptor *desc =3D av_pix_fmt_desc_get(c->dstFormat); > + int i; > + int alpha =3D desc->flags & AV_PIX_FMT_FLAG_ALPHA; > + int hasAlpha =3D alpha && alpSrcx; > + int pixelStep =3D alpha ? 4 : 3; > + uint32_t *dest32 =3D (uint32_t*)dest; > + const int32_t **lumSrc =3D (const int32_t**)lumSrcx; > + const int32_t **chrUSrc =3D (const int32_t**)chrUSrcx; > + const int32_t **chrVSrc =3D (const int32_t**)chrVSrcx; > + const int32_t **alpSrc =3D (const int32_t**)alpSrcx; > + static const float float_mult =3D 1.0f / 65535.0f; > + uint32_t a =3D av_float2int(1.0f); > + > + for (i =3D 0; i < dstW; i++) { > + int j; > + int Y =3D -0x40000000; > + int U =3D -(128 << 23); > + int V =3D -(128 << 23); > + int R, G, B, A; > + > + for (j =3D 0; j < lumFilterSize; j++) > + Y +=3D lumSrc[j][i] * (unsigned)lumFilter[j]; > + > + for (j =3D 0; j < chrFilterSize; j++) { > + U +=3D chrUSrc[j][i] * (unsigned)chrFilter[j]; > + V +=3D chrVSrc[j][i] * (unsigned)chrFilter[j]; > + } > + > + Y >>=3D 14; > + Y +=3D 0x10000; > + U >>=3D 14; > + V >>=3D 14; > + > + if (hasAlpha) { > + A =3D -0x40000000; > + > + for (j =3D 0; j < lumFilterSize; j++) > + A +=3D alpSrc[j][i] * (unsigned)lumFilter[j]; > + > + A >>=3D 1; > + A +=3D 0x20002000; > + a =3D av_float2int(float_mult * (float)(av_clip_uintp2(A, 30= ) >> 14)); > + } > + > + Y -=3D c->yuv2rgb_y_offset; > + Y *=3D c->yuv2rgb_y_coeff; > + Y +=3D 1 << 13; > + R =3D V * c->yuv2rgb_v2r_coeff; > + G =3D V * c->yuv2rgb_v2g_coeff + U * c->yuv2rgb_u2g_coeff; > + B =3D U * c->yuv2rgb_u2b_coeff; > + > + R =3D av_clip_uintp2(Y + R, 30); > + G =3D av_clip_uintp2(Y + G, 30); > + B =3D av_clip_uintp2(Y + B, 30); these additions can overflow i think given sufficiently "bad" input especially with the bt2020 matrix ive posted a proposed solution for the rgba64 / gbrp16/32f cases something similar can be done here thx [...] --=20 Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Opposition brings concord. Out of discord comes the fairest harmony. -- Heraclitus --+Z7/5fzWRHDJ0o7Q Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABEIAB0WIQSf8hKLFH72cwut8TNhHseHBAsPqwUCY2LbOgAKCRBhHseHBAsP q0KhAJ4n6ve/8uqXa65MrivYoRQ+BGQs4wCfTUHy3HmcRmPuvEAq79bwOknoiDE= =XRtd -----END PGP SIGNATURE----- --+Z7/5fzWRHDJ0o7Q-- --===============7989033462521780848== 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". --===============7989033462521780848==--