Skip to content

Commit 9aa7949

Browse files
authored
dep: Remove libc (CCExtractor#136)
1 parent 35bd8fc commit 9aa7949

File tree

4 files changed

+16
-14
lines changed

4 files changed

+16
-14
lines changed

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ exclude = [".github"]
2222
doctest = false
2323

2424
[dependencies]
25-
libc = "0.2"
2625

2726
[build-dependencies]
2827
bindgen = "0.70"

src/avutil/_avutil.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
use crate::ffi::{AVRational, AV_TIME_BASE};
2+
use std::ffi::c_int;
23

34
pub const AV_NOPTS_VALUE: i64 = 0x8000000000000000u64 as i64;
45
pub const AV_TIME_BASE_Q: AVRational = AVRational {
56
num: 1,
6-
den: AV_TIME_BASE as libc::c_int,
7+
den: AV_TIME_BASE as c_int,
78
};

src/avutil/error.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
use libc::c_int;
1+
use std::ffi::c_char;
2+
use std::ffi::c_int;
23
use std::ffi::CStr;
34
use super::common::MKTAG;
45
use crate::ffi;
@@ -62,16 +63,16 @@ pub const AV_ERROR_MAX_STRING_SIZE: usize = 64;
6263
/// # Safety
6364
/// Safety requirements is the same as the av_strerror()`
6465
pub unsafe fn av_make_error_string(
65-
errbuf: *mut libc::c_char,
66-
errbuf_size: libc::size_t,
67-
errnum: libc::c_int
68-
) -> *mut libc::c_char {
66+
errbuf: *mut c_char,
67+
errbuf_size: usize,
68+
errnum: c_int
69+
) -> *mut c_char {
6970
ffi::av_strerror(errnum, errbuf, errbuf_size);
7071
errbuf
7172
}
7273

7374
pub fn av_err2str(
74-
errnum: libc::c_int
75+
errnum: c_int
7576
) -> String {
7677
let mut errbuf = [0u8; AV_ERROR_MAX_STRING_SIZE];
7778
let errbuf_ptr = errbuf.as_mut_ptr() as _;

src/avutil/rational.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22
/// in linked library. So we need this.
33
/// Ref: https://github.com/rust-lang/rust-bindgen/issues/1344
44
use crate::ffi::AVRational;
5+
use std::ffi::{c_double, c_int};
56

67
/// Create an AVRational.
78
///
89
/// Useful for compilers that do not support compound literals.
910
///
1011
/// @note The return value is not reduced.
1112
/// @see av_reduce()
12-
pub const fn av_make_q(num: libc::c_int, den: libc::c_int) -> AVRational {
13+
pub const fn av_make_q(num: c_int, den: c_int) -> AVRational {
1314
AVRational { num, den }
1415
}
1516

@@ -23,26 +24,26 @@ pub const fn av_make_q(num: libc::c_int, den: libc::c_int) -> AVRational {
2324
/// - 1 if `a > b`
2425
/// - -1 if `a < b`
2526
/// - `INT_MIN` if one of the values is of the form `0 / 0`
26-
pub fn av_cmp_q(a: AVRational, b: AVRational) -> libc::c_int {
27+
pub fn av_cmp_q(a: AVRational, b: AVRational) -> c_int {
2728
let tmp = i64::from(a.num) * i64::from(b.den) - i64::from(b.num) * i64::from(a.den);
2829

2930
if tmp != 0 {
30-
(((tmp ^ i64::from(a.den) ^ i64::from(b.den)) >> 63) | 1) as libc::c_int
31+
(((tmp ^ i64::from(a.den) ^ i64::from(b.den)) >> 63) | 1) as c_int
3132
} else if b.den != 0 && a.den != 0 {
3233
0
3334
} else if a.num != 0 && b.num != 0 {
3435
(a.num >> 31) - (b.num >> 31)
3536
} else {
36-
libc::c_int::MIN
37+
c_int::MIN
3738
}
3839
}
3940

4041
/// Convert an AVRational to a `double`.
4142
/// @param a AVRational to convert
4243
/// @return `a` in floating-point form
4344
/// @see av_d2q()
44-
pub fn av_q2d(a: AVRational) -> libc::c_double {
45-
libc::c_double::from(a.num) / libc::c_double::from(a.den)
45+
pub fn av_q2d(a: AVRational) -> c_double {
46+
c_double::from(a.num) / c_double::from(a.den)
4647
}
4748

4849
/// Invert a rational.

0 commit comments

Comments
 (0)