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

x264 benchmark compilation & installation guide for DragonFly BSD >=3.0

DragonFly BSD Logo

System prerequisites

There is one thing that should be mentioned beforehand and that is that the guide presented here has NO validity for OpenBSD <=5.1 or FreeBSD <=9.1 or any older version. As of now, restrictions of the GNU portable assembler on those systems have prevented me from reaching a satisfactory result on OpenBSD and FreeBSD. So for now, of all BSD style systems, the compilation and installation of libav and x264 only works on NetBSD >=6.0 and DragonFly BSD >=3.0.

To compile and install the x264 benchmark on DragonFly BSD, some basic software needs to be present first. To install what is required, we will use the BSD package manager. Unlike with other BSD distributions, the package manager for installation of packages from remote sources is not called pkg_add, but pkg_radd. Also, you do not need to specify the -r option for remote package fetching as is sometimes necessary with pkg_add. So let's install the required packages as the super user root:


Sometimes you will need to restart the terminal window for the system to recognize the newly installed software. If you're on a pure text shell, it should be ok to just log out and back in (CTRL+D). If you're on a graphical user interface, just close the terminal window and open a new one. Now we can go for the real deal:

The benchmarking software itself

To be able to use x264, we need the decoder filters from libavcodec (in short libav) and of course the x264 encoder itself, which will be linked against libav during the course of configuration and compilation. Additionally, we need the benchmark input video, download mirrors for that are available at the bottom of the x264 [benchmark results list]. If you like, you may also use ffmpeg/ffms as a replacement for libav.

For simplicities sake, we shall assume, that the files are now placed in /home/user/x264src/. So on the terminal we switch to that directory and start with libav. Please unpack the archive like tar -xzvf <filename.tgz>, after which you will see a new libav subfolder. Change to that new folder, so that you can begin to do the necessary modifications and configurations:

A Perl script, which is a part of the libav source code and which is responsible for generating the documentation for the code has a wrong shebang line in its code. The shebang line is the very first line of the script, that we will need to change. The script is in a subfolder of the libav folder called doc and itself is called texi2html.pl. We shall edit that script using vi or maybe xedit if you have a graphical user interface and change that first line, search for:

#! /usr/bin/perl -w

Just replace that with the path where the actual Perl binary is sitting:

#! /usr/pkg/bin/perl -w

After this quick modification we can configure, build and install libav:

Now libav is installed and we may continue with x264 itself.

First, let's unpack x264, again in folder /home/user/x264src like: tar -xjvf <x264 archive> and change to the newly created x264 subfolder right afterwards.

Now while x264 has been somewhat prepared to build on FreeBSD/OpenBSD/NetBSD, it does not know DragonFly BSD. So for the configure script to recognize the system, we need to modify it a little bit. Please open the script in your favorite text editor, and look for the following text block:

openbsd*)
  SYS="OPENBSD"
  LDFLAGS="$LDFLAGS -lm"
  ;;

After that, add a new block, exactly like this:

*dragonfly*)
  SYS="DRAGONFLYBSD"
  LDFLAGS="$LDFLAGS -lm"
  ;;

Before continuing, please launch the bash shell first, as the csh may cause problems when actually configuring the source code, also create a link for the bash where configure will be able to find it:

For the course of x264 configuration, compilation and installation, please stay on the bash.

Now, let's set our compiler CFLAGS and CXXFLAGS as well as the linker LDFLAGS:

Now we can launch the configure script and also build and install the resulting software:

You may want to check whether the configure scripts output shows the line "lavf yes" after configuration. x264 will be able to link against libav only if this is the case. If it says "lavf no", you will need to analyze the output in the file config.log to determine what might have gone wrong. If this part is ok, you can go on with the gmake commands as shown above to compile and install x264.
Now x264 is also installed and ready for operation. The basic functionality of the software can be checked by running x264 --version. If that works, and the binary shows it's been linked against libswscale and libavformat, everything went smoothly. If x264 cannot be found, you will usually need to restart your terminal or log out and back in. Now you can download the following benchmarking script and input video file:

This file launchbenchmark.sh needs to be copied into the subfolder dedicated to the benchmark, if it does not yet exist, please just created it: mkdir -p /home/user/x264benchmark. You should also put the input video elephantsdream_source.264 into that folder.

Now unfortunately x264 will use a way of CPU core detection that might very well work fine on Linux and some flavors of Unix, but will fail on BSD and with it on DragonFly BSD. That results in x264 having strictly no idea how many logical processors there are in the system. When that happens, x264 will only launch a single worker thread, and hence will only load one logical processor core, even if we have multithreading support on board. Luckily, there is an easy fix for this, we just need to add a little something to our launchbenchmark.sh, telling x264 how many worker threads it's supposed to spawn. For that, we should follow the old x264 rule:

So, for a CPU with 4 cores, that would make 6 threads. For a CPU with 4 cores and hyper threading (=8 logical CPUs) that would make 12 threads. If by any chance you have a triple core that simple old formula won't work of course, but in that case just round up to 5 threads. The maximum number of workers is by the way 32, at least at the time of writing, so you can't spawn more worker threads than that. So to make that little change to the benchmark, open up launchbenchmark.sh with vi or maybe xedit, and add the option after both occurences of --cqm flat:

Here, n is the amount of worker threads, so e.g. --threads 12 for a system with 8 logical CPUs. Now with that, nothing should stand in the way of using multiple CPUs, cores and hyper threads anymore!

So now you can basically just launch the benchmark, so just enter the following line after ensuring that the script is executable (chmod +x ./launchbenchmark.sh) and while of course sitting in /home/user/x264benchmark. Please make sure you're really running /usr/bin/time and not just time, as the shells builtin will not produce proper output:

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":

DragonFly BSD 3.0.2 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 DragonFly BSD/BSD, 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]