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 9C67044C14 for ; Sun, 13 Nov 2022 21:25:05 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D3F1C68BCA6; Sun, 13 Nov 2022 23:25:02 +0200 (EET) Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C03CA68BB9A for ; Sun, 13 Nov 2022 23:24:56 +0200 (EET) Received: (Authenticated sender: michael@niedermayer.cc) by mail.gandi.net (Postfix) with ESMTPSA id 7292FE0002 for ; Sun, 13 Nov 2022 21:24:55 +0000 (UTC) Date: Sun, 13 Nov 2022 22:24:53 +0100 From: Michael Niedermayer To: FFmpeg development discussions and patches Message-ID: <20221113212453.GF1814017@pb2> References: <20221103040010.1134-1-mindmark@gmail.com> <20221103040010.1134-2-mindmark@gmail.com> MIME-Version: 1.0 In-Reply-To: <20221103040010.1134-2-mindmark@gmail.com> Subject: Re: [FFmpeg-devel] [PATCH v3 1/4] swscale/input: add rgbaf32 input 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="===============6343263446295848876==" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --===============6343263446295848876== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="hU50fLDIZPaBYjJk" Content-Disposition: inline --hU50fLDIZPaBYjJk Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Nov 02, 2022 at 09:00:07PM -0700, mindmark@gmail.com wrote: > From: Mark Reid >=20 > --- > libswscale/input.c | 172 +++++++++++++++++++++++++++++++++++++++++++++ > libswscale/utils.c | 4 ++ > 2 files changed, 176 insertions(+) >=20 > diff --git a/libswscale/input.c b/libswscale/input.c > index 7ff7bfaa01..4683284b0b 100644 > --- a/libswscale/input.c > +++ b/libswscale/input.c > @@ -1284,6 +1284,136 @@ static void rgbaf16##endian_name##ToA_c(uint8_t *= _dst, const uint8_t *_src, cons > rgbaf16_funcs_endian(le, 0) > rgbaf16_funcs_endian(be, 1) > =20 > +#define rdpx(src) (is_be ? av_int2float(AV_RB32(&src)): av_int2float(AV_= RL32(&src))) > + > +static av_always_inline void rgbaf32ToUV_half_endian(uint16_t *dstU, uin= t16_t *dstV, int is_be, > + const float *src, i= nt width, > + int32_t *rgb2yuv, i= nt comp) > +{ > + int32_t ru =3D rgb2yuv[RU_IDX], gu =3D rgb2yuv[GU_IDX], bu =3D rgb2y= uv[BU_IDX]; > + int32_t rv =3D rgb2yuv[RV_IDX], gv =3D rgb2yuv[GV_IDX], bv =3D rgb2y= uv[BV_IDX]; > + int i; > + for (i =3D 0; i < width; i++) { > + int r =3D (lrintf(av_clipf(65535.0f * rdpx(src[i*(comp*2)+0]), 0= =2E0f, 65535.0f)) + > + lrintf(av_clipf(65535.0f * rdpx(src[i*(comp*2)+4]), 0.0= f, 65535.0f))) >> 1; > + int g =3D (lrintf(av_clipf(65535.0f * rdpx(src[i*(comp*2)+1]), 0= =2E0f, 65535.0f)) + > + lrintf(av_clipf(65535.0f * rdpx(src[i*(comp*2)+5]), 0.0= f, 65535.0f))) >> 1; > + int b =3D (lrintf(av_clipf(65535.0f * rdpx(src[i*(comp*2)+2]), 0= =2E0f, 65535.0f)) + > + lrintf(av_clipf(65535.0f * rdpx(src[i*(comp*2)+6]), 0.0= f, 65535.0f))) >> 1; > + > + dstU[i] =3D (ru*r + gu*g + bu*b + (0x10001<<(RGB2YUV_SHIFT-1))) = >> RGB2YUV_SHIFT; > + dstV[i] =3D (rv*r + gv*g + bv*b + (0x10001<<(RGB2YUV_SHIFT-1))) = >> RGB2YUV_SHIFT; I would expect this sort of code to use 2 lrintf() and 2 av_clipf() not 6 > + } > +} > + > +static av_always_inline void rgbaf32ToUV_endian(uint16_t *dstU, uint16_t= *dstV, int is_be, > + const float *src, int wi= dth, > + int32_t *rgb2yuv, int co= mp) > +{ > + int32_t ru =3D rgb2yuv[RU_IDX], gu =3D rgb2yuv[GU_IDX], bu =3D rgb2y= uv[BU_IDX]; > + int32_t rv =3D rgb2yuv[RV_IDX], gv =3D rgb2yuv[GV_IDX], bv =3D rgb2y= uv[BV_IDX]; > + int i; > + for (i =3D 0; i < width; i++) { > + int r =3D lrintf(av_clipf(65535.0f * rdpx(src[i*comp+0]), 0.0f, = 65535.0f)); > + int g =3D lrintf(av_clipf(65535.0f * rdpx(src[i*comp+1]), 0.0f, = 65535.0f)); > + int b =3D lrintf(av_clipf(65535.0f * rdpx(src[i*comp+2]), 0.0f, = 65535.0f)); > + > + dstU[i] =3D (ru*r + gu*g + bu*b + (0x10001<<(RGB2YUV_SHIFT-1))) = >> RGB2YUV_SHIFT; > + dstV[i] =3D (rv*r + gv*g + bv*b + (0x10001<<(RGB2YUV_SHIFT-1))) = >> RGB2YUV_SHIFT; > + } > +} > + > +static av_always_inline void rgbaf32ToY_endian(uint16_t *dst, const floa= t *src, int is_be, > + int width, int32_t *rgb2y= uv, int comp) > +{ > + int32_t ry =3D rgb2yuv[RY_IDX], gy =3D rgb2yuv[GY_IDX], by =3D rgb2y= uv[BY_IDX]; > + int i; > + for (i =3D 0; i < width; i++) { > + int r =3D lrintf(av_clipf(65535.0f * rdpx(src[i*comp+0]), 0.0f, = 65535.0f)); > + int g =3D lrintf(av_clipf(65535.0f * rdpx(src[i*comp+1]), 0.0f, = 65535.0f)); > + int b =3D lrintf(av_clipf(65535.0f * rdpx(src[i*comp+2]), 0.0f, = 65535.0f)); > + > + dst[i] =3D (ry*r + gy*g + by*b + (0x2001<<(RGB2YUV_SHIFT-1))) >>= RGB2YUV_SHIFT; there is one output so there should be only need for one clip and one float= ->int thx [...] --=20 Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Any man who breaks a law that conscience tells him is unjust and willingly= =20 accepts the penalty by staying in jail in order to arouse the conscience of= =20 the community on the injustice of the law is at that moment expressing the= =20 very highest respect for law. - Martin Luther King Jr --hU50fLDIZPaBYjJk Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABEIAB0WIQSf8hKLFH72cwut8TNhHseHBAsPqwUCY3FgngAKCRBhHseHBAsP qyW/AJ9afLSPOS9fhYZaESq+BS6Ie26WZQCfZmubAo8ze2YqO0F0oyww1NQw6ws= =GEkB -----END PGP SIGNATURE----- --hU50fLDIZPaBYjJk-- --===============6343263446295848876== 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". --===============6343263446295848876==--