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 03BBD4518A for ; Fri, 12 May 2023 23:36:59 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3065968C006; Sat, 13 May 2023 02:36:56 +0300 (EEST) Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id AADE268BF11 for ; Sat, 13 May 2023 02:36:49 +0300 (EEST) Received: (Authenticated sender: michael@niedermayer.cc) by mail.gandi.net (Postfix) with ESMTPSA id BA24BC0002 for ; Fri, 12 May 2023 23:36:48 +0000 (UTC) Date: Sat, 13 May 2023 01:36:47 +0200 From: Michael Niedermayer To: FFmpeg development discussions and patches Message-ID: <20230512233647.GE1391451@pb2> References: MIME-Version: 1.0 In-Reply-To: Subject: Re: [FFmpeg-devel] [PATCH] swresample: misc improvements 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="===============1252853191957044635==" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --===============1252853191957044635== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="KJKxYQkVikLexIKR" Content-Disposition: inline --KJKxYQkVikLexIKR Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, May 11, 2023 at 07:13:19PM +0200, Paul B Mahol wrote: > Attached. [...] > @@ -33,64 +33,86 @@ > =20 > =20 > #define CONV_FUNC_NAME(dst_fmt, src_fmt) conv_ ## src_fmt ## _to_ ## dst= _fmt > +#define CONVP_FUNC_NAME(dst_fmt, src_fmt) convp_ ## src_fmt ## _to_ ## d= st_fmt > =20 > //FIXME rounding ? > -#define CONV_FUNC(ofmt, otype, ifmt, expr)\ > +#define CONV_FUNC(ofmt, otype, ifmt, itype, expr)\ > + \ > static void CONV_FUNC_NAME(ofmt, ifmt)(uint8_t *po, const uint8_t *pi, i= nt is, int os, uint8_t *end)\ > {\ > uint8_t *end2 =3D end - 3*os;\ > while(po < end2){\ > + itype x =3D *(itype*)pi;\ > *(otype*)po =3D expr; pi +=3D is; po +=3D os;\ > + x =3D *(itype*)pi;\ > *(otype*)po =3D expr; pi +=3D is; po +=3D os;\ > + x =3D *(itype*)pi;\ > *(otype*)po =3D expr; pi +=3D is; po +=3D os;\ > + x =3D *(itype*)pi;\ > *(otype*)po =3D expr; pi +=3D is; po +=3D os;\ > }\ > while(po < end){\ > + itype x =3D *(itype*)pi;\ > *(otype*)po =3D expr; pi +=3D is; po +=3D os;\ > }\ > +}\ > +\ > +static void CONVP_FUNC_NAME(ofmt, ifmt)(uint8_t *ddst, const uint8_t *ss= rc, int len)\ > +{\ > + const itype *src =3D (const itype *)ssrc;\ > + otype *dst =3D (otype *)ddst;\ > + for (int n =3D 0; n < len; n++){\ > + itype x =3D src[n];\ > + dst[n] =3D expr;\ > + }\ > } > =20 > //FIXME put things below under ifdefs so we do not waste space for cases= no codec will need > -CONV_FUNC(AV_SAMPLE_FMT_U8 , uint8_t, AV_SAMPLE_FMT_U8 , *(const uint8_= t*)pi) > -CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_U8 , (*(const uint8_= t*)pi - 0x80U)<<8) > -CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_U8 , (*(const uint8_= t*)pi - 0x80U)<<24) > -CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_U8 , (uint64_t)((*(c= onst uint8_t*)pi - 0x80U))<<56) > -CONV_FUNC(AV_SAMPLE_FMT_FLT, float , AV_SAMPLE_FMT_U8 , (*(const uint8_= t*)pi - 0x80)*(1.0f/ (1<<7))) > -CONV_FUNC(AV_SAMPLE_FMT_DBL, double , AV_SAMPLE_FMT_U8 , (*(const uint8_= t*)pi - 0x80)*(1.0 / (1<<7))) > -CONV_FUNC(AV_SAMPLE_FMT_U8 , uint8_t, AV_SAMPLE_FMT_S16, (*(const int16_= t*)pi>>8) + 0x80) > -CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_S16, *(const int16_= t*)pi) > -CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_S16, *(const int16_t= *)pi * (1 << 16)) > -CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S16, (uint64_t)(*(co= nst int16_t*)pi)<<48) > -CONV_FUNC(AV_SAMPLE_FMT_FLT, float , AV_SAMPLE_FMT_S16, *(const int16_= t*)pi*(1.0f/ (1<<15))) > -CONV_FUNC(AV_SAMPLE_FMT_DBL, double , AV_SAMPLE_FMT_S16, *(const int16_= t*)pi*(1.0 / (1<<15))) > -CONV_FUNC(AV_SAMPLE_FMT_U8 , uint8_t, AV_SAMPLE_FMT_S32, (*(const int32_= t*)pi>>24) + 0x80) > -CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_S32, *(const int32_= t*)pi>>16) > -CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_S32, *(const int32_= t*)pi) > -CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S32, (uint64_t)(*(co= nst int32_t*)pi)<<32) > -CONV_FUNC(AV_SAMPLE_FMT_FLT, float , AV_SAMPLE_FMT_S32, *(const int32_= t*)pi*(1.0f/ (1U<<31))) > -CONV_FUNC(AV_SAMPLE_FMT_DBL, double , AV_SAMPLE_FMT_S32, *(const int32_= t*)pi*(1.0 / (1U<<31))) > -CONV_FUNC(AV_SAMPLE_FMT_U8 , uint8_t, AV_SAMPLE_FMT_S64, (*(const int64_= t*)pi>>56) + 0x80) > -CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_S64, *(const int64_= t*)pi>>48) > -CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_S64, *(const int64_= t*)pi>>32) > -CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S64, *(const int64_= t*)pi) > -CONV_FUNC(AV_SAMPLE_FMT_FLT, float , AV_SAMPLE_FMT_S64, *(const int64_= t*)pi*(1.0f/ (UINT64_C(1)<<63))) > -CONV_FUNC(AV_SAMPLE_FMT_DBL, double , AV_SAMPLE_FMT_S64, *(const int64_= t*)pi*(1.0 / (UINT64_C(1)<<63))) > -CONV_FUNC(AV_SAMPLE_FMT_U8 , uint8_t, AV_SAMPLE_FMT_FLT, av_clip_uint8( = lrintf(*(const float*)pi * (1<<7)) + 0x80)) > -CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, av_clip_int16( = lrintf(*(const float*)pi * (1<<15)))) > -CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, av_clipl_int32(= llrintf(*(const float*)pi * (1U<<31)))) > -CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_FLT, llrintf(*(const= float*)pi * (UINT64_C(1)<<63))) > -CONV_FUNC(AV_SAMPLE_FMT_FLT, float , AV_SAMPLE_FMT_FLT, *(const float*)= pi) > -CONV_FUNC(AV_SAMPLE_FMT_DBL, double , AV_SAMPLE_FMT_FLT, *(const float*)= pi) > -CONV_FUNC(AV_SAMPLE_FMT_U8 , uint8_t, AV_SAMPLE_FMT_DBL, av_clip_uint8( = lrint(*(const double*)pi * (1<<7)) + 0x80)) > -CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, av_clip_int16( = lrint(*(const double*)pi * (1<<15)))) > -CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, av_clipl_int32(= llrint(*(const double*)pi * (1U<<31)))) > -CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_DBL, llrint(*(const = double*)pi * (UINT64_C(1)<<63))) > -CONV_FUNC(AV_SAMPLE_FMT_FLT, float , AV_SAMPLE_FMT_DBL, *(const double*= )pi) > -CONV_FUNC(AV_SAMPLE_FMT_DBL, double , AV_SAMPLE_FMT_DBL, *(const double*= )pi) > - > -#define FMT_PAIR_FUNC(out, in) [(out) + AV_SAMPLE_FMT_NB*(in)] =3D CONV_= FUNC_NAME(out, in) > - > -static conv_func_type * const fmt_pair_to_conv_functions[AV_SAMPLE_FMT_N= B*AV_SAMPLE_FMT_NB] =3D { > +CONV_FUNC(AV_SAMPLE_FMT_U8 , uint8_t, AV_SAMPLE_FMT_U8 , uint8_t, x) > +CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_U8 , uint8_t, (x - 0= x80U)<<8) > +CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_U8 , uint8_t, (x - 0= x80U)<<24) > +CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_U8 , uint8_t, (uint6= 4_t)(x - 0x80U)<<56) > +CONV_FUNC(AV_SAMPLE_FMT_FLT, float , AV_SAMPLE_FMT_U8 , uint8_t, (x - 0= x80)*(1.0f/ (1<<7))) > +CONV_FUNC(AV_SAMPLE_FMT_DBL, double , AV_SAMPLE_FMT_U8 , uint8_t, (x - 0= x80)*(1.0 / (1<<7))) > +CONV_FUNC(AV_SAMPLE_FMT_U8 , uint8_t, AV_SAMPLE_FMT_S16, int16_t, (x>>8)= + 0x80) > +CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_S16, int16_t, x) > +CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_S16, int16_t, x * (1= << 16)) > +CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S16, int16_t, (uint6= 4_t)(x)<<48) > +CONV_FUNC(AV_SAMPLE_FMT_FLT, float , AV_SAMPLE_FMT_S16, int16_t, x*(1.0= f/ (1<<15))) > +CONV_FUNC(AV_SAMPLE_FMT_DBL, double , AV_SAMPLE_FMT_S16, int16_t, x*(1.0= / (1<<15))) > +CONV_FUNC(AV_SAMPLE_FMT_U8 , uint8_t, AV_SAMPLE_FMT_S32, int32_t, (x>>24= ) + 0x80) > +CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_S32, int32_t, x>>16) > +CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_S32, int32_t, x) > +CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S32, int32_t, (uint6= 4_t)(x)<<32) > +CONV_FUNC(AV_SAMPLE_FMT_FLT, float , AV_SAMPLE_FMT_S32, int32_t, x*(1.= 0f/ (1U<<31))) > +CONV_FUNC(AV_SAMPLE_FMT_DBL, double , AV_SAMPLE_FMT_S32, int32_t, x*(1.= 0 / (1U<<31))) > +CONV_FUNC(AV_SAMPLE_FMT_U8 , uint8_t, AV_SAMPLE_FMT_S64, int64_t, (x>>56= ) + 0x80) > +CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_S64, int64_t, x>>48) > +CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_S64, int64_t, x>>32) > +CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S64, int64_t, x) > +CONV_FUNC(AV_SAMPLE_FMT_FLT, float , AV_SAMPLE_FMT_S64, int64_t, x*(1.0= f/ (UINT64_C(1)<<63))) > +CONV_FUNC(AV_SAMPLE_FMT_DBL, double , AV_SAMPLE_FMT_S64, int64_t, x*(1.0= / (UINT64_C(1)<<63))) > +CONV_FUNC(AV_SAMPLE_FMT_U8 , uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_= uint8( lrintf(x * (1<<7)) + 0x80)) > +CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_= int16( lrintf(x * (1<<15)))) > +CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl= _int32(llrintf(x * (1U<<31)))) > +CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_FLT, float, llrintf(= x * (UINT64_C(1)<<63))) > +CONV_FUNC(AV_SAMPLE_FMT_FLT, float , AV_SAMPLE_FMT_FLT, float, x) > +CONV_FUNC(AV_SAMPLE_FMT_DBL, double , AV_SAMPLE_FMT_FLT, float, x) > +CONV_FUNC(AV_SAMPLE_FMT_U8 , uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip= _uint8( lrint(x * (1<<7)) + 0x80)) > +CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip= _int16( lrint(x * (1<<15)))) > +CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clip= l_int32(llrint(x * (1U<<31)))) > +CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_DBL, double, llrint(= x * (UINT64_C(1)<<63))) > +CONV_FUNC(AV_SAMPLE_FMT_FLT, float , AV_SAMPLE_FMT_DBL, double, x) > +CONV_FUNC(AV_SAMPLE_FMT_DBL, double , AV_SAMPLE_FMT_DBL, double, x) i think the new cases are longer const, is that intended ? (it would cast const to non const) except that patch LGTM =20 thx [...] --=20 Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB The real ebay dictionary, page 2 "100% positive feedback" - "All either got their money back or didnt compla= in" "Best seller ever, very honest" - "Seller refunded buyer after failed scam" --KJKxYQkVikLexIKR Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABEIAB0WIQSf8hKLFH72cwut8TNhHseHBAsPqwUCZF7NiwAKCRBhHseHBAsP q22PAJ9VW+KACEEtJKxDxEhmechl2M/S3wCePiHQk39ZYazX3rf5lvbgmY3aQIM= =8lCJ -----END PGP SIGNATURE----- --KJKxYQkVikLexIKR-- --===============1252853191957044635== 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". --===============1252853191957044635==--