From 30aabf9033b9ad3422c51afdc109527a24dfbb99 Mon Sep 17 00:00:00 2001 From: FreezyLemon Date: Tue, 2 Apr 2024 14:47:59 +0200 Subject: [PATCH] Add FFmpeg 6.1 support (#14) Co-authored-by: Rafie --- .github/workflows/build.yml | 35 +-------------------------------- Cargo.toml | 2 +- ffmpeg-sys-the-third/Cargo.toml | 2 +- ffmpeg-sys-the-third/build.rs | 1 + src/codec/id.rs | 21 ++++++++++++++++++++ src/format/context/output.rs | 2 -- src/util/format/pixel.rs | 22 +++++++++++++++++++++ src/util/frame/side_data.rs | 9 +++++++++ 8 files changed, 56 insertions(+), 38 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b291d09..3b3979a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,8 +12,7 @@ jobs: strategy: matrix: ffmpeg_version: - # The windows build tests ffmpeg 6.0. There's no linux image for 6.0 at this time. - ["3.4", "4.0", "4.1", "4.2", "4.3", "4.4", "5.0", "5.1"] + ["3.4", "4.0", "4.1", "4.2", "4.3", "4.4", "5.0", "5.1", "6.0", "6.1"] fail-fast: false steps: - uses: actions/checkout@v2 @@ -40,38 +39,6 @@ jobs: run: | cargo fmt -- --check - build-test-lint-linux-ffmpeg6: - # There is no docker image for ffmpeg 6.0, so we have to build it ourselves - name: Linux - FFmpeg 6.0 - build, test and lint - runs-on: ubuntu-latest - container: rust:latest - strategy: - fail-fast: false - steps: - - uses: actions/checkout@v2 - - name: Install dependencies - run: | - apt update - apt install -y --no-install-recommends clang curl pkg-config nasm - - name: Set up Rust - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - override: true - components: rustfmt, clippy - - name: Build - run: | - cargo build --examples --features build - - name: Test - run: | - cargo test --examples --features build - - name: Lint - run: | - cargo clippy --examples --features build -- -D warnings - - name: Check format - run: | - cargo fmt -- --check - build-test-lint-macos: name: macOS - FFmpeg latest - build, test and lint runs-on: macos-latest diff --git a/Cargo.toml b/Cargo.toml index 5017278..ec994f7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ffmpeg-the-third" -version = "1.2.2+ffmpeg-6.0" +version = "1.3.0+ffmpeg-6.1" build = "build.rs" authors = ["meh. ", "Zhiming Wang "] diff --git a/ffmpeg-sys-the-third/Cargo.toml b/ffmpeg-sys-the-third/Cargo.toml index 0a00a3b..b4f836d 100644 --- a/ffmpeg-sys-the-third/Cargo.toml +++ b/ffmpeg-sys-the-third/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ffmpeg-sys-the-third" -version = "1.1.1+ffmpeg-6.0" +version = "1.2.0+ffmpeg-6.1" build = "build.rs" links = "ffmpeg" diff --git a/ffmpeg-sys-the-third/build.rs b/ffmpeg-sys-the-third/build.rs index aa9daae..bc53874 100644 --- a/ffmpeg-sys-the-third/build.rs +++ b/ffmpeg-sys-the-third/build.rs @@ -608,6 +608,7 @@ fn check_features( ("ffmpeg_5_0", 59, 18), ("ffmpeg_5_1", 59, 37), ("ffmpeg_6_0", 60, 3), + ("ffmpeg_6_1", 60, 31), ]; for &(ffmpeg_version_flag, lavc_version_major, lavc_version_minor) in ffmpeg_lavc_versions.iter() diff --git a/src/codec/id.rs b/src/codec/id.rs index 4bb58d6..ba2d3ee 100644 --- a/src/codec/id.rs +++ b/src/codec/id.rs @@ -647,6 +647,17 @@ pub enum Id { VNULL, #[cfg(feature = "ffmpeg_6_0")] ANULL, + + #[cfg(feature = "ffmpeg_6_1")] + PDV, + #[cfg(feature = "ffmpeg_6_1")] + EVC, + #[cfg(feature = "ffmpeg_6_1")] + RTV1, + #[cfg(feature = "ffmpeg_6_1")] + VMIX, + #[cfg(feature = "ffmpeg_6_1")] + AC4, } impl Id { @@ -1944,6 +1955,16 @@ impl From for AVCodecID { Id::VNULL => AV_CODEC_ID_VNULL, #[cfg(feature = "ffmpeg_6_0")] Id::ANULL => AV_CODEC_ID_ANULL, + #[cfg(feature = "ffmpeg_6_1")] + Id::PDV => AV_CODEC_ID_PDV, + #[cfg(feature = "ffmpeg_6_1")] + Id::EVC => AV_CODEC_ID_EVC, + #[cfg(feature = "ffmpeg_6_1")] + Id::RTV1 => AV_CODEC_ID_RTV1, + #[cfg(feature = "ffmpeg_6_1")] + Id::VMIX => AV_CODEC_ID_VMIX, + #[cfg(feature = "ffmpeg_6_1")] + Id::AC4 => AV_CODEC_ID_AC4, } } } diff --git a/src/format/context/output.rs b/src/format/context/output.rs index 84bac41..5a4e0c1 100644 --- a/src/format/context/output.rs +++ b/src/format/context/output.rs @@ -3,8 +3,6 @@ use std::mem::size_of; use std::ops::{Deref, DerefMut}; use std::ptr; -use libc; - use super::common::Context; use super::destructor; use codec::traits; diff --git a/src/util/format/pixel.rs b/src/util/format/pixel.rs index 6910fc8..7a7d185 100644 --- a/src/util/format/pixel.rs +++ b/src/util/format/pixel.rs @@ -404,6 +404,17 @@ pub enum Pixel { #[cfg(feature = "ffmpeg_6_0")] RGBAF32LE, + #[cfg(feature = "ffmpeg_6_1")] + P212BE, + #[cfg(feature = "ffmpeg_6_1")] + P212LE, + #[cfg(feature = "ffmpeg_6_1")] + P412BE, + #[cfg(feature = "ffmpeg_6_1")] + P412LE, + #[cfg(feature = "ffmpeg_6_1")] + GBRAP14BE, + #[cfg(feature = "rpi")] RPI, #[cfg(feature = "rpi")] @@ -1215,6 +1226,17 @@ impl From for AVPixelFormat { #[cfg(feature = "ffmpeg_6_0")] Pixel::RGBAF32LE => AV_PIX_FMT_RGBAF32LE, + #[cfg(feature = "ffmpeg_6_1")] + Pixel::P212BE => AV_PIX_FMT_P212BE, + #[cfg(feature = "ffmpeg_6_1")] + Pixel::P212LE => AV_PIX_FMT_P212LE, + #[cfg(feature = "ffmpeg_6_1")] + Pixel::P412BE => AV_PIX_FMT_P412BE, + #[cfg(feature = "ffmpeg_6_1")] + Pixel::P412LE => AV_PIX_FMT_P412LE, + #[cfg(feature = "ffmpeg_6_1")] + Pixel::GBRAP14BE => AV_PIX_FMT_GBRAP14BE, + #[cfg(feature = "rpi")] Pixel::RPI => AV_PIX_FMT_RPI, #[cfg(feature = "rpi")] diff --git a/src/util/frame/side_data.rs b/src/util/frame/side_data.rs index 3dcaf93..830215d 100644 --- a/src/util/frame/side_data.rs +++ b/src/util/frame/side_data.rs @@ -64,6 +64,9 @@ pub enum Type { #[cfg(feature = "ffmpeg_6_0")] AMBIENT_VIEWING_ENVIRONMENT, + + #[cfg(feature = "ffmpeg_6_1")] + VIDEO_HINT, } impl Type { @@ -130,6 +133,9 @@ impl From for Type { #[cfg(feature = "ffmpeg_6_0")] AV_FRAME_DATA_AMBIENT_VIEWING_ENVIRONMENT => Type::AMBIENT_VIEWING_ENVIRONMENT, + #[cfg(feature = "ffmpeg_6_1")] + AV_FRAME_DATA_VIDEO_HINT => Type::VIDEO_HINT, + #[cfg(feature = "non-exhaustive-enums")] _ => unimplemented!(), } @@ -190,6 +196,9 @@ impl From for AVFrameSideDataType { #[cfg(feature = "ffmpeg_6_0")] Type::AMBIENT_VIEWING_ENVIRONMENT => AV_FRAME_DATA_AMBIENT_VIEWING_ENVIRONMENT, + + #[cfg(feature = "ffmpeg_6_1")] + Type::VIDEO_HINT => AV_FRAME_DATA_VIDEO_HINT, } } }