How to compile 32 bit programs on 64 bit Ubuntu OS

I installed ia32-libs, but got an error like this while compiling my program(already added -m32 option to CPPFLAG arguments in the Makefile)
jacky@ubuntu-msdk:/opt/workspace/msdk/src/msdk_client32$ make
/usr/include/features.h:324:26: fatal error: bits/predefs.h: No such file or directory
compilation terminated.
/usr/include/features.h:324:26: fatal error: bits/predefs.h: No such file or directory
compilation terminated.
g++ -m32 -I./../base_shm -g -O2 -Wall -c main_cli.cpp -o main_cli.o
In file included from /usr/include/stdio.h:28:0,
from ./../base_shm/config.h:4,
from main_cli.cpp:1:
/usr/include/features.h:324:26: fatal error: bits/predefs.h: No such file or directory
compilation terminated.
make: *** [main_cli.o] Error 1

Solution for this error:
sudo apt-get install gcc-multilib

Try again. But still return with errors(If you are compiling a C program, than it’ll be OK now. But I’m compiling a C++ program…):
jacky@ubuntu-msdk:/opt/workspace/msdk/src/msdk_client32$ make
g++ -m32 -I./../base_shm -g -O2 -Wall -c main_cli.cpp -o main_cli.o
main_cli.cpp: In function ‘void* WorkerThread(void*)’:
main_cli.cpp:230:41: warning: format ‘%X’ expects argument of type ‘unsigned int’, but argument 3 has type ‘void*’ [-Wformat]
main_cli.cpp:270:228: warning: format ‘%X’ expects argument of type ‘unsigned int’, but argument 2 has type ‘TThreadParam*’ [-Wformat]
main_cli.cpp: At global scope:
main_cli.cpp:51:13: warning: ‘void cbDecodeCallback(unsigned char*, unsigned int, short unsigned int, short unsigned int, unsigned int, long long unsigned int, void*)’ defined but not used [-Wunused-function]
g++ -m32 -I./../base_shm -g -O2 -Wall -c ../base_shm/easyshm.cpp -o ../base_shm/easyshm.o
../base_shm/easyshm.cpp: In member function ‘int easyshm::rs_shm_get(TShmInfo*)’:
../base_shm/easyshm.cpp:24:8: warning: unused variable ‘mem’ [-Wunused-variable]
../base_shm/easyshm.cpp: In member function ‘int easyshm::rs_shm_post(TShmInfo*, void*, size_t, int, EShmProtoType)’:
../base_shm/easyshm.cpp:262:52: warning: pointer of type ‘void *’ used in arithmetic [-Wpointer-arith]
g++ -m32 -I./../base_shm -g -O2 -Wall  .//main_cli.o ./../base_shm/easyshm.o -lpthread -o msdk_client32
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.6/ when searching for -lstdc++
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.6/libstdc++.a when searching for -lstdc++
/usr/bin/ld: cannot find -lstdc++
collect2: ld returned 1 exit status
make: *** [msdk_client32] Error 1

For Fedora, make sure you have installed the following packages as well:

  • libstdc++.i386
  • libgcc.i386
  • glibc.i386
  • glibc-devel.i386

And for Ubuntu that’ll be:
sudo apt-get install g++-multilib

So, as a conclusion for compiling 32 bit programs on a 64 bit Linux OS, you need not only
sudo apt-get install ia32-libs
but also
sudo apt-get install build-essential module-assistant

  • C: sudo apt-get install gcc-multilib
  • C++: sudo apt-get install g++-multilib


Performance tests of Intel Media SDK(4.0.026-HSW): Efficiency comparision between different Profiles

720P H.264 video decoding performance

Yesterday I got two test H.264 ES stream files from one of my colleague.

One was encoded by Main Profile, the other was encoded by Baseline Profile.

Weired thing is decoding the Main Profiled file seems much more fast than the Baseline Profiled file.

To release his concerns, today I did some more tests.

First, I double checked with these files together with one another High Profile file.

Here is the test result:

Profile Instance FPS CPU GPU
HP 1 629.63575 <10% 50% ~ 60%
HP 4 854.59665 40% ~ 50% 80%
Main 1 1064.62068 20% ~ 30% 67%
Main 4 1257.23482 40% ~ 50% 90% ~ 93%
Baseline 1 740.99021 <10% 46% ~ 48%
Baseline 4 1241.61537 30% ~ 50% 80% ~ 83%

*CPU usage: max usage on a single core
*GPU usage: max usage of GPU’s bitstream space

According to test result, the Baseline & Main Profile video decoding efficiency seems really strange.

So I checked these test video streams:

Test video sequence bit stream file:

  • 720p HP: 720p-lakeside-forest.264 (Standard test sequence)
  • 720p Main: 720p-dec-main.264 . Recorded video from one of Kedacom product, A regular moving video, and clearly a rag.
  • 720p Baseline: 720p-vid2-baseline.264 .Recorded video from one of Kedacom product, a regular moving video.

Then, I decided to transcode the Baseline profile video(720p-vid2-baseline.264) to a Main Profile video stream, and run one more test for Main Profile H.264 video decoding which will be using a same YUV video sequence with the previous Baseline Profile video decoding test.

Since the H.264 profile setting’s in MSDK is not open for set(but can be set by an indirect way), I ported a x264 to the current test framework(added a new encoder library base on x264).

Finally, I got two more files:

720p-vid2-baseline-still-baseline.264, which major encode setting was “baseline” + “veryfast”, “zerolatency”

Command: ./kdvcodec_msdkenc h264 -i 720p-baseline.yuv -o s.264 -w 1280 -h 720 -b 2000 -f 30 -hw -vaapi -u speed -loop 1 -run 1 -test 0 -cache 500

720p-vid2-baseline-to-main.264, which major encode setting was “ main” + “veryfast”, “zerolatency” profile Main, level 5.2

Command: ./kdvcodec_msdkenc h264 -i 720p-baseline.yuv -o s.264 -w 1280 -h 720 -b 2000 -f 30 -hw -vaapi -u speed -loop 1 -run 1 -test 2 -cache 500

Now run one more test:

Profile Instance FPS CPU GPU
Baseline 1 721.26709 20% ~ 30% 67%
Baseline 4 1218.01066 40% ~ 50% 90% ~ 93%
Main 1 620.54006 <10% 46% ~ 48%
Main 4 1136.95245 30% ~ 50% 80% ~ 83%


  1. Decoding a ragged video will cost less than decoding a normal video.
  2. Decoding a Baseline profile video can be more efficiency than decoding a Main Profile by given an even circumstance.

Step by step: build libva 1.2.0 on Ubuntu 12.04 LTS

After finished my first phase of GPU – Intel Media SDK research, now it’s time to get into libva, my goal is to get a set of performance test report for both MSDK and libva, so that we can finally choose one of them, or both of them for product use. If you don’t know libva, or not sure if you know it or not, please visit here for more informations: or (a copy in RG4.NET)


And the first step of research on libva will be download & build libva. Continue reading “Step by step: build libva 1.2.0 on Ubuntu 12.04 LTS”

Performance tests of Intel Media SDK (4.0.024-HSW) – Multithread decode

Performance test – multithread decode

Media SDK version

Intel Media SDK (4.0.024-HSW)

Test environments

CPU: Core ivy bridge i7-3770

OS: Ubuntu server 12.04 LTS, kernel version 3.2.0-23 x86_64 x86_64 x86_64 GNU/Linux

Test program

kdvcodec_msdkdec_mt (svn: 10)

Working mode

a. Decode with simulated block mode

b. Return with NV12 buffer.

c. Run N decoding threads. Open & caching H.264 Elementary Streams from one specified file.

d. Timing: start before thread created, end time after all thread terminated(Means it’s a ballpark estimation). Continue reading “Performance tests of Intel Media SDK (4.0.024-HSW) – Multithread decode”

Performance tests of Intel Media SDK (4.0.024-HSW) – Decode

It’s a test report of current/latest version of kdvcodec_msdkdec which based on the latest version of Intel Media SDK(4.0.024-HSW).

There is a known issue, NV12 to YV12 (or YUV420P) conversion, which is very low in efficiency.

Here are the details. Continue reading “Performance tests of Intel Media SDK (4.0.024-HSW) – Decode”

Finished my last degree course

Really happy that I’ve finished my last degree course, Software Project Management. Cost of this exam is I missed my first and also the biggest and most important event of my employer in the year.

There are still 5 more required/compulsory courses, that those will be:
a. Software Architecture & Design Pattern(《软件体系结构与设计模式》)
b. Software Quality Assurance and Testing(软件质量保证与测试)
c. Intellectual property rights(知识产权)
d. Discrete mathematics and combinatorial mathematics Intellectual Property(离散数学和组合数学)
e. Information retrieval(信息检索)

There are way to go, however, I finally can put more energy to my work.

Here is the exercises for SPM course: software project management.

and latest version of courses schedule: ustc.course.schedule

Step by step research into Intel Media SDK for Linux server

Intel release an alpha version of Media SDK for linux servers (Intel® Media SDK 2013 for Linux Servers) recently, here now I am researching on it. I will record my research details in this post, as usual,  can not guarantee everything I write here are exact true and right, only an experiment of it.


Intel® Media SDK 2013 for Linux Servers is an SDK for optimizing datacenter and embedded media applications for Linux operating systems to utilize Intel HD Graphics hardware acceleration capabilities. Now, quickly and easily develop optimized media applications for Linux operating systems such as encode, decode, and transcode for real-time streaming, teleconferencing, and video analytics.

You can visit: to get more informations from Intel’s official website of Media SDK


  • For Intel Xeon® E3-1285Lv2 and Intel Core™ Processor-based Platforms with Intel HD Graphics
  • Encode, decode, and transcode for server-based streaming
  • Supports Ubuntu* and SUSE* Linux Enterprise Operating Systems
  • Supports H.264, MPEG-2, VC-1 formats


Step by step to setup the develop environment, and get into works. My hardware environemts(CPU) is Core 3rd Generation Ivy, according to Intel’s introduction in it Release Notes, I can only choose ubuntu 12.04 server 64 with kernel 3.2.

1. OS Install
Related files:
1. ubuntu-12.04-server-amd64.iso
2. unetbootin-windows-581.exe

According to Intel’s Release Notes, target OS version match with MediaSDK is ubuntu 12.04 server 64 bit with kernel 3.2.
So we choose: ubuntu-12.04-server-amd64.iso(we can not download this version of ubuntu server on, if you dont have it, you can mail me or call me)

1. Get yourself a USB flash(4G or bigger), use unetbootin-windows-581.exe to write the iso to the USB flash.
2. Plug the USB to 8000e, and power up, press DEL to get into BIOS, choose your newly plugged in USB as first boot option.
3. Install Ubuntu server.
4. Make sure your 8000e can access to the internet (Mail your 8000e’s ethernet MAC ADDR together with your pre-assigned IP addr to 黄阳)
5. I strongly recommend you to not do it on 8000e’s iCF4000 card(which has only 8 GB rom), because I was sucked here 2 times being told “no space left” while compiling the kernel.
2. Media SDK install
Related files:
1. haswell.rar which including but not limits to files:
a. intel-Linux-media_ubuntu_16.1.0.8778_64bit.tar.gz
b. kmd_patched_sources.tar.bz2

Upload haswell.rar to 8000e, and extract it, you will find a file named as intel-linux-media_ubuntu_16.1.0.8778_64bit.tar.gz
1. Extract intel-linux-media_ubuntu_16.1.0.8778_64bit.tar.gz
2. Locate to the extracted files, find and execute ./

jacky@ubuntu-msdk:~/msdk$ ./
INFO... Install on Ubuntu ...
Error... This script must be run as root!
jacky@ubuntu-msdk:~/msdk$ sudo -i
[sudo] password for jacky:
root@ubuntu-msdk:~# ls
root@ubuntu-msdk:~# cd /home/jacky/msdk/
root@ubuntu-msdk:/home/jacky/msdk# ls
bak  intel-linux-media_ubuntu_16.1.0.8778_64bit.tar.gz  kmd  MSDK  usr
root@ubuntu-msdk:/home/jacky/msdk# ./
INFO... Install on Ubuntu ...
INFO... Installing New Driver...
INFO... The default media driver is renderless API, do you want to use X11 backend?
press 'y' to use X11 backend, otherwise by default(drm backend, renderless)y
INFO... X11 backend enabled!
INFO... MediaSDK installed successfully in /opt/intel/mediasdk!
INFO... Do you want to install KMD?
press 'y' to confirm, otherwise cancelled.y
INFO... Original i915.ko backuped in kmd_backup/i915.ko.2013-07-02_182315
INFO... Trying to install 3.2.42 kmd...
Error... Kernel module updated failed, due to mismatched kernel 3.2.0-23-generic with pre-build KMD. You have to rebuild kernel with patched files (kmd/source) manually.
INFO... Package installation Done.
root@ubuntu-msdk:/home/jacky/msdk# uname -a
Linux ubuntu-msdk 3.2.0-23-generic #36-Ubuntu SMP Tue Apr 10 20:39:51 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux

As you can see, I was told to rebuild the kernel, so we do it. However it’s a long way to go…

3. Install a bunch of stuffs with rebuild kernel needed:
If you encounter with network setting & routing problems, you can refer to … pid=24641&fromuid=3 for a guide.

sudo apt-get install git g++ make curl
sudo apt-get install ncurses-dev kernel-package

4. Download kernel

git clone git://
cd linux-stable
git checkout v3.2

5. Apply Intel Media SDK patch

jacky@ubuntu-msdk:~/kernel/linux-stable/include$ cd ../drivers/char/agp/
jacky@ubuntu-msdk:~/kernel/linux-stable/drivers/char/agp$ cp -r ~/msdk/kmd/source/xcode-ubuntu-kmd-rel/drivers/char/agp/* .
jacky@ubuntu-msdk:~/kernel/linux-stable/drivers/char/agp$ cd ../../gpu/
jacky@ubuntu-msdk:~/kernel/linux-stable/drivers/gpu$ cp -r ~/msdk/kmd/source/xcode-ubuntu-kmd-rel/drivers/gpu/* .

6. Recompile kernel

make menuconfig
make-kpkg --initrd --append-to-version -01 kernel_image kernel_headers -j8