media/ffmpeg: use bindgen-common.sh

Switch to the common bindgen wrapper so that the ffmpeg bindings get the
same defaults as other bindgen-generated bindings.

BUG=None
TEST=media/ffmpeg/bindgen.sh
TEST=cargo build --features=ffmpeg,video-decoder

Change-Id: I09901c122401fe1b65eed154a6be8348decfcc33
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3893751
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
This commit is contained in:
Daniel Verkamp 2022-09-13 14:21:37 -07:00 committed by crosvm LUCI
parent 693f5e0a82
commit 03e1b667e3
5 changed files with 244 additions and 8277 deletions

View file

@ -10,16 +10,18 @@ cd "$(dirname "${BASH_SOURCE[0]}")/../.."
VERSIONS="media/ffmpeg/VERSIONS"
#source tools/impl/bindgen-common.sh
source tools/impl/bindgen-common.sh
bindgen media/ffmpeg/src/bindings.h -o media/ffmpeg/src/ffmpeg.rs \
bindgen_generate \
--allowlist-function "av_.*" \
--allowlist-function "avcodec_.*" \
--allowlist-function "sws_.*" \
--allowlist-function "av_image_.*" \
--allowlist-var "FF_PROFILE.*" \
--allowlist-var "AV_.*" \
--allowlist-var "AVERROR_.*"
--allowlist-var "AVERROR_.*" \
media/ffmpeg/src/bindings.h \
> media/ffmpeg/src/ffmpeg.rs
echo "# These version numbers are updated by the bindgen.sh script" >$VERSIONS
echo "avcodec: `pkg-config --modversion libavcodec`" >>$VERSIONS

View file

@ -38,13 +38,8 @@ impl Display for AvError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let mut buffer = [0u8; 255];
// Safe because we are passing valid bounds for the buffer.
let ret = unsafe {
ffi::av_strerror(
self.0,
buffer.as_mut_ptr() as *mut c_char,
buffer.len() as ffi::size_t,
)
};
let ret =
unsafe { ffi::av_strerror(self.0, buffer.as_mut_ptr() as *mut c_char, buffer.len()) };
match ret {
ret if ret >= 0 => {
let end_of_string = buffer.iter().position(|i| *i == 0).unwrap_or(buffer.len());
@ -467,7 +462,7 @@ impl AvBuffer {
Some(Self(unsafe {
ffi::av_buffer_create(
storage.as_mut_ptr(),
storage.len() as ffi::size_t,
storage.len(),
Some(avbuffer_free::<D>),
Box::into_raw(storage) as *mut c_void,
0,

View file

@ -1,20 +0,0 @@
// Copyright 2022 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#![allow(non_upper_case_globals)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(clippy::approx_constant)]
#![allow(clippy::missing_safety_doc)]
#![allow(clippy::redundant_static_lifetimes)]
#![allow(clippy::too_many_arguments)]
#![allow(clippy::type_complexity)]
#![allow(clippy::upper_case_acronyms)]
// Some of the tests generated by bindgen rely on dereferencing a null pointer
// (https://github.com/rust-lang/rust-bindgen/issues/1651), which is UB. Let's tolerate this to
// avoid a bunch of warnings.
#![allow(deref_nullptr)]
include!("ffmpeg.rs");

File diff suppressed because it is too large Load diff

View file

@ -7,7 +7,8 @@ mod avutil;
pub use avutil::*;
mod error;
pub use error::*;
mod ffi;
mod ffmpeg;
use ffmpeg as ffi;
pub mod swscale;
pub use ffi::AVPixelFormat_AV_PIX_FMT_NV12;