Voodooalert+x264 Logo
US+UK Flagge DE+AT Flagge
Change language:
 

x264 benchmark guide for compilation & installation on OpenBSD 5.4 - 5.5

OpenBSD Logo

System prerequisites

To compile and install the x264 benchmark on OpenBSD, we need some software first. To install it, we will be using the OpenBSD package manager, that we have to configure first though. At this moment, the benchmark requires OpenBSD 5.4 - 5.5, and this guide may be invalid for any newer release as there may be some fundamental changes coming soon. So, this guide shall not be expected to work for future OpenBSD versions.

We'll do the following as the superuser root, configuring and running pkg_add through the installation of our first package:


Right after that we shall run the following command both as the user who is supposed to run the benchmark later as well as as root:

After this, all users need to be logged out, for instance by restarting the graphical user interface so the change can be applied. We are now using the bourne again shell instead of the default korn shell, which will make some further steps easier and is also required by many of the build scripts we're going to run. We still have some more packages to install though, this time we'll use the environment variable PKG_PATH to tell the package manager where to get its packages from:

In the case of autoconf, pkg_add will list a bunch of available versions, prompting the user to pick one. Just select the latest version.

Since OpenBSD is highly restrictive when it comes to imposing limits onto its users, we will need to adjust that a little bit to be able to actually run the benchmark afterwards. In particular, we'll need to raise the 512MB per user memory allocation limit. Since the x264 benchmark may use around 600MB - 1100MB depending on the machine architecture and thread count, we have to raise the bar, or x264 will crash, telling us that malloc() has failed.

To get it done, please edit the file /etc/login.conf as root with a text editor of your choice like maybe nano, that can also be installed via pkg_add. Look for the following spot:

staff:\
        :datasize-cur=512M;\

This part we will alter, raising the default memory allocation limit for users of the login class staff from 512MB to 2GB:

staff:\
        :datasize-cur=2048M;\

On top of that we will need to actually add the user who is supposed to run the benchmark to that login class. For simplicities sake we shall assume, that the user is just called user. Run the following command as root:

chpass will launch the systems default text editor - likely vi - and let us edit the user. The following line is the one we're looking for: ung:

Class:

We shall add a little something:

Class: staff

Save and close the file after the alteration. Now again, the user needs to be completely logged out to apply the change, again for insance by restarting the graphical user interface. With this step, the initial system configuration is complete and we can continue with compilation. Unfortunately, x264 needs a GNU assembler equal to or newer than version 2.17 to build SSSE3 inline assembly code on x86 processor machines. Since we cannot just give up all assembly for performance reasons, we'll need to help ourselves to a newer assembler. That assembler, also called gas or just as is a component of the GNU binutils which we shall download in source code form:

As of the time of this writing, the latest version was 2.24.51. If newer versions cause unexpected problems, you may want to use 2.24.51 instead. We shall from here on out assume, that this is the version being used. Please unpack the binutils like this; tar -xzvf ./binutils-2.24.tar.gz, and switch into the binutils-2.24/ directory afterwards. For building/linking binutils correctly, we'll need to set the following two environment variables, because some dependecies would otherwise not be detected:

After setting those variables, please do not close the terminal, or you'll have to re-set them again. Now let's configure the binutils and attempt compilation, sitting in the folder binutils-2.24/:

This will compile the better part of the binutils and then crash at GNU ld. At this point however, enough of the binutils will be built, including the GNU assembler. Before we will use the assembler though, we will recompile it with a clean target platform definition. So we'll change to the directory binutils-2.24/gas/ and run the following commands:

After that we will disable the older gas 2.15 temporarily by renaming it:

Now the new assembler should respond when running as -version. If the command cannot be found, you may need to rename the file /usr/local/bin/amd64-unknown-openbsd5.4-as or similar to /usr/local/bin/as. With that, the initial environment for compiling the benchmarks components is complete.

Now we'll get to the actual part we're here for:

The benchmarking software itself

To be able to use x264, we will need the decoding filters of libavcodec (in short libav) and the x264 encoder itself, which will be linked against libav in the process of building. On top of that you'll naturally need the benchmarks input video file, that is linked to on the bottom of the [benchmark results list]. As a replacement for libav you might also use ffmpeg if this is preferred. We will stay with libav here though.

Before we start, we'll need to set a few more variables to ensure we'll be using the newer GCC 4.8.1, the newer C/C++ compiler that we installed in the beginning. Again, please keep in mind that these are lost when closing the terminal where you set them, so if you open a new terminal, you need to re-set them:

For simplicities sake we shall assume that the files are now sitting in /home/user/x264src/. Change to that directory on the console and start off with libav. Unpack it running the command tar -xzvf <filename.tgz>, after which there will be a new libav folder. Change into that folder and start configuring and building libav:

libav is now installed, and we can continue with x264 itself.

First unpack it - again in the directory /home/user/x264src by running tar -xjvf last_x264.tar.bz2 and change to the newly created x264 subfolder.

For x264 we will need to ensure that all scripts of its build system can be launched. Some of the scripts may have a shebang line at the very beginning that is unsuitable for OpenBSD. Depending on the version of x264, the script configure will surely be affected, as might be version.sh and for older versions even more scripts. Just look at the first line. If it looks like the following one, we'll need to adjust it:

#!/bin/bash

Replace that with:

#!/usr/local/bin/bash

Now we can start:

x264 is now installed and ready for operation! To verify the functionality of the software, just run x264 --version. If that works and the binary shows being linked against libswscale and libavformat, everything worked fine. Now you can download the following benchmarking script:

Copy that script launchbenchmark.sh to a subfolder dedicated to the benchmark. Create one, if there is none already, like: mkdir -p /home/user/x264benchmark. In this folder we will also need to put the benchmarks input video file elephantsdream_source.264.

Now you can run the benchmark while sitting in /home/user/x264benchmark and after ensuring that the script is being flagged as executable (chmod +x ./launchbenchmark.sh) by running the following command:

That could look somewhat like this (click to enlarge). The result can be read from the terminal after the benchmark is done, the important value here is the one that will be shown besides the string "Real":

OpenBSD Screenshot

Depending on the host machine that might take some hours, in extreme cases even days, weeks or months. If you have problems with this guide or if there are any additional questions about the x264 benchmark on OpenBSD, please refer to the [according forum thread] and ask there. The forum is german, but if you ask in english, you will still get a reply, at least by me. :)

[Back to the x264 benchmark results list]

[Comment on this guide]