3 releases

0.1.2 Aug 10, 2023
0.1.1 Dec 17, 2022
0.1.0 Dec 16, 2022

#52 in Multimedia

GPL-2.0-or-later

210KB
4.5K SLoC

libyuv-rs

Raw FFI bindings to libyuv libraries.

Quick start

Add the following to your Cargo.toml:

libyuv = "0.1"

Building

The libyuv crate will automatically find the precompiled static library files in the git libyuv repo release.

  • YUV_LIBRARY_PATH - libyuv static library path, this will skip downloading and use your static library.

Pre-requisites

You'll need to have depot tools installed: https://www.chromium.org/developers/how-tos/install-depot-tools Refer to chromium instructions for each platform for other prerequisites.

Getting the Code

Create a working directory, enter it, and run:

gclient config --name src https://chromium.googlesource.com/libyuv/libyuv
gclient sync

Then you'll get a .gclient file like:

solutions = [
  { "name"        : "src",
    "url"         : "https://chromium.googlesource.com/libyuv/libyuv",
    "deps_file"   : "DEPS",
    "managed"     : True,
    "custom_deps" : {
    },
    "safesync_url": "",
  },
];

For iOS add ;target_os=['ios']; to your OSX .gclient and run gclient sync.

Android

For Android add ;target_os=['android']; to your Linux .gclient

solutions = [
  { "name"        : "src",
    "url"         : "https://chromium.googlesource.com/libyuv/libyuv",
    "deps_file"   : "DEPS",
    "managed"     : True,
    "custom_deps" : {
    },
    "safesync_url": "",
  },
];
target_os = ["android", "linux"];

Then run:

gclient sync

To get just the source (not buildable):

git clone https://chromium.googlesource.com/libyuv/libyuv

Building the Library

Windows
call gn gen out\Release "--args=is_debug=false target_cpu=\"x64\""
call gn gen out\Debug "--args=is_debug=true target_cpu=\"x64\""
ninja -v -C out\Release
ninja -v -C out\Debug

call gn gen out\Release "--args=is_debug=false target_cpu=\"x86\""
call gn gen out\Debug "--args=is_debug=true target_cpu=\"x86\""
ninja -v -C out\Release
ninja -v -C out\Debug
macOS and Linux
gn gen out/Release "--args=is_debug=false"
gn gen out/Debug "--args=is_debug=true"
ninja -v -C out/Release
ninja -v -C out/Debug
iOS

http://www.chromium.org/developers/how-tos/build-instructions-ios

Add to .gclient last line: target_os=['ios'];

  • arm64
gn gen out/Release "--args=is_debug=false target_os=\"ios\" ios_enable_code_signing=false target_cpu=\"arm64\""
gn gen out/Debug "--args=is_debug=true target_os=\"ios\" ios_enable_code_signing=false target_cpu=\"arm64\""
ninja -v -C out/Debug libyuv_unittest
ninja -v -C out/Release libyuv_unittest
  • ios simulator
gn gen out/Release "--args=is_debug=false target_os=\"ios\" ios_enable_code_signing=false use_xcode_clang=true target_cpu=\"x86\""
gn gen out/Debug "--args=is_debug=true target_os=\"ios\" ios_enable_code_signing=false use_xcode_clang=true target_cpu=\"x86\""
ninja -v -C out/Debug libyuv_unittest
ninja -v -C out/Release libyuv_unittest
Android

https://code.google.com/p/chromium/wiki/AndroidBuildInstructions

Add to .gclient last line: target_os=['android'];

  • arm64
gn gen out/Release "--args=is_debug=false target_os=\"android\" target_cpu=\"arm64\""
gn gen out/Debug "--args=is_debug=true target_os=\"android\" target_cpu=\"arm64\""
ninja -v -C out/Debug libyuv_unittest
ninja -v -C out/Release libyuv_unittest
  • armv7
gn gen out/Release "--args=is_debug=false target_os=\"android\" target_cpu=\"arm\""
gn gen out/Debug "--args=is_debug=true target_os=\"android\" target_cpu=\"arm\""
ninja -v -C out/Debug libyuv_unittest
ninja -v -C out/Release libyuv_unittest
  • ia32
gn gen out/Release "--args=is_debug=false target_os=\"android\" target_cpu=\"x86\""
gn gen out/Debug "--args=is_debug=true target_os=\"android\" target_cpu=\"x86\""
ninja -v -C out/Debug libyuv_unittest
ninja -v -C out/Release libyuv_unittest
  • mips
gn gen out/Release "--args=is_debug=false target_os=\"android\" target_cpu=\"mips64el\" mips_arch_variant=\"r6\" mips_use_msa=true is_component_build=true"
gn gen out/Debug "--args=is_debug=true target_os=\"android\" target_cpu=\"mips64el\" mips_arch_variant=\"r6\" mips_use_msa=true is_component_build=true"
ninja -v -C out/Debug libyuv_unittest
ninja -v -C out/Release libyuv_unittest
Build targets
ninja -C out/Debug libyuv
ninja -C out/Debug libyuv_unittest
ninja -C out/Debug compare
ninja -C out/Debug yuvconvert
ninja -C out/Debug yuvconstants
ninja -C out/Debug psnr
ninja -C out/Debug cpuid
ARM Linux
gn gen out/Release "--args=is_debug=false target_cpu=\"arm64\""
gn gen out/Debug "--args=is_debug=true target_cpu=\"arm64\""
ninja -v -C out/Debug libyuv_unittest
ninja -v -C out/Release libyuv_unittest
MIPS Linux
gn gen out/Release "--args=is_debug=false target_os="linux" target_cpu="mips64el" mips_arch_variant="loongson3" is_component_build=false use_sysroot=false use_gold=false” 
gn gen out/Debug "--args=is_debug=true target_os="linux" target_cpu="mips64el" mips_arch_variant="loongson3" is_component_build=false use_sysroot=false use_gold=false” 
ninja -v -C out/Debug libyuv_unittest 
ninja -v -C out/Release libyuv_unittest

Building the Library with make

Linux
make V=1 -f linux.mk
make V=1 -f linux.mk clean
make V=1 -f linux.mk CXX=clang++ CC=clang

Building the library with cmake

Install cmake: http://www.cmake.org/

Default debug build:
mkdir out
cd out
cmake ..
cmake --build .
Release build
mkdir out
cd out
cmake -DCMAKE_BUILD_TYPE="Release" ..
cmake --build . --config Release

Sanitizers

Sanitizers available: asan, msan, tsan, ubsan, lsan, ubsan_vptr

gn gen out/Release "--args=is_debug=false is_msan=true"
ninja -v -C out/Release

License

MIT Copyright (c) 2022 Mr.Panda.

Dependencies

~43KB