Skip to content

video/external: Bump OpenH264 to 2.5.0 #18581

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion video/external/src/decoder.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// cargo install bindgen-cli
// bindgen ../openh264/codec/api/wels/codec_api.h --no-prepend-enum-name \
// --dynamic-loading OpenH264 -o openh264_sys.rs
// --no-layout-tests --dynamic-loading OpenH264 -o openh264_sys.rs
#[cfg(feature = "openh264")]
#[allow(non_upper_case_globals)]
#[allow(non_camel_case_types)]
Expand Down
50 changes: 27 additions & 23 deletions video/external/src/decoder/openh264.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::fs::File;
use std::io::copy;
use std::path::{Path, PathBuf};
use std::ptr;
use std::sync::Arc;
use std::rc::Rc;

use crate::decoder::openh264_sys::{self, videoFormatI420, ISVCDecoder, OpenH264};
use crate::decoder::VideoDecoder;
Expand Down Expand Up @@ -39,56 +39,60 @@ pub enum OpenH264Error {

/// OpenH264 codec representation.
pub struct OpenH264Codec {
openh264: Arc<OpenH264>,
openh264: Rc<OpenH264>,
}

impl OpenH264Codec {
const VERSION: OpenH264Version = OpenH264Version(2, 4, 1);
const VERSION: OpenH264Version = OpenH264Version(2, 5, 0);

/// Returns the OpenH264 library data for the current platform.
fn get_data() -> Result<OpenH264Data, Box<dyn std::error::Error>> {
const OS: &str = std::env::consts::OS;
const ARCH: &str = std::env::consts::ARCH;

let local_filenames = match OS {
"linux" => vec!["libopenh264.so.7", "libopenh264.so.2.4.1", "libopenh264.so"],
"linux" => vec!["libopenh264.so.7", "libopenh264.so.2.5.0", "libopenh264.so"],
// TODO: investigate other OSes
_ => vec![],
};

// Source: https://github.com/cisco/openh264/releases/tag/v2.4.1
// Source: https://github.com/cisco/openh264/releases/tag/v2.5.0
let (download_filename, download_sha256) = match (OS, ARCH) {
("linux", "x86") => (
"libopenh264-2.4.1-linux32.7.so",
"b7cf0e407f99056d90cbf62787a34820a7595b2129b165319d50766e00a66704",
"libopenh264-2.5.0-linux32.7.so",
"cfa8fcf711114fd174c7e377979bb88a4ef330c8ae6da1b9275f87c5146ba789",
),
("linux", "x86_64") => (
"libopenh264-2.4.1-linux64.7.so",
"1392d21466bc638e68151b716d5b2086d54cd812afd43253f1adb5b6e0185f51",
"libopenh264-2.5.0-linux64.7.so",
"e17f533b41dae28682e118273e368d4c11bff945207a22363188102c28877b3d",
),
("linux", "arm") => (
"libopenh264-2.4.1-linux-arm.7.so",
"fd1dfb27d30bb72e903c9d2b4c650104a4369d2e7ffe8a4a533e8db2e7e9b19e",
"libopenh264-2.5.0-linux-arm.7.so",
"0eb4ef9f3c8c7c1959c1731ce3fd13e43b542c14fdd163154bb92d1836c179ae",
),
("linux", "aarch64") => (
"libopenh264-2.4.1-linux-arm64.7.so",
"e8ea7e42855ceb4a90e7bd0b3abeba0c58b5f97166e8b0a30eefd58e099557a4",
"libopenh264-2.5.0-linux-arm64.7.so",
"a3561cbd04889f38ba82b6f4e4a226f00063863c263bd4ae13e1398b5ca9df80",
),
("macos", "x86_64") => (
"libopenh264-2.4.1-mac-x64.dylib",
"cc0ba518a63791c37571f3c851f0aa03a4fbda5410acc214ecd4f24f8d1c478e",
"libopenh264-2.5.0-mac-x64.dylib",
"83af03a9d9bc816fdced1ecb2aa775416890fe8154c0ef4897da2af1a5af3eab",
),
("macos", "aarch64") => (
"libopenh264-2.4.1-mac-arm64.dylib",
"213ff93831cfa3dd6d7ad0c3a3403a6ceedf4ac1341e1278b5b869d42fefb496",
"libopenh264-2.5.0-mac-arm64.dylib",
"784f1b95d88b1904ceb6d6b2c18f93d250ab6479e62b84c4f79a67d7d6db6ad9",
),
("windows", "x86") => (
"openh264-2.4.1-win32.dll",
"83270149640469c994a62cc32a6d8c0413cd7b802b7f1f2f532159f5bdc1cedd",
"openh264-2.5.0-win32.dll",
"2824a4fbfc4640c2cd94aa208f78aac16304bd49e83529d0fb106a87b165f89a",
),
("windows", "x86_64") => (
"openh264-2.4.1-win64.dll",
"081b0c081480d177cbfddfbc90b1613640e702f875897b30d8de195cde73dd34",
"openh264-2.5.0-win64.dll",
"bf91c488638b32448f7d89611f6bb9c232dce82975d7d2827c78f78fc2a7fb2b",
),
("windows", "aarch64") => (
"openh264-2.5.0-win-arm64.dll",
"6d046ac2f85082fdfebdc54bc53c9c4ff7add4e9383ea52aa0e05b6a0b380b64",
),
(os, arch) => return Err(format!("Unsupported OS/arch: {}/{}", os, arch).into()),
};
Expand Down Expand Up @@ -163,7 +167,7 @@ impl OpenH264Codec {
}

Ok(Self {
openh264: Arc::new(openh264),
openh264: Rc::new(openh264),
})
}

Expand Down Expand Up @@ -197,7 +201,7 @@ pub struct H264Decoder {
/// How many bytes are used to store the length of the NALU (1, 2, 3, or 4).
length_size: u8,

openh264: Arc<OpenH264>,
openh264: Rc<OpenH264>,
decoder: *mut ISVCDecoder,
}

Expand Down
Loading
Loading