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 8580B49DE1 for ; Mon, 10 Jun 2024 12:32:57 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id BCD2E68D740; Mon, 10 Jun 2024 15:32:54 +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 3D66668D5AB for ; Mon, 10 Jun 2024 15:32:48 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 6E5C6C0007 for ; Mon, 10 Jun 2024 12:32:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=niedermayer.cc; s=gm1; t=1718022767; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=FTd2QKUTzLt1V80jNTq1evUvJsLaiY5BuZH5vgVQlTM=; b=HPufTjl79YS/dqCZcahdoxiHuXNBOJOvXafu6NXDAAG0EGuHZuGCbT9Z2Ah7IXmMJ/E5HL 1s5nx1nk12oBqub18NmIo7N4af8kx5LxARg2fguFp7TBVoaZlyOrR/0QnHIS4hMpsi0E3P 3ZZ03nonMnhvLaU5ibXN9n0wU8OgdR/aeDx/nOypX7z/XJLf10/CaX7LfTUoy7bva4R9y1 6HMnSaHBytk1efKJNk0o24Wu0qfF1bXSGXfc7G5ZkLp9xF+kPoYN08je+u4ggyfPB9ccQI G294DI/vztUe90uEs9zyWd+iHy9DN98U2Wz+XM7mJtOscux9X5pKioiVNJHL/A== Date: Mon, 10 Jun 2024 14:32:46 +0200 From: Michael Niedermayer To: FFmpeg development discussions and patches Message-ID: <20240610123246.GE2821752@pb2> References: <20240609162347.2541907-1-remi@remlab.net> <20240609162347.2541907-2-remi@remlab.net> <20240610114131.GB2821752@pb2> MIME-Version: 1.0 In-Reply-To: X-GND-Sasl: michael@niedermayer.cc Subject: Re: [FFmpeg-devel] [PATCH 2/4] lavc/mpegvideo: use H263DSP dequant function 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="===============7137653291451286094==" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --===============7137653291451286094== Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="HTxS7It8wpDcI4PN" Content-Disposition: inline --HTxS7It8wpDcI4PN Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Jun 10, 2024 at 03:14:14PM +0300, R=E9mi Denis-Courmont wrote: >=20 >=20 > Le 10 juin 2024 14:41:31 GMT+03:00, Michael Niedermayer a =E9crit=A0: > >On Sun, Jun 09, 2024 at 07:23:45PM +0300, R=E9mi Denis-Courmont wrote: > >> --- > >> libavcodec/mpegvideo.c | 44 ++++++++++-------------------------------- > >> 1 file changed, 10 insertions(+), 34 deletions(-) > >>=20 > >> diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c > >> index 7af823b8bd..9be0fecc8d 100644 > >> --- a/libavcodec/mpegvideo.c > >> +++ b/libavcodec/mpegvideo.c > >> @@ -201,13 +201,11 @@ static void dct_unquantize_mpeg2_inter_c(MpegEnc= Context *s, > >> static void dct_unquantize_h263_intra_c(MpegEncContext *s, > >> int16_t *block, int n, int qscale) > >> { > >> - int i, level, qmul, qadd; > >> - int nCoeffs; > >> + int qmul =3D qscale << 1; > >> + int qadd, nCoeffs; > >> =20 > >> av_assert2(s->block_last_index[n]>=3D0 || s->h263_aic); > >> =20 > >> - qmul =3D qscale << 1; > >> - > >> if (!s->h263_aic) { > >> block[0] *=3D n < 4 ? s->y_dc_scale : s->c_dc_scale; > >> qadd =3D (qscale - 1) | 1; > >> @@ -215,47 +213,24 @@ static void dct_unquantize_h263_intra_c(MpegEncC= ontext *s, > >> qadd =3D 0; > >> } > >> if(s->ac_pred) > >> - nCoeffs=3D63; > >> + nCoeffs =3D 64; > >> else > >> - nCoeffs=3D s->intra_scantable.raster_end[ s->block_last_index= [n] ]; > >> + nCoeffs =3D s->intra_scantable.raster_end[s->block_last_index= [n]] + 1; > >> =20 > >> - for(i=3D1; i<=3DnCoeffs; i++) { > >> - level =3D block[i]; > >> - if (level) { > >> - if (level < 0) { > >> - level =3D level * qmul - qadd; > >> - } else { > >> - level =3D level * qmul + qadd; > >> - } > >> - block[i] =3D level; > >> - } > >> - } > >> + s->h263dsp.h263_dct_unquantize_intra(block, nCoeffs, qmul, qadd); > >> } > >> =20 > >> static void dct_unquantize_h263_inter_c(MpegEncContext *s, > >> int16_t *block, int n, int qscale) > >> { > >> - int i, level, qmul, qadd; > >> + int qmul =3D qscale << 1; > >> + int qadd =3D (qscale - 1) | 1; > >> int nCoeffs; > >> =20 > >> av_assert2(s->block_last_index[n]>=3D0); > >> =20 > >> - qadd =3D (qscale - 1) | 1; > >> - qmul =3D qscale << 1; > >> - > >> - nCoeffs=3D s->inter_scantable.raster_end[ s->block_last_index[n] = ]; > >> - > >> - for(i=3D0; i<=3DnCoeffs; i++) { > >> - level =3D block[i]; > >> - if (level) { > >> - if (level < 0) { > >> - level =3D level * qmul - qadd; > >> - } else { > >> - level =3D level * qmul + qadd; > >> - } > >> - block[i] =3D level; > >> - } > >> - } > >> + nCoeffs =3D s->inter_scantable.raster_end[s->block_last_index[n]]= + 1; > >> + s->h263dsp.h263_dct_unquantize_inter(block, nCoeffs, qmul, qadd); > > > >It would be better if the "+ 1" would not be needed and teh functions > >would keep using "<=3D" >=20 > Why? because its 1 instruction less and the compieler cannot optimize it out. > AFAICT, that just makes the assembler more confusing by requiring an unus= ual boundary check. >=20 > And then for SVE and RVV, adding one is unavoidable possible, as we need = the element count to predicate the vector ops. So we'd just end up having t= o add one in the assembler instead of C. [...] --=20 Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB If a bugfix only changes things apparently unrelated to the bug with no further explanation, that is a good sign that the bugfix is wrong. --HTxS7It8wpDcI4PN Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABEKAB0WIQSf8hKLFH72cwut8TNhHseHBAsPqwUCZmbybgAKCRBhHseHBAsP q7CeAKCVEL8N+yMYdDfDn2G8/QEuPvegqACfUvgSnoSkoDUFNDMf5XJJd4K9fpI= =v3Pf -----END PGP SIGNATURE----- --HTxS7It8wpDcI4PN-- --===============7137653291451286094== 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". --===============7137653291451286094==--