x264 benchmark compilation & installation guide for MacOS X on PowerPC
To compile and install the x264 benchmark on MacOS X for PowerPC processors, a set of basic software needs to be present on the system. That includes:
- Apple XCode (incl. GCC/autoconf/make)
- tar, gzip and bzip2
- sh or bash shell
- Slightly older libav/x264 versions (Apple G4 only)
- gas-preprocessor (Apple G4 only)
The most important software is XCode, which can be obtained from Apple for free. XCode is what gives us an entire GNU build toolchain including a C/C++ compiler, GNU autoconf and GNU make.
For simplicities sake and to prevent certain bugs from appearing, all following steps should be executed as root / superuser!
The benchmark software itself
Now we need to compile libav and x264, where we need to pay attention to some potential problems caused by the old XCode build toolchain for MacOS X on PowerPC. First, let's download libav and x264, in the case of the G4 please take note that you will need those specific software versions plus the GAS preprocessor. The GAS preprocessor is required to modify parts of the libav/x264 inline assembler code, so that the Apple XCode assembler can correctly understand and assemble those parts. For that it is sufficient to unpack the *.pl script from the GAS preprocessor archive to /usr/bin/:
Again, for simplicities sake we assume, that those files are now in /home/user/x264src/. So let's go to that directory on the terminal, and start with libav. Just unpack the archive lke that: tar -xzvf <filename.tgz>, after that you will get some libav folder. Change to that folder to properly configure and build it. To prepare the build you need to set some environment variables for the compiler, those are specific to the machine you're sitting on, so better pay close attention to this! The export commands here need to be adapted to your host processor, depending on whether you have a G3, G4, G4 745x series or G5. For G4 you need to make sure that it actually supports the Altivec SIMD extension, otherwise you'll need to remove the -maltivec flag:
- G3 flags #1: export CFLAGS="-mcpu=G3 -mtune=G3 -pipe"
- G3 flags #2: export CXXFLAGS="-mcpu=G3 -mtune=G3 -pipe"
- G4 flags #1: export CFLAGS="-mcpu=G4 -mtune=G4 -maltivec -pipe"
- G4 flags #2: export CXXFLAGS="-mcpu=G4 -mtune=G4 -maltivec -pipe"
- G4 Flags (PPC 7455/7457) #1: export CFLAGS="-mcpu=7450 -mtune=7450 -maltivec -pipe"
- G4 Flags (PPC 7455/7457) #2: export CXXFLAGS="-mcpu=7450 -mtune=7450 -maltivec -pipe"
- G5 flags #1: export CFLAGS="-mcpu=G5 -mtune=G5 -maltivec -pipe"
- G5 flags #2: export CXXFLAGS"-mcpu=G5 -mtune=G5 -maltivec -pipe"
It's important not to close the terminal window after setting those variables. If you do, you need to set them again before proceeding. To check whether they're actually set is quite easy though:
Now let's build that code here, --disable-asm is required on G5 only, because the PowerPC G5 Altivec assembler code path is broken in libav. This is not really a performance problem though, as only the decoder will be affected. For G4 we will need the gas-preprocessor here, which needs to be copied to a path where the build system can find it, e.g.: /usr/bin/, which should already be done after the second to last step:
- ./configure --enable-gpl --enable-nonfree --disable-asm
- make install
If you get a warning about a missing GNU assembler after the ./configure step, you need to ensure that the GAS preprocessor has been installed correctly! Even if you happen to not have a G4, if you get this, you need to install the GAS preprocessor. After doing the installation, you will need to re-run ./configure, the warning should be gone after the GAS preprocessor becomes available. Now libav is installed, we can proceed to compile and link x264 itself, so unpack the archive like tar -xjvf last_x264.tar.bz2 and go to the newly created x264 snapshot subfolder. Now let's proceed as usual. Well, almost as usual, because this is the part where you will most likely need to do some manual tweaks:
- ./configure (After this, check whether the output claims "lavf yes", only then will x264 be properly linked against libav!)
Now some versions of XCode and most definitely those older ones for PowerPC are shipped with a version of GNU autoconf that will make some mistakes when generating your makefile. This bug affects G5 and G4 processors of 7450 series for sure and potentially also G3 (untested). To fix this, you need to edit the newly generated config.mak, and look for conflicting -mcpu and -mtune flags. Let's assume you have a PowerMac G5, then all of those flags should end in =G5, for 7450 series G4 it should be =7450. Sometimes, autoconf wrongly lets a =G4 slip through here, which then may cause the resulting code to become unstable. If x264 still crashes after this fix, please also remove all -O3 and expeciall -ffast-math flags and build again. If you're sure you got that all right for your processor, let's compile:
After that last step, you can check the functionality by running x264 --version. If that works, and if the binary shows that it's been linked against libswscale and libavformat, then everything went smoothly. Now we can download the benchmark script which will be used to actually run the test, and the input video file which you should place in the same folder as the script:
This file launchbenchmark.sh shall be copied to the folder dedicated to the benchmark itself. If you don't have one yet, just create one: mkdir -p /home/user/x264benchmark. This folder should contain said script and also the input video file elephantsdream_source.264.
Now you may run the benchmark, so while sitting in /home/user/x264benchmark, run the following commands:
- cd /home/user/x264benchmark/
- chmod +x ./launchbenchmark.sh
- time ./launchbenchmark.sh
The result can be obtained directly from the terminal window after both rendering passes have completed. The correct value to report is the one besides the string "Real"!
[Back to the x264 benchmark results list]
[Comment on this guide]