diff --git a/lib/Android.bp b/lib/Android.bp index 92a62cb..ea7bf85 100644 --- a/lib/Android.bp +++ b/lib/Android.bp @@ -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, diff --git a/lib/build.rs b/lib/build.rs index 7c56157..b6730e6 100644 --- a/lib/build.rs +++ b/lib/build.rs @@ -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!( diff --git a/lib/src/buffer/av1.rs b/lib/src/buffer/av1.rs index a600f98..bc60782 100644 --- a/lib/src/buffer/av1.rs +++ b/lib/src/buffer/av1.rs @@ -621,6 +621,7 @@ impl AV1EncSeqFields { bit_depth_minus8, subsampling_x, subsampling_y, + #[cfg(libva_1_19_or_higher)] mono_chrome, Default::default(), ); @@ -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, @@ -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, @@ -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(), @@ -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, diff --git a/lib/src/lib.rs b/lib/src/lib.rs index a761495..c7111f3 100644 --- a/lib/src/lib.rs +++ b/lib/src/lib.rs @@ -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); diff --git a/lib/src/surface.rs b/lib/src/surface.rs index 0ef74f4..3597409 100644 --- a/lib/src/surface.rs +++ b/lib/src/surface.rs @@ -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, } @@ -307,6 +308,7 @@ impl Surface { 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!(