Skip to content

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. maintainers: @ustc-ivclab/x264-transplant

Notifications You must be signed in to change notification settings

ustc-ivclab/x264-dsp

 
 

Repository files navigation

x264-dsp

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.

Dependencies

Build Systems

For autotools:

Download a source distribution, then install:

  • bash
  • make (ccstudio contains a builtin /opt/ccstudio/ccs/utils/bin/gmake)

For cmake:

For meson:

Toolchains

Host Builds

One of the following:

Cross Compiling

For TI C6000 toolchain > 8.0.0, refer https://github.com/Freed-Wu/x264.

Optional Dependencies

  • check: for unit test
    • make check
    • ctest
    • meson test -Cbuild
  • bin2c: use bin2c to convert a yuv to a c array
    • ./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

Build

autotools

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.

cmake

# 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
cmake -Bbuild -DCMAKE_TOOLCHAIN_FILE=cmake/ti.cmake
cmake --build build

See ccmake -Bbuild to know how to configure.

meson

meson setup build
meson compile -Cbuild

See meson configure build to know how to configure.

ccstudio

# a large heap/stack size to avoid malloc failure
ccstudio -noSplash -data ~/workspace_v12 -application com.ti.ccstudio.apps.projectCreate -ccs.device TMS320C64XX.TMS320DM6467 -ccs.name x264-dsp -ccs.setCompilerOptions --gcc -ccs.setCompilerOptions -O3 @configurations Release -ccs.setCompilerOptions --program_level_compile @configurations Release -ccs.setCompilerOptions --call_assumptions=3 @configurations Release -ccs.setLinkerOptions -heap=0x1000000 -ccs.setLinkerOptions -stack=0x1000000
cd ~/workspace_v12/x264-dsp
git clone --bare --depth=1 https://github.com/Freed-Wu/x264-dsp .git
git config core.bare false
git reset --hard
# use autotools to generate config.h and yuv.h
autoreconf -vif
./configure --with-bin2c=/the/path/of/1280x720.yuv --with-downsample --with-downsample-scale=4
# or use cmake
cmake -B. -DBIN2C=ON -DINPUT_FILENAME=/the/path/of/1280x720.yuv -DDOWNSAMPLE=1 -DSCALE=4
cmake --build . --target yuv.h
rm -r CMakeFiles
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

Burn

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
  1. select project arm
  2. press Alt + CR to open properties

project explorer

  1. select Manage the project's target-configuration automatically
  2. change Connection according to your debug probe

Connection

ccxml

  1. double click TMS320DM6467.ccxml
  2. press Target Configuration

Target Configuration

  1. select ~/workspace_v12/x264-dsp/assets/gel/davincihd_arm.gel for ARM926, ARM968_0, ARM968_1
  2. select ~/workspace_v12/x264-dsp/assets/gel/davincihd_dsp.gel for C64XP
  3. press Ctrl + S to save

arm

dsp

  1. power on DSP
  2. press F11 to debug
  3. press OK
  1. press OK to close Launching Debug Session

Launching Debug Session

  1. change project x264-dsp on Project Explorer
  2. press F11 to debug
  3. press F8 to run

Refer Code Composer Studio User’s Guide to debug.

Usage

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

Documents

About

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. maintainers: @ustc-ivclab/x264-transplant

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C 95.5%
  • Shell 2.2%
  • M4 1.0%
  • CMake 0.6%
  • Meson 0.4%
  • Python 0.2%
  • Other 0.1%