This is a complete implementation of H.264 codec ported for TI C6000 DSP. By using linear assembly language, we can take full advantage of DSP architecture. We tried to optimize several core routines, including DCT, Intra-Predict, Inter-Predict, CABAC, etc.
Add an optional downsample module.
For autotools
:
Download a source distribution, then install:
For cmake
:
For meson
:
For xmake
:
One of the following:
- mingw-w64: for windows
- android-ndk: for android
- ccstudio: for TI DSP
- TI C6000 toolchain < 8.0.0: for TI DSP DM6467. Go to ccstudio's App center to install TI-CGT 7.4.24
For TI C6000 toolchain > 8.0.0, refer https://github.com/Freed-Wu/x264.
- check: for unit test
make check
ctest
meson test -Cbuild
- bin2c: use bin2c to convert a yuv to
a c array. Or use xmake's builtin
bin2c.
./configure --with-bin2c=/the/path/of/WxH.yuv
cmake -DBIN2C=ON -DINPUT_FILENAME=/the/path/of/WxH.yuv
meson setup build -Dbin2c=true -Dinput_filename=/the/path/of/WxH.yuv
xmake f --bin2c=y
For OSs:
mkdir build
cd build
# host build
../configure
# or cross compiling for windows
../configure --build=x86_64-pc-linux-gnu --host=x86_64-w64-mingw32
# or cross compiling for android with API 21
../configure --build=x86_64-pc-linux-gnu --host=aarch64-linux-android21
make -j$(nproc)
See --help
to know how to configure:
$ ./configure --help
...
--enable-debug enable debug. default=no
--enable-asm enable TI C6X asm. default=no
--enable-dry-run enable dry run, do not write any file. default=no
...
--with-x264-bit-depth[=8|10]
bit depth. default=8
--with-x264-chroma-format[=0..3]
chroma format: 400, 420, 422, 444. default=1
--with-x264-log-level[=0..3]
log level: error, warning, info, debug. debug will
decrease fps. default=2
--with-bin2c[=/the/path/of/WxH.yuv]
use bin2c to convert a yuv to yuv.h
--with-downsample[=1|2] downsample from 720p to 360p, 1, 2 means bilinear,
bicubic. default=1
--with-downsample-scale[=X]
downsample scale. default=2
--with-padding[=1..3] padding method, edge, reflect, symmetric. default=3
...
autotools
doesn't support TI-CGT.
# host build
cmake -Bbuild
# or cross compiling for windows
cmake -Bbuild -DCMAKE_TOOLCHAIN_FILE=cmake/mingw.cmake
# or cross compiling for windows on x86
cmake -Bbuild -DCMAKE_TOOLCHAIN_FILE=cmake/mingw.cmake -DCMAKE_SYSTEM_PROCESSOR=i686
# or cross compiling for android with highest API
cmake -Bbuild -DCMAKE_TOOLCHAIN_FILE=cmake/android-ndk.cmake
# or cross compiling for TI DSP. make sure *.cmd in project root
cmake -Bbuild -DCMAKE_TOOLCHAIN_FILE=cmake/ti.cmake
cmake --build build
See ccmake -Bbuild
to know how to configure.
meson setup build
# or cross compiling for TI DSP. make sure *.cmd in project root
meson setup --cross-file meson/ti-c6000.txt build
meson compile -Cbuild
See meson configure build
to know how to configure.
xmake
See xmake f --menu
to know how to configure.
scripts/ccstudio.sh
cd ~/workspace_v12/x264-dsp
# use autotools to generate config.h and yuv.h
autoreconf -vif
mkdir build
cd build
../configure --with-bin2c=/the/path/of/1280x720.yuv --with-downsample --with-downsample-scale=4
# or use cmake
cmake -Bbuild -DBIN2C=ON -DINPUT_FILENAME=/the/path/of/1280x720.yuv -DDOWNSAMPLE=1 -DSCALE=4
cmake --build build --target yuv.h
rm -r CMakeFiles
# or use xmake
xmake f --bin2c=yes --input\ filename=/the/path/of/1280x720.yuv
xmake
ccstudio -noSplash -data ~/workspace_v12 -application com.ti.ccstudio.apps.projectBuild -ccs.projects x264-dsp -ccs.configuration Release
You will get Release/x264-dsp.out
.
Note: TI-CGT cannot support too large /the/path/of/WxH.yuv
!
Otherwise, you will met the following error when ccs.projectBuild
.
terminate called after throwing an instance of 'std::bad_alloc'
what(): St9bad_alloc
INTERNAL ERROR: /opt/ccstudio/ccs/tools/compiler/c6000_7.4.24/bin/ilk6x aborted while
processing file /tmp/TIXXXXXXXXX
This is a serious problem. Please contact Customer
Support with this message and a copy of the input file
and help us to continue to make the tools more robust.
Try to reduce the size of YUV file:
head -c13824000 /720p/the/path/of/WxH.yuv > /the/path/of/WxH.yuv
You must create an arm project to activate DSP core by gel files.
ccstudio -noSplash -data ~/workspace_v12 -application com.ti.ccstudio.apps.projectCreate -ccs.device ARM9.TMS320DM6467 -ccs.name arm -ccs.template com.ti.common.project.core.emptyProjectWithMainTemplate
- select project
arm
- press Alt + CR to open properties
- select
Manage the project's target-configuration automatically
- change
Connection
according to your debug probe
- double click
TMS320DM6467.ccxml
- press
Target Configuration
- select
~/workspace_v12/x264-dsp/assets/gel/davincihd_arm.gel
for ARM926, ARM968_0, ARM968_1 - select
~/workspace_v12/x264-dsp/assets/gel/davincihd_dsp.gel
for C64XP - press Ctrl + S to save
- power on DSP
- press F11 to debug
- press
OK
- press
OK
to closeLaunching Debug Session
- change project
x264-dsp
onProject Explorer
- press F11 to debug
- press F8 to run
Refer Code Composer Studio User’s Guide to debug.
Download a test YUV from release. Note the file name must respect YUView filename rules to contain resolution.
If you don't use bin2c
, you must move YUV file to the path which x264 can find.
# For DSP
mv /the/path/yuv/1280x720.yuv ~/workspace_v12/x264-dsp/Release
# For PC
mv /the/path/yuv/1280x720.yuv .
Or tell the precious path:
the/path/of/x264 /the/path/yuv/1280x720.yuv
After running, out.264
will occur in ~/workspace_v12/x264-dsp/Release
for
DSP and current directory for PC.
You can use ffplay
to check the correctness of 264 format.
ffplay /the/path/of/out.264