Skip to content

Commit b8bf09b

Browse files
committed
Patch some of the FFmpeg specific error process macros
1 parent 624db4b commit b8bf09b

File tree

6 files changed

+68
-3
lines changed

6 files changed

+68
-3
lines changed

Cargo.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,10 @@ doctest = false
2929

3030
[dependencies]
3131
once_cell = "1.4.0"
32+
libc = "0.2.71"
3233

3334
[build-dependencies]
3435
bindgen = "0.54.0"
3536
once_cell = "1.4.0"
3637
pkg-config = "0.3.17"
3738
num_cpus = "1.13.0"
38-
39-
[dev-dependencies]
40-
libc = "0.2.71"

src/avutil/avutil.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pub const AV_NOPTS_VALUE: i64 = 0x8000000000000000u64 as i64;

src/avutil/common.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#[allow(non_snake_case)]
2+
pub const fn MKBETAG(a: u8, b: u8, c: u8, d: u8) -> u32 {
3+
(d as u32) | ((c as u32) << 8) | ((b as u32) << 16) | ((a as u32) << 24)
4+
}
5+
6+
#[allow(non_snake_case)]
7+
pub const fn MKTAG(a: u8, b: u8, c: u8, d: u8) -> u32 {
8+
(a as u32) | ((b as u32) << 8) | ((c as u32) << 16) | ((d as u32) << 24)
9+
}

src/avutil/error.rs

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
use libc::c_int;
2+
use super::common::MKTAG;
3+
4+
#[allow(non_snake_case)]
5+
pub const fn AVERROR(e: c_int) -> c_int {
6+
-e
7+
}
8+
9+
#[allow(non_snake_case)]
10+
pub const fn AVUNERROR(e: c_int) -> c_int {
11+
-e
12+
}
13+
14+
macro_rules! FFERRTAG {
15+
($a:expr, $b:expr, $c:expr, $d:expr) =>
16+
(-(MKTAG($a, $b, $c, $d) as c_int))
17+
}
18+
19+
pub const AVERROR_BSF_NOT_FOUND: c_int = FFERRTAG!(0xF8, b'B', b'S', b'F');
20+
pub const AVERROR_BUG: c_int = FFERRTAG!(b'B', b'U', b'G', b'!');
21+
pub const AVERROR_BUFFER_TOO_SMALL: c_int = FFERRTAG!(b'B', b'U', b'F', b'S');
22+
pub const AVERROR_DECODER_NOT_FOUND: c_int = FFERRTAG!(0xF8, b'D', b'E', b'C');
23+
pub const AVERROR_DEMUXER_NOT_FOUND: c_int = FFERRTAG!(0xF8, b'D', b'E', b'M');
24+
pub const AVERROR_ENCODER_NOT_FOUND: c_int = FFERRTAG!(0xF8, b'E', b'N', b'C');
25+
pub const AVERROR_EOF: c_int = FFERRTAG!(b'E', b'O', b'F', b' ');
26+
pub const AVERROR_EXIT: c_int = FFERRTAG!(b'E', b'X', b'I', b'T');
27+
pub const AVERROR_EXTERNAL: c_int = FFERRTAG!(b'E', b'X', b'T', b' ');
28+
pub const AVERROR_FILTER_NOT_FOUND: c_int = FFERRTAG!(0xF8, b'F', b'I', b'L');
29+
pub const AVERROR_INVALIDDATA: c_int = FFERRTAG!(b'I', b'N', b'D', b'A');
30+
pub const AVERROR_MUXER_NOT_FOUND: c_int = FFERRTAG!(0xF8, b'M', b'U', b'X');
31+
pub const AVERROR_OPTION_NOT_FOUND: c_int = FFERRTAG!(0xF8, b'O', b'P', b'T');
32+
pub const AVERROR_PATCHWELCOME: c_int = FFERRTAG!(b'P', b'A', b'W', b'E');
33+
pub const AVERROR_PROTOCOL_NOT_FOUND: c_int = FFERRTAG!(0xF8, b'P', b'R', b'O');
34+
35+
pub const AVERROR_STREAM_NOT_FOUND: c_int = FFERRTAG!(0xF8, b'S', b'T', b'R');
36+
37+
pub const AVERROR_BUG2: c_int = FFERRTAG!(b'B', b'U', b'G', b' ');
38+
pub const AVERROR_UNKNOWN: c_int = FFERRTAG!(b'U', b'N', b'K', b'N');
39+
pub const AVERROR_EXPERIMENTAL: c_int = -0x2bb2afa8; ///< Requested feature is flagged experimental. Set strict_std_compliance if you really want to use it.
40+
pub const AVERROR_INPUT_CHANGED: c_int = -0x636e6701; ///< Input changed between calls. Reconfiguration is required. (can be OR-ed with AVERROR_OUTPUT_CHANGED)
41+
pub const AVERROR_OUTPUT_CHANGED: c_int = -0x636e6702; ///< Output changed between calls. Reconfiguration is required. (can be OR-ed with AVERROR_INPUT_CHANGED)
42+
43+
44+
pub const AVERROR_HTTP_BAD_REQUEST: c_int = FFERRTAG!(0xF8, b'4', b'0', b'0');
45+
pub const AVERROR_HTTP_UNAUTHORIZED: c_int = FFERRTAG!(0xF8, b'4', b'0', b'1');
46+
pub const AVERROR_HTTP_FORBIDDEN: c_int = FFERRTAG!(0xF8, b'4', b'0', b'3');
47+
pub const AVERROR_HTTP_NOT_FOUND: c_int = FFERRTAG!(0xF8, b'4', b'0', b'4');
48+
pub const AVERROR_HTTP_OTHER_4XX: c_int = FFERRTAG!(0xF8, b'4', b'X', b'X');
49+
pub const AVERROR_HTTP_SERVER_ERROR: c_int = FFERRTAG!(0xF8, b'5', b'X', b'X');
50+
51+
pub const AV_ERROR_MAX_STRING_SIZE: c_int = 64;

src/avutil/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
pub mod common;
2+
pub mod error;
3+
pub mod avutil;

src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,6 @@
88
pub mod ffi {
99
include!(concat!(env!("OUT_DIR"), "/binding.rs"));
1010
}
11+
12+
#[rustfmt::skip]
13+
pub mod avutil;

0 commit comments

Comments
 (0)