hwcodec 0.1.0

Realtime AV1 and VP9 video encoding and decoding: hardware encoders (NVENC, Quick Sync, AMF, VA-API) and software codecs (SVT-AV1, libvpx, dav1d) behind one interface
Documentation
[package]
name = "hwcodec"
description = "Realtime AV1 and VP9 video encoding and decoding: hardware encoders (NVENC, Quick Sync, AMF, VA-API) and software codecs (SVT-AV1, libvpx, dav1d) behind one interface"
version = "0.1.0"
edition = "2024"
rust-version = "1.90"
license = "MIT OR Apache-2.0"
repository = "https://github.com/Mumcord/hwcodec"
documentation = "https://docs.rs/hwcodec"
readme = "README.md"
keywords = ["av1", "vp9", "video", "encoder", "hardware"]
categories = ["multimedia::video", "multimedia::encoding"]
# Only what a build of the crate, its tests and its examples needs.
include = [
    "/Cargo.toml",
    "/README.md",
    "/CHANGELOG.md",
    "/LICENSE-APACHE",
    "/LICENSE-MIT",
    "/build.rs",
    "/wrapper.h",
    "/src/**",
    "/examples/**",
    "/tests/**",
    "/vendor/**",
]

# docs.rs builds without network access and with a time limit. Its build sets DOCS_RS, which
# makes build.rs generate the bindings from the bundled headers without building or linking a
# codec library, so the documentation covers every feature. One target is enough: the public
# interface is the same on every system.
[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]

[workspace]
members = ["sys/*"]

[features]
default = ["nvenc", "amf", "qsv", "vaapi", "svt-av1", "libvpx", "dav1d"]
# Hardware encoders. They only exist on Windows and Linux (VA-API on Linux only); elsewhere the
# features compile to nothing.
nvenc = ["dep:bindgen"]
amf = ["dep:bindgen"]
qsv = ["dep:bindgen", "dep:pkg-config", "dep:hwcodec-libvpl-src", "dep:hwcodec-prebuilt-x86_64-pc-windows-msvc", "dep:sha2"]
vaapi = ["dep:bindgen"]
# Software codecs.
svt-av1 = ["dep:bindgen", "dep:pkg-config", "dep:hwcodec-svt-av1-src", "dep:hwcodec-prebuilt-x86_64-pc-windows-msvc", "dep:sha2"]
libvpx = ["dep:bindgen", "dep:pkg-config", "dep:hwcodec-libvpx-src", "dep:hwcodec-prebuilt-x86_64-pc-windows-msvc", "dep:sha2"]
dav1d = ["dep:bindgen", "dep:pkg-config", "dep:hwcodec-dav1d-src", "dep:hwcodec-prebuilt-x86_64-pc-windows-msvc", "dep:sha2"]

[dependencies]
log = "0.4"
thiserror = "2"

# Loads the GPU driver libraries for the hardware encoders at runtime (none on macOS). The
# loaders that bindgen generates in build.rs use it too.
[target.'cfg(not(target_os = "macos"))'.dependencies]
libloading = "0.9"

# Every build dependency is optional and belongs to the features that have native code: a build
# without features has none, so its build script needs neither libclang nor pkg-config nor a C
# compiler, on any target.
[build-dependencies]
# Generates the bindings of the codec libraries and of the vendor headers (needs libclang).
bindgen = { version = "0.73", optional = true }
# Finds the system libraries when HWCODEC_USE_SYSTEM_LIBS=1 is set.
pkg-config = { version = "0.3", optional = true }
# The bundled sources of the native libraries, one package per library because of the crates.io
# size limit. build.rs compiles them unless a prebuilt or system library is selected.
hwcodec-libvpx-src = { version = "0.1.0", path = "sys/libvpx-src", optional = true }
hwcodec-svt-av1-src = { version = "0.1.0", path = "sys/svt-av1-src", optional = true }
hwcodec-dav1d-src = { version = "0.1.0", path = "sys/dav1d-src", optional = true }
hwcodec-libvpl-src = { version = "0.1.0", path = "sys/libvpl-src", optional = true }

# Only for builds that run on 64-bit Windows with MSVC; nothing is added on other systems.
# The first holds the codec libraries prebuilt, because the bundled sources are not built on
# Windows. The second checks the download that replaces it in a git checkout, where that
# package is empty, against the checksum pinned in build.rs.
[target.'cfg(all(target_os = "windows", target_arch = "x86_64", target_env = "msvc"))'.build-dependencies]
hwcodec-prebuilt-x86_64-pc-windows-msvc = { version = "0.1.0", path = "sys/prebuilt-x86_64-pc-windows-msvc", optional = true }
sha2 = { version = "0.10", optional = true }

[[test]]
name = "av1"
required-features = ["svt-av1", "dav1d", "libvpx"]

[[test]]
name = "codec"
required-features = ["libvpx"]

[[test]]
name = "temporal_channels"
required-features = ["svt-av1", "dav1d", "libvpx"]

[[test]]
name = "vaapi"
required-features = ["dav1d", "libvpx"]

[[test]]
name = "settings"
required-features = ["svt-av1", "dav1d", "libvpx"]

[[test]]
name = "fallback"
required-features = ["svt-av1", "dav1d", "libvpx"]

[[example]]
name = "encode_decode"
required-features = ["svt-av1", "dav1d", "libvpx"]

[[example]]
name = "encode_speed"
required-features = ["svt-av1", "libvpx"]

[lints.rust]
missing_docs = "warn"
unsafe_op_in_unsafe_fn = "warn"

[lints.clippy]
dbg_macro = "warn"
todo = "warn"
undocumented_unsafe_blocks = "warn"
unwrap_used = "warn"