[Theora-dev] patch to build theora-mmx on AMD64

Ralph Giles giles at xiph.org
Tue May 2 22:58:02 PDT 2006

On Wed, May 03, 2006 at 12:48:45AM -0400, Dan Lenski wrote:

> Hi all, I've patched theora-mmx to build on x86_64.  The patch against
> SVN is attached.

Excellent, thanks for doing this! Some comments inline.

> Basically all I did was to copy lib/i386 to lib/x86_64 and tweak the
> assembler code a bit:
> * added to each file: typedef unsigned long int ogg_uint64_t

This is reasonable, since the file will only be compiled with gcc on 
x86_64. But really we should make libogg provide this type if people
are wanting it.

> * converted all asm inputs to 64-bit in: dsp_mmxext.c,  fdct_mmx.c,  
> recon_mmx.c
> * left all asm outputs at 32-bit
> * I didn't patch dsp_mmx.c, since all x86_64 processors have SSE, thus
> there's no need for the old mmx version


> A couple things that need improvement:
> * I don't know automake/autoconf that well, so I don't know how to
> make it automatically choose i386/x86_64 in the Makefile.  I did make
> it so that cpu.c will choose the appropriate cpuid routine based on
> #if defined(__x86_64__)

Right. Unfortunately there needs to be more of this before I can apply 
since it breaks the x86_32 build as is. I can make the configure script 
tell the makefile which directory to compile, but for the sake of those 
using other build systems, it would really be better if it was always 
safe to compile both sets on any arch and have the inappropriate code 
#ifdef'd out.

It may also make sense to add an arch to the asm functions to 
distinguish the two sets.

You might also look at what ruik did in the theora-exp branch. He kept 
unified source files and just used a few conditionals to make the same 
code work on both. Perhaps that's less helpful if you're intending to 
rewrite everything to use 64 bit integers, but see for examples


Anyway, thanks for getting the ball rolling here, this has been an 
oft-requested feature.


More information about the Theora-dev mailing list