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 7D1CB43CF8 for ; Sat, 8 Oct 2022 18:26:54 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 73D6368BC4B; Sat, 8 Oct 2022 21:26:51 +0300 (EEST) Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5186368BB72 for ; Sat, 8 Oct 2022 21:26:44 +0300 (EEST) Received: (Authenticated sender: michael@niedermayer.cc) by mail.gandi.net (Postfix) with ESMTPSA id 1993A1C0004 for ; Sat, 8 Oct 2022 18:26:42 +0000 (UTC) Date: Sat, 8 Oct 2022 20:26:42 +0200 From: Michael Niedermayer To: FFmpeg development discussions and patches Message-ID: <20221008182642.GO6583@pb2> References: MIME-Version: 1.0 In-Reply-To: Subject: Re: [FFmpeg-devel] [PATCH 1/9] avcodec/x86/simple_idct: Empty MMX state in ff_simple_idct_mmx 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="===============0481178563638004410==" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --===============0481178563638004410== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="Bf1m62tZozKFsi1s" Content-Disposition: inline --Bf1m62tZozKFsi1s Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Oct 06, 2022 at 02:54:30AM +0200, Andreas Rheinhardt wrote: > We currently mostly do not empty the MMX state in our MMX > DSP functions; instead we only do so before code that might > be using x87 code. This is a violation of the System V i386 ABI > (and maybe of other ABIs, too): > "The CPU shall be in x87 mode upon entry to a function. Therefore, > every function that uses the MMX registers is required to issue an > emms or femms instruction after using MMX registers, before returning > or calling another function." (See 2.2.1 in [1]) > This patch does not intend to change all these functions to abide > by the ABI; it only does so for ff_simple_idct_mmx(), as this > function can by called by external users, because it is exported > via AVDCT (i.e. via avcodec_dct_init()). Without this, the following > fragment will assert (in i386): > av_force_cpu_flags(AV_CPU_FLAG_MMX | AV_CPU_FLAG_MMXEXT); > int16_t *blk =3D av_malloc(64 * sizeof(*blk)); > AVDCT *avdct =3D avcodec_dct_alloc(); > avcodec_dct_init(avdct); > avdct->idct(blk); > av_assert0_fpu(); >=20 > [1]: https://raw.githubusercontent.com/wiki/hjl-tools/x86-psABI/intel386-= psABI-1.1.pdf >=20 > Signed-off-by: Andreas Rheinhardt > --- > libavcodec/x86/simple_idct.asm | 1 + > 1 file changed, 1 insertion(+) >=20 > diff --git a/libavcodec/x86/simple_idct.asm b/libavcodec/x86/simple_idct.= asm > index dcf0da6df1..e3a29efc33 100644 > --- a/libavcodec/x86/simple_idct.asm > +++ b/libavcodec/x86/simple_idct.asm > @@ -845,6 +845,7 @@ INIT_MMX mmx > =20 > cglobal simple_idct, 1, 2, 8, 128, block, t0 > IDCT > + emms > RET as comments where requested What speed impact does this have on old CPUs ? can this be made compile time optional so someone building for an old machiene can avoid the speedhit while ignoring the ABI (which worked fine) (this case would then require a 2nd function with the emms for AVDCT) thx [...] --=20 Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB I am the wisest man alive, for I know one thing, and that is that I know nothing. -- Socrates --Bf1m62tZozKFsi1s Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABEIAB0WIQSf8hKLFH72cwut8TNhHseHBAsPqwUCY0HA3QAKCRBhHseHBAsP q0uGAKCBezE5A+wf0/ZE0cTtACVPX0Cn8QCcDythzPqwwSTV6pM699/TykrRnxE= =9WAJ -----END PGP SIGNATURE----- --Bf1m62tZozKFsi1s-- --===============0481178563638004410== 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". --===============0481178563638004410==--