Skip to content

Commit

Permalink
Enable to build any libva headers >= 1.15.0
Browse files Browse the repository at this point in the history
  • Loading branch information
rosetta-jpn committed Nov 25, 2024
1 parent 9d63222 commit feb1647
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 26 deletions.
3 changes: 3 additions & 0 deletions lib/Android.bp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ rust_library {

cfgs: [
"libva_1_21_or_higher",
"libva_1_20_or_higher",
"libva_1_19_or_higher",
"libva_1_16_or_higher",
],

vendor: true,
Expand Down
9 changes: 9 additions & 0 deletions lib/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,15 @@ fn main() {
if va_check_version(1, 21) {
println!("cargo::rustc-cfg=libva_1_21_or_higher");
}
if va_check_version(1, 20) {
println!("cargo::rustc-cfg=libva_1_20_or_higher")
}
if va_check_version(1, 19) {
println!("cargo::rustc-cfg=libva_1_19_or_higher")
}
if va_check_version(1, 16) {
println!("cargo::rustc-cfg=libva_1_16_or_higher")
}

if !va_lib_path.is_empty() {
assert!(
Expand Down
33 changes: 9 additions & 24 deletions lib/src/buffer/av1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,7 @@ impl AV1EncSeqFields {
bit_depth_minus8,
subsampling_x,
subsampling_y,
#[cfg(libva_1_19_or_higher)]
mono_chrome,
Default::default(),
);
Expand Down Expand Up @@ -655,6 +656,7 @@ impl EncSequenceParameterBufferAV1 {
seq_profile,
seq_level_idx,
seq_tier,
#[cfg(libva_1_16_or_higher)]
hierarchical_flag,
intra_period,
ip_period,
Expand Down Expand Up @@ -736,11 +738,12 @@ impl AV1EncPictureFlags {
let disable_frame_recon = disable_frame_recon as u32;
let allow_intrabc = allow_intrabc as u32;
let palette_mode_enable = palette_mode_enable as u32;

#[cfg(libva_1_21_or_higher)]
let allow_screen_content_tools = allow_screen_content_tools as u32;
#[cfg(libva_1_21_or_higher)]
let force_integer_mv = force_integer_mv as u32;

let _bitfield_1 = {
let allow_screen_content_tools = allow_screen_content_tools as u32;
let force_integer_mv = force_integer_mv as u32;
bindings::_VAEncPictureParameterBufferAV1__bindgen_ty_1__bindgen_ty_1::new_bitfield_1(
frame_type,
error_resilient_mode,
Expand All @@ -755,32 +758,13 @@ impl AV1EncPictureFlags {
disable_frame_recon,
allow_intrabc,
palette_mode_enable,
#[cfg(libva_1_21_or_higher)]
allow_screen_content_tools,
#[cfg(libva_1_21_or_higher)]
force_integer_mv,
Default::default(),
)
};
#[cfg(not(libva_1_21_or_higher))]
let _bitfield_1 =
bindings::_VAEncPictureParameterBufferAV1__bindgen_ty_1__bindgen_ty_1::new_bitfield_1(
frame_type,
error_resilient_mode,
disable_cdf_update,
use_superres,
allow_high_precision_mv,
use_ref_frame_mvs,
disable_frame_end_update_cdf,
reduced_tx_set,
enable_frame_obu,
long_term_reference,
disable_frame_recon,
allow_intrabc,
palette_mode_enable,
//allow_screen_content_tools,
//force_integer_mv,
Default::default(),
);

Self(bindings::_VAEncPictureParameterBufferAV1__bindgen_ty_1 {
bits: bindings::_VAEncPictureParameterBufferAV1__bindgen_ty_1__bindgen_ty_1 {
_bitfield_align_1: Default::default(),
Expand Down Expand Up @@ -1095,6 +1079,7 @@ impl EncPictureParameterBufferAV1 {
coded_buf,
reference_frames,
ref_frame_idx,
#[cfg(libva_1_19_or_higher)]
hierarchical_level_plus1,
primary_ref_frame,
order_hint,
Expand Down
2 changes: 0 additions & 2 deletions lib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ pub use usage_hint::*;

use std::num::NonZeroI32;

use crate::bindings::VAStatus;

/// A `VAStatus` that is guaranteed to not be `VA_STATUS_SUCCESS`.
#[derive(Debug)]
pub struct VaError(NonZeroI32);
Expand Down
2 changes: 2 additions & 0 deletions lib/src/surface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ where
pub enum DecodeErrorType {
SliceMissing = bindings::VADecodeErrorType::VADecodeSliceMissing,
MBError = bindings::VADecodeErrorType::VADecodeMBError,
#[cfg(libva_1_20_or_higher)]
Reset = bindings::VADecodeErrorType::VADecodeReset,
}

Expand Down Expand Up @@ -307,6 +308,7 @@ impl<D: SurfaceMemoryDescriptor> Surface<D> {
let type_ = match error.decode_error_type {
bindings::VADecodeErrorType::VADecodeSliceMissing => DecodeErrorType::SliceMissing,
bindings::VADecodeErrorType::VADecodeMBError => DecodeErrorType::MBError,
#[cfg(libva_1_20_or_higher)]
bindings::VADecodeErrorType::VADecodeReset => DecodeErrorType::Reset,
_ => {
log::warn!(
Expand Down

0 comments on commit feb1647

Please sign in to comment.