U17: cros-libva drop unused MPEG2/VP8/JPEG buffers, Android.bp, test_frame.nv12, ignored hardware tests and crc32fast dev-dep (ec-va/ec-hw never build these)
Browse files at this commit894968f788128316bf11b72f20eb675ebfec13cdParent: 41510f010 changed files +7 -1609
- Cargo.lock +0 -1
- shims/cros-libva/Android.bp +0 -63
- shims/cros-libva/Cargo.toml +0 -3
- shims/cros-libva/src/buffer.rs +7 -129
- shims/cros-libva/src/buffer/enc_jpeg.rs +0 -159
- shims/cros-libva/src/buffer/jpeg_baseline.rs +0 -220
- shims/cros-libva/src/buffer/mpeg2.rs +0 -172
- shims/cros-libva/src/buffer/vp8.rs +0 -397
- shims/cros-libva/src/lib.rs +0 -465
- shims/cros-libva/src/test_frame.nv12 +0 -0
Cargo.lockmodified+0 -1
| @@ -308,7 +308,6 @@ version = "0.0.13" | |||
| 308 | dependencies = [ | 308 | dependencies = [ |
| 309 | "bindgen", | 309 | "bindgen", |
| 310 | "bitflags 2.13.1", | 310 | "bitflags 2.13.1", |
| 311 | - "crc32fast", | ||
| 312 | "log", | 311 | "log", |
| 313 | "pkg-config", | 312 | "pkg-config", |
| 314 | "regex", | 313 | "regex", |
shims/cros-libva/Android.bpdeleted+0 -63
| @@ -1,63 +0,0 @@ | |||
| 1 | -// Copyright 2024 The ChromiumOS Authors | ||
| 2 | -// Use of this source code is governed by a BSD-style license that can be | ||
| 3 | -// found in the LICENSE file. | ||
| 4 | - | ||
| 5 | -// This file is generated by cargo_embargo. | ||
| 6 | -// Do not modify this file because the changes will be overridden on upgrade. | ||
| 7 | - | ||
| 8 | -package { | ||
| 9 | - default_applicable_licenses: ["external_rust_cros-libva_license"], | ||
| 10 | -} | ||
| 11 | - | ||
| 12 | -soong_config_module_type_import { | ||
| 13 | - from: "system/cros-codecs/Android.bp", | ||
| 14 | - module_types: [ | ||
| 15 | - "rust_defaults_cros_codecs_protected_content", | ||
| 16 | - ], | ||
| 17 | -} | ||
| 18 | - | ||
| 19 | -rust_defaults_cros_codecs_protected_content { | ||
| 20 | - name: "cros_libva_protected_content_rust_library_defaults", | ||
| 21 | - soong_config_variables: { | ||
| 22 | - intel_protected_content: { | ||
| 23 | - features: ["intel-protected-content-headers"], | ||
| 24 | - }, | ||
| 25 | - }, | ||
| 26 | -} | ||
| 27 | - | ||
| 28 | -rust_library { | ||
| 29 | - name: "libcros_libva", | ||
| 30 | - crate_name: "cros_libva", | ||
| 31 | - cargo_env_compat: true, | ||
| 32 | - cargo_pkg_version: "0.0.8", | ||
| 33 | - crate_root: "src/lib.rs", | ||
| 34 | - edition: "2021", | ||
| 35 | - defaults: ["cros_libva_protected_content_rust_library_defaults"], | ||
| 36 | - rustlibs: [ | ||
| 37 | - "libbitflags", | ||
| 38 | - "liblog_rust", | ||
| 39 | - "libthiserror", | ||
| 40 | - ], | ||
| 41 | - apex_available: [ | ||
| 42 | - "//apex_available:platform", | ||
| 43 | - "//apex_available:anyapex", | ||
| 44 | - ], | ||
| 45 | - | ||
| 46 | - cfgs: [ | ||
| 47 | - "libva_1_21_or_higher", | ||
| 48 | - "libva_1_20_or_higher", | ||
| 49 | - "libva_1_19_or_higher", | ||
| 50 | - "libva_1_16_or_higher", | ||
| 51 | - ], | ||
| 52 | - | ||
| 53 | - vendor: true, | ||
| 54 | - enabled: false, | ||
| 55 | - arch: { | ||
| 56 | - x86_64: { | ||
| 57 | - enabled: true, | ||
| 58 | - // Bindgen-generated bindings of our local libva headers. | ||
| 59 | - srcs: [":libcros_libva_bindgen"], | ||
| 60 | - shared_libs: ["libva"], | ||
| 61 | - }, | ||
| 62 | - }, | ||
| 63 | -} | ||
shims/cros-libva/Cargo.tomlmodified+0 -3
| @@ -21,6 +21,3 @@ log = { version = "0", features = ["release_max_level_debug"] } | |||
| 21 | bindgen = "0.70.1" | 21 | bindgen = "0.70.1" |
| 22 | pkg-config = "0.3.31" | 22 | pkg-config = "0.3.31" |
| 23 | regex = "1.11.1" | 23 | regex = "1.11.1" |
| 24 | - | ||
| 25 | -[dev-dependencies] | ||
| 26 | -crc32fast = "1.2.1" | ||
shims/cros-libva/src/buffer.rsmodified+7 -129
| @@ -5,25 +5,17 @@ | |||
| 5 | //! Wrappers and helpers around `VABuffer`s. | 5 | //! Wrappers and helpers around `VABuffer`s. |
| 6 | 6 | ||
| 7 | mod av1; | 7 | mod av1; |
| 8 | -mod enc_jpeg; | ||
| 9 | mod enc_misc; | 8 | mod enc_misc; |
| 10 | mod h264; | 9 | mod h264; |
| 11 | mod hevc; | 10 | mod hevc; |
| 12 | -mod jpeg_baseline; | ||
| 13 | -mod mpeg2; | ||
| 14 | mod proc_pipeline; | 11 | mod proc_pipeline; |
| 15 | -mod vp8; | ||
| 16 | mod vp9; | 12 | mod vp9; |
| 17 | 13 | ||
| 18 | pub use av1::*; | 14 | pub use av1::*; |
| 19 | -pub use enc_jpeg::*; | ||
| 20 | pub use enc_misc::*; | 15 | pub use enc_misc::*; |
| 21 | pub use h264::*; | 16 | pub use h264::*; |
| 22 | pub use hevc::*; | 17 | pub use hevc::*; |
| 23 | -pub use jpeg_baseline::*; | ||
| 24 | -pub use mpeg2::*; | ||
| 25 | pub use proc_pipeline::*; | 18 | pub use proc_pipeline::*; |
| 26 | -pub use vp8::*; | ||
| 27 | pub use vp9::*; | 19 | pub use vp9::*; |
| 28 | 20 | ||
| 29 | use std::rc::Rc; | 21 | use std::rc::Rc; |
| @@ -61,14 +53,6 @@ impl Buffer { | |||
| 61 | 53 | ||
| 62 | let (ptr, size) = match type_ { | 54 | let (ptr, size) = match type_ { |
| 63 | BufferType::PictureParameter(ref mut picture_param) => match picture_param { | 55 | BufferType::PictureParameter(ref mut picture_param) => match picture_param { |
| 64 | - PictureParameter::MPEG2(ref mut wrapper) => ( | ||
| 65 | - wrapper.inner_mut() as *mut _ as *mut std::ffi::c_void, | ||
| 66 | - std::mem::size_of_val(wrapper.inner_mut()), | ||
| 67 | - ), | ||
| 68 | - PictureParameter::VP8(ref mut wrapper) => ( | ||
| 69 | - wrapper.inner_mut() as *mut _ as *mut std::ffi::c_void, | ||
| 70 | - std::mem::size_of_val(wrapper.inner_mut()), | ||
| 71 | - ), | ||
| 72 | PictureParameter::VP9(ref mut wrapper) => ( | 56 | PictureParameter::VP9(ref mut wrapper) => ( |
| 73 | wrapper.inner_mut() as *mut _ as *mut std::ffi::c_void, | 57 | wrapper.inner_mut() as *mut _ as *mut std::ffi::c_void, |
| 74 | std::mem::size_of_val(wrapper.inner_mut()), | 58 | std::mem::size_of_val(wrapper.inner_mut()), |
| @@ -93,25 +77,9 @@ impl Buffer { | |||
| 93 | wrapper.inner_mut() as *mut _ as *mut std::ffi::c_void, | 77 | wrapper.inner_mut() as *mut _ as *mut std::ffi::c_void, |
| 94 | std::mem::size_of_val(wrapper.inner_mut()), | 78 | std::mem::size_of_val(wrapper.inner_mut()), |
| 95 | ), | 79 | ), |
| 96 | - PictureParameter::JPEGBaseline(ref mut wrapper) => ( | ||
| 97 | - wrapper.inner_mut() as *mut _ as *mut std::ffi::c_void, | ||
| 98 | - std::mem::size_of_val(wrapper.inner_mut()), | ||
| 99 | - ), | ||
| 100 | - PictureParameter::EncJPEG(ref mut wrapper) => ( | ||
| 101 | - wrapper.inner_mut() as *mut _ as *mut std::ffi::c_void, | ||
| 102 | - std::mem::size_of_val(wrapper.inner_mut()), | ||
| 103 | - ), | ||
| 104 | }, | 80 | }, |
| 105 | 81 | ||
| 106 | BufferType::SliceParameter(ref mut slice_param) => match slice_param { | 82 | BufferType::SliceParameter(ref mut slice_param) => match slice_param { |
| 107 | - SliceParameter::MPEG2(ref mut wrapper) => ( | ||
| 108 | - wrapper.inner_mut() as *mut _ as *mut std::ffi::c_void, | ||
| 109 | - std::mem::size_of_val(wrapper.inner_mut()), | ||
| 110 | - ), | ||
| 111 | - SliceParameter::VP8(ref mut wrapper) => ( | ||
| 112 | - wrapper.inner_mut() as *mut _ as *mut std::ffi::c_void, | ||
| 113 | - std::mem::size_of_val(wrapper.inner_mut()), | ||
| 114 | - ), | ||
| 115 | SliceParameter::VP9(ref mut wrapper) => ( | 83 | SliceParameter::VP9(ref mut wrapper) => ( |
| 116 | wrapper.inner_mut() as *mut _ as *mut std::ffi::c_void, | 84 | wrapper.inner_mut() as *mut _ as *mut std::ffi::c_void, |
| 117 | std::mem::size_of_val(wrapper.inner_mut()), | 85 | std::mem::size_of_val(wrapper.inner_mut()), |
| @@ -132,25 +100,9 @@ impl Buffer { | |||
| 132 | wrapper.inner_mut().as_mut_ptr() as *mut std::ffi::c_void, | 100 | wrapper.inner_mut().as_mut_ptr() as *mut std::ffi::c_void, |
| 133 | std::mem::size_of::<bindings::VASliceParameterBufferAV1>(), | 101 | std::mem::size_of::<bindings::VASliceParameterBufferAV1>(), |
| 134 | ), | 102 | ), |
| 135 | - SliceParameter::JPEGBaseline(ref mut wrapper) => ( | ||
| 136 | - wrapper.inner_mut() as *mut _ as *mut std::ffi::c_void, | ||
| 137 | - std::mem::size_of_val(wrapper.inner_mut()), | ||
| 138 | - ), | ||
| 139 | - SliceParameter::EncJpeg(ref mut wrapper) => ( | ||
| 140 | - wrapper.inner_mut() as *mut _ as *mut std::ffi::c_void, | ||
| 141 | - std::mem::size_of_val(wrapper.inner_mut()), | ||
| 142 | - ), | ||
| 143 | }, | 103 | }, |
| 144 | 104 | ||
| 145 | BufferType::IQMatrix(ref mut iq_matrix) => match iq_matrix { | 105 | BufferType::IQMatrix(ref mut iq_matrix) => match iq_matrix { |
| 146 | - IQMatrix::MPEG2(ref mut wrapper) => ( | ||
| 147 | - wrapper.inner_mut() as *mut _ as *mut std::ffi::c_void, | ||
| 148 | - std::mem::size_of_val(wrapper.inner_mut()), | ||
| 149 | - ), | ||
| 150 | - IQMatrix::VP8(ref mut wrapper) => ( | ||
| 151 | - wrapper.inner_mut() as *mut _ as *mut std::ffi::c_void, | ||
| 152 | - std::mem::size_of_val(wrapper.inner_mut()), | ||
| 153 | - ), | ||
| 154 | IQMatrix::H264(ref mut wrapper) => ( | 106 | IQMatrix::H264(ref mut wrapper) => ( |
| 155 | wrapper.inner_mut() as *mut _ as *mut std::ffi::c_void, | 107 | wrapper.inner_mut() as *mut _ as *mut std::ffi::c_void, |
| 156 | std::mem::size_of_val(wrapper.inner_mut()), | 108 | std::mem::size_of_val(wrapper.inner_mut()), |
| @@ -159,23 +111,9 @@ impl Buffer { | |||
| 159 | wrapper.inner_mut() as *mut _ as *mut std::ffi::c_void, | 111 | wrapper.inner_mut() as *mut _ as *mut std::ffi::c_void, |
| 160 | std::mem::size_of_val(wrapper.inner_mut()), | 112 | std::mem::size_of_val(wrapper.inner_mut()), |
| 161 | ), | 113 | ), |
| 162 | - IQMatrix::JPEGBaseline(ref mut wrapper) => ( | ||
| 163 | - wrapper.inner_mut() as *mut _ as *mut std::ffi::c_void, | ||
| 164 | - std::mem::size_of_val(wrapper.inner_mut()), | ||
| 165 | - ), | ||
| 166 | }, | 114 | }, |
| 167 | 115 | ||
| 168 | - BufferType::HuffmanTable(ref mut huffman_table) => match huffman_table { | ||
| 169 | - HuffmanTable::JPEGBaseline(ref mut wrapper) => ( | ||
| 170 | - wrapper.inner_mut() as *mut _ as *mut std::ffi::c_void, | ||
| 171 | - std::mem::size_of_val(wrapper.inner_mut()), | ||
| 172 | - ), | ||
| 173 | - }, | ||
| 174 | 116 | ||
| 175 | - BufferType::Probability(ref mut wrapper) => ( | ||
| 176 | - wrapper.inner_mut() as *mut _ as *mut std::ffi::c_void, | ||
| 177 | - std::mem::size_of_val(wrapper.inner_mut()), | ||
| 178 | - ), | ||
| 179 | 117 | ||
| 180 | BufferType::SliceData(ref mut data) => { | 118 | BufferType::SliceData(ref mut data) => { |
| 181 | (data.as_mut_ptr() as *mut std::ffi::c_void, data.len()) | 119 | (data.as_mut_ptr() as *mut std::ffi::c_void, data.len()) |
| @@ -190,10 +128,6 @@ impl Buffer { | |||
| 190 | wrapper.inner_mut() as *mut _ as *mut std::ffi::c_void, | 128 | wrapper.inner_mut() as *mut _ as *mut std::ffi::c_void, |
| 191 | std::mem::size_of_val(wrapper.inner_mut()), | 129 | std::mem::size_of_val(wrapper.inner_mut()), |
| 192 | ), | 130 | ), |
| 193 | - EncSequenceParameter::VP8(ref mut wrapper) => ( | ||
| 194 | - wrapper.inner_mut() as *mut _ as *mut std::ffi::c_void, | ||
| 195 | - std::mem::size_of_val(wrapper.inner_mut()), | ||
| 196 | - ), | ||
| 197 | EncSequenceParameter::VP9(ref mut wrapper) => ( | 131 | EncSequenceParameter::VP9(ref mut wrapper) => ( |
| 198 | wrapper.inner_mut() as *mut _ as *mut std::ffi::c_void, | 132 | wrapper.inner_mut() as *mut _ as *mut std::ffi::c_void, |
| 199 | std::mem::size_of_val(wrapper.inner_mut()), | 133 | std::mem::size_of_val(wrapper.inner_mut()), |
| @@ -213,10 +147,6 @@ impl Buffer { | |||
| 213 | wrapper.inner_mut() as *mut _ as *mut std::ffi::c_void, | 147 | wrapper.inner_mut() as *mut _ as *mut std::ffi::c_void, |
| 214 | std::mem::size_of_val(wrapper.inner_mut()), | 148 | std::mem::size_of_val(wrapper.inner_mut()), |
| 215 | ), | 149 | ), |
| 216 | - EncPictureParameter::VP8(ref mut wrapper) => ( | ||
| 217 | - wrapper.inner_mut() as *mut _ as *mut std::ffi::c_void, | ||
| 218 | - std::mem::size_of_val(wrapper.inner_mut()), | ||
| 219 | - ), | ||
| 220 | EncPictureParameter::VP9(ref mut wrapper) => ( | 150 | EncPictureParameter::VP9(ref mut wrapper) => ( |
| 221 | wrapper.inner_mut() as *mut _ as *mut std::ffi::c_void, | 151 | wrapper.inner_mut() as *mut _ as *mut std::ffi::c_void, |
| 222 | std::mem::size_of_val(wrapper.inner_mut()), | 152 | std::mem::size_of_val(wrapper.inner_mut()), |
| @@ -289,12 +219,6 @@ impl Buffer { | |||
| 289 | proc_pipeline_param.inner_mut() as *mut _ as *mut std::ffi::c_void, | 219 | proc_pipeline_param.inner_mut() as *mut _ as *mut std::ffi::c_void, |
| 290 | std::mem::size_of_val(proc_pipeline_param.inner_mut()), | 220 | std::mem::size_of_val(proc_pipeline_param.inner_mut()), |
| 291 | ), | 221 | ), |
| 292 | - BufferType::QMatrix(ref mut q_matrix) => match q_matrix { | ||
| 293 | - QMatrix::JPEG(ref mut wrapper) => ( | ||
| 294 | - wrapper.inner_mut() as *mut _ as *mut std::ffi::c_void, | ||
| 295 | - std::mem::size_of_val(wrapper.inner_mut()), | ||
| 296 | - ), | ||
| 297 | - }, | ||
| 298 | BufferType::EncPackedHeaderParameter(ref mut wrapper) => ( | 222 | BufferType::EncPackedHeaderParameter(ref mut wrapper) => ( |
| 299 | wrapper.inner_mut() as *mut _ as *mut std::ffi::c_void, | 223 | wrapper.inner_mut() as *mut _ as *mut std::ffi::c_void, |
| 300 | std::mem::size_of_val(wrapper.inner_mut()), | 224 | std::mem::size_of_val(wrapper.inner_mut()), |
| @@ -419,34 +343,28 @@ impl Drop for Buffer { | |||
| 419 | 343 | ||
| 420 | /// Abstraction over `VABufferType`s. | 344 | /// Abstraction over `VABufferType`s. |
| 421 | pub enum BufferType { | 345 | pub enum BufferType { |
| 422 | - /// Abstraction over `VAPictureParameterBufferType`. Needed for MPEG2, VP8, VP9, H264, JPEGBaseline. | 346 | + /// Abstraction over `VAPictureParameterBufferType`. Needed for VP9, H264. |
| 423 | PictureParameter(PictureParameter), | 347 | PictureParameter(PictureParameter), |
| 424 | - /// Abstraction over `VASliceParameterBufferType`. Needed for MPEG2, VP8, VP9, H264, JPEGBaseline. | 348 | + /// Abstraction over `VASliceParameterBufferType`. Needed for VP9, H264. |
| 425 | SliceParameter(SliceParameter), | 349 | SliceParameter(SliceParameter), |
| 426 | - /// Abstraction over `VAIQMatrixBufferType`. Needed for VP8, H264, JPEGBaseline. | 350 | + /// Abstraction over `VAIQMatrixBufferType`. Needed for H264. |
| 427 | IQMatrix(IQMatrix), | 351 | IQMatrix(IQMatrix), |
| 428 | - /// Abstraction over `HuffmanTableBufferType`. Needed for JPEGBaseline. | ||
| 429 | - HuffmanTable(HuffmanTable), | ||
| 430 | - /// Abstraction over `VAProbabilityDataBufferType`. Needed for VP8. | ||
| 431 | - Probability(vp8::ProbabilityDataBufferVP8), | ||
| 432 | /// Abstraction over `VASliceDataBufferType`. Needed for VP9, H264. | 352 | /// Abstraction over `VASliceDataBufferType`. Needed for VP9, H264. |
| 433 | SliceData(Vec<u8>), | 353 | SliceData(Vec<u8>), |
| 434 | - /// Abstraction over `VAEncSequenceParameterBufferType`. Needed for MPEG2, VP8, VP9, H264, HEVC. | 354 | + /// Abstraction over `VAEncSequenceParameterBufferType`. Needed for VP9, H264, HEVC. |
| 435 | EncSequenceParameter(EncSequenceParameter), | 355 | EncSequenceParameter(EncSequenceParameter), |
| 436 | - /// Abstraction over `VAEncPictureParameterBufferType`. Needed for MPEG2, VP8, VP9, H264, HEVC. | 356 | + /// Abstraction over `VAEncPictureParameterBufferType`. Needed for VP9, H264, HEVC. |
| 437 | EncPictureParameter(EncPictureParameter), | 357 | EncPictureParameter(EncPictureParameter), |
| 438 | - /// Abstraction over `VAEncSliceParameterBufferType`. Needed for MPEG2, VP8, VP9, H264, HEVC. | 358 | + /// Abstraction over `VAEncSliceParameterBufferType`. Needed for VP9, H264, HEVC. |
| 439 | EncSliceParameter(EncSliceParameter), | 359 | EncSliceParameter(EncSliceParameter), |
| 440 | /// Abstraction over `VAEncMacroblockMapBufferType`. Needed for H264. | 360 | /// Abstraction over `VAEncMacroblockMapBufferType`. Needed for H264. |
| 441 | EncMacroblockParameterBuffer(EncMacroblockParameterBuffer), | 361 | EncMacroblockParameterBuffer(EncMacroblockParameterBuffer), |
| 442 | - /// Abstraction over `VAEncCodedBufferType`. Needed for MPEG2, VP8, VP9, H264, HEVC. | 362 | + /// Abstraction over `VAEncCodedBufferType`. Needed for VP9, H264, HEVC. |
| 443 | EncCodedBuffer(usize), | 363 | EncCodedBuffer(usize), |
| 444 | /// Abstraction over `VAEncMiscParameterBuffer`. | 364 | /// Abstraction over `VAEncMiscParameterBuffer`. |
| 445 | EncMiscParameter(EncMiscParameter), | 365 | EncMiscParameter(EncMiscParameter), |
| 446 | /// Abstraction over `VAProcPipelineParameterBuffer`. | 366 | /// Abstraction over `VAProcPipelineParameterBuffer`. |
| 447 | ProcPipelineParameter(proc_pipeline::ProcPipelineParameterBuffer), | 367 | ProcPipelineParameter(proc_pipeline::ProcPipelineParameterBuffer), |
| 448 | - /// Abstraction over `VAQMatrixBufferType`. | ||
| 449 | - QMatrix(QMatrix), | ||
| 450 | /// Abstraction over `VAEncPackedHeaderParameterBufferType`. | 368 | /// Abstraction over `VAEncPackedHeaderParameterBufferType`. |
| 451 | EncPackedHeaderParameter(EncPackedHeaderParameter), | 369 | EncPackedHeaderParameter(EncPackedHeaderParameter), |
| 452 | /// Abstraction over `VAEncPackedHeaderDataBufferType`. | 370 | /// Abstraction over `VAEncPackedHeaderDataBufferType`. |
| @@ -460,8 +378,6 @@ impl BufferType { | |||
| 460 | BufferType::PictureParameter(_) => bindings::VABufferType::VAPictureParameterBufferType, | 378 | BufferType::PictureParameter(_) => bindings::VABufferType::VAPictureParameterBufferType, |
| 461 | BufferType::SliceParameter(_) => bindings::VABufferType::VASliceParameterBufferType, | 379 | BufferType::SliceParameter(_) => bindings::VABufferType::VASliceParameterBufferType, |
| 462 | BufferType::IQMatrix(_) => bindings::VABufferType::VAIQMatrixBufferType, | 380 | BufferType::IQMatrix(_) => bindings::VABufferType::VAIQMatrixBufferType, |
| 463 | - BufferType::HuffmanTable(_) => bindings::VABufferType::VAHuffmanTableBufferType, | ||
| 464 | - BufferType::Probability(_) => bindings::VABufferType::VAProbabilityBufferType, | ||
| 465 | BufferType::SliceData { .. } => bindings::VABufferType::VASliceDataBufferType, | 381 | BufferType::SliceData { .. } => bindings::VABufferType::VASliceDataBufferType, |
| 466 | 382 | ||
| 467 | BufferType::EncSequenceParameter(_) => { | 383 | BufferType::EncSequenceParameter(_) => { |
| @@ -488,7 +404,6 @@ impl BufferType { | |||
| 488 | bindings::VABufferType::VAProcPipelineParameterBufferType | 404 | bindings::VABufferType::VAProcPipelineParameterBufferType |
| 489 | } | 405 | } |
| 490 | 406 | ||
| 491 | - BufferType::QMatrix(_) => bindings::VABufferType::VAQMatrixBufferType, | ||
| 492 | 407 | ||
| 493 | BufferType::EncPackedHeaderParameter(_) => { | 408 | BufferType::EncPackedHeaderParameter(_) => { |
| 494 | bindings::VABufferType::VAEncPackedHeaderParameterBufferType | 409 | bindings::VABufferType::VAEncPackedHeaderParameterBufferType |
| @@ -503,10 +418,6 @@ impl BufferType { | |||
| 503 | 418 | ||
| 504 | /// Abstraction over the `PictureParameterBuffer` types we support. | 419 | /// Abstraction over the `PictureParameterBuffer` types we support. |
| 505 | pub enum PictureParameter { | 420 | pub enum PictureParameter { |
| 506 | - /// Wrapper over VAPictureParameterBufferMPEG2. | ||
| 507 | - MPEG2(mpeg2::PictureParameterBufferMPEG2), | ||
| 508 | - /// Wrapper over VAPictureParameterBufferVP8. | ||
| 509 | - VP8(vp8::PictureParameterBufferVP8), | ||
| 510 | /// Wrapper over VAPictureParameterBufferVP9. | 421 | /// Wrapper over VAPictureParameterBufferVP9. |
| 511 | VP9(vp9::PictureParameterBufferVP9), | 422 | VP9(vp9::PictureParameterBufferVP9), |
| 512 | /// Wrapper over VAPictureParameterBufferH264. | 423 | /// Wrapper over VAPictureParameterBufferH264. |
| @@ -519,18 +430,10 @@ pub enum PictureParameter { | |||
| 519 | HEVCScc(hevc::PictureParameterBufferHEVCScc), | 430 | HEVCScc(hevc::PictureParameterBufferHEVCScc), |
| 520 | /// Wrapper over VADecPictureParameterBufferAV1 | 431 | /// Wrapper over VADecPictureParameterBufferAV1 |
| 521 | AV1(av1::PictureParameterBufferAV1), | 432 | AV1(av1::PictureParameterBufferAV1), |
| 522 | - /// Wrapper over VAPictureParameterBufferJPEGBaseline | ||
| 523 | - JPEGBaseline(jpeg_baseline::PictureParameterBufferJPEGBaseline), | ||
| 524 | - /// Wrapper over VAEncPictureParameterBufferJPEG | ||
| 525 | - EncJPEG(enc_jpeg::EncPictureParameterBufferJPEG), | ||
| 526 | } | 433 | } |
| 527 | 434 | ||
| 528 | /// Abstraction over the `SliceParameterBuffer` types we support | 435 | /// Abstraction over the `SliceParameterBuffer` types we support |
| 529 | pub enum SliceParameter { | 436 | pub enum SliceParameter { |
| 530 | - /// Wrapper over VASliceParameterBufferMPEG2 | ||
| 531 | - MPEG2(mpeg2::SliceParameterBufferMPEG2), | ||
| 532 | - /// Wrapper over VASliceParameterBufferVP8 | ||
| 533 | - VP8(vp8::SliceParameterBufferVP8), | ||
| 534 | /// Wrapper over VASliceParameterBufferVP9 | 437 | /// Wrapper over VASliceParameterBufferVP9 |
| 535 | VP9(vp9::SliceParameterBufferVP9), | 438 | VP9(vp9::SliceParameterBufferVP9), |
| 536 | /// Wrapper over VASliceParameterBufferH264 | 439 | /// Wrapper over VASliceParameterBufferH264 |
| @@ -541,37 +444,16 @@ pub enum SliceParameter { | |||
| 541 | HEVCRext(hevc::SliceParameterBufferHEVCRext), | 444 | HEVCRext(hevc::SliceParameterBufferHEVCRext), |
| 542 | /// Wrapper over VASliceParameterBufferAV1 | 445 | /// Wrapper over VASliceParameterBufferAV1 |
| 543 | AV1(av1::SliceParameterBufferAV1), | 446 | AV1(av1::SliceParameterBufferAV1), |
| 544 | - /// Wrapper over VASliceParameterBufferJPEGBaseline | ||
| 545 | - JPEGBaseline(jpeg_baseline::SliceParameterBufferJPEGBaseline), | ||
| 546 | - /// Wrapper over VAEncSliceParameterBufferJPEG | ||
| 547 | - EncJpeg(enc_jpeg::EncSliceParameterBufferJPEG), | ||
| 548 | } | 447 | } |
| 549 | 448 | ||
| 550 | /// Abstraction over the `IQMatrixBuffer` types we support. | 449 | /// Abstraction over the `IQMatrixBuffer` types we support. |
| 551 | pub enum IQMatrix { | 450 | pub enum IQMatrix { |
| 552 | - /// Abstraction over `VAIQMatrixBufferMPEG2` | ||
| 553 | - MPEG2(mpeg2::IQMatrixBufferMPEG2), | ||
| 554 | - /// Abstraction over `VAIQMatrixBufferVP8` | ||
| 555 | - VP8(vp8::IQMatrixBufferVP8), | ||
| 556 | /// Abstraction over `VAIQMatrixBufferH264` | 451 | /// Abstraction over `VAIQMatrixBufferH264` |
| 557 | H264(h264::IQMatrixBufferH264), | 452 | H264(h264::IQMatrixBufferH264), |
| 558 | /// Abstraction over `VAIQMatrixBufferHEVC` | 453 | /// Abstraction over `VAIQMatrixBufferHEVC` |
| 559 | HEVC(hevc::IQMatrixBufferHEVC), | 454 | HEVC(hevc::IQMatrixBufferHEVC), |
| 560 | - /// Abstraction over `VAIQMatrixBufferJPEGBaseline`` | ||
| 561 | - JPEGBaseline(jpeg_baseline::IQMatrixBufferJPEGBaseline), | ||
| 562 | } | 455 | } |
| 563 | 456 | ||
| 564 | -/// Abstraction over the `HuffmanTable` types we support. | ||
| 565 | -pub enum HuffmanTable { | ||
| 566 | - /// Abstraction over `VAHuffmanTableBufferJPEGBaseline` | ||
| 567 | - JPEGBaseline(jpeg_baseline::HuffmanTableBufferJPEGBaseline), | ||
| 568 | -} | ||
| 569 | - | ||
| 570 | -/// Abstraction over the `QMatrix` types we support. | ||
| 571 | -pub enum QMatrix { | ||
| 572 | - /// Abstraction over `VAQMatrixBufferJPEG` | ||
| 573 | - JPEG(enc_jpeg::QMatrixBufferJPEG), | ||
| 574 | -} | ||
| 575 | 457 | ||
| 576 | /// Abstraction over the `EncSequenceParameter` types we support. | 458 | /// Abstraction over the `EncSequenceParameter` types we support. |
| 577 | pub enum EncSequenceParameter { | 459 | pub enum EncSequenceParameter { |
| @@ -579,8 +461,6 @@ pub enum EncSequenceParameter { | |||
| 579 | H264(h264::EncSequenceParameterBufferH264), | 461 | H264(h264::EncSequenceParameterBufferH264), |
| 580 | /// Abstraction over `VAEncSequenceParameterBufferHEVC` | 462 | /// Abstraction over `VAEncSequenceParameterBufferHEVC` |
| 581 | HEVC(hevc::EncSequenceParameterBufferHEVC), | 463 | HEVC(hevc::EncSequenceParameterBufferHEVC), |
| 582 | - /// Abstraction over `VAEncSequenceParameterBufferVP8` | ||
| 583 | - VP8(vp8::EncSequenceParameterBufferVP8), | ||
| 584 | /// Abstraction over `VAEncSequenceParameterBufferVP9` | 464 | /// Abstraction over `VAEncSequenceParameterBufferVP9` |
| 585 | VP9(vp9::EncSequenceParameterBufferVP9), | 465 | VP9(vp9::EncSequenceParameterBufferVP9), |
| 586 | /// Abstraction over `VAEncSequenceParameterBufferAV1` | 466 | /// Abstraction over `VAEncSequenceParameterBufferAV1` |
| @@ -593,8 +473,6 @@ pub enum EncPictureParameter { | |||
| 593 | H264(h264::EncPictureParameterBufferH264), | 473 | H264(h264::EncPictureParameterBufferH264), |
| 594 | /// Abstraction over `VAEncPictureParameterBufferHEVC` | 474 | /// Abstraction over `VAEncPictureParameterBufferHEVC` |
| 595 | HEVC(hevc::EncPictureParameterBufferHEVC), | 475 | HEVC(hevc::EncPictureParameterBufferHEVC), |
| 596 | - /// Abstraction over `VAEncPictureParameterBufferVP8` | ||
| 597 | - VP8(vp8::EncPictureParameterBufferVP8), | ||
| 598 | /// Abstraction over `VAEncPictureParameterBufferVP9` | 476 | /// Abstraction over `VAEncPictureParameterBufferVP9` |
| 599 | VP9(vp9::EncPictureParameterBufferVP9), | 477 | VP9(vp9::EncPictureParameterBufferVP9), |
| 600 | /// Abstraction over `VAEncPictureParameterBufferAV1` | 478 | /// Abstraction over `VAEncPictureParameterBufferAV1` |
shims/cros-libva/src/buffer/enc_jpeg.rsdeleted+0 -159
| @@ -1,159 +0,0 @@ | |||
| 1 | -// Copyright 2025 The ChromiumOS Authors | ||
| 2 | -// Use of this source code is governed by a BSD-style license that can be | ||
| 3 | -// found in the LICENSE file. | ||
| 4 | - | ||
| 5 | -//! Wrappers around JPEG-Encoding `VABuffer` types. | ||
| 6 | - | ||
| 7 | -use crate::bindings; | ||
| 8 | - | ||
| 9 | -/// Wrapper over the `pic_flags` bindgen field in `VAEncPictureParameterBufferJPEG` | ||
| 10 | -pub struct PicFlags(bindings::_VAEncPictureParameterBufferJPEG__bindgen_ty_1); | ||
| 11 | - | ||
| 12 | -impl PicFlags { | ||
| 13 | - pub fn new( | ||
| 14 | - profile: u32, | ||
| 15 | - progressive: u32, | ||
| 16 | - huffman: u32, | ||
| 17 | - interleaved: u32, | ||
| 18 | - differential: u32, | ||
| 19 | - ) -> Self { | ||
| 20 | - let _bitfield_1 = | ||
| 21 | - bindings::_VAEncPictureParameterBufferJPEG__bindgen_ty_1__bindgen_ty_1::new_bitfield_1( | ||
| 22 | - profile, | ||
| 23 | - progressive, | ||
| 24 | - huffman, | ||
| 25 | - interleaved, | ||
| 26 | - differential, | ||
| 27 | - ); | ||
| 28 | - Self(bindings::_VAEncPictureParameterBufferJPEG__bindgen_ty_1 { | ||
| 29 | - bits: bindings::_VAEncPictureParameterBufferJPEG__bindgen_ty_1__bindgen_ty_1 { | ||
| 30 | - _bitfield_align_1: Default::default(), | ||
| 31 | - _bitfield_1, | ||
| 32 | - __bindgen_padding_0: Default::default(), | ||
| 33 | - }, | ||
| 34 | - }) | ||
| 35 | - } | ||
| 36 | -} | ||
| 37 | - | ||
| 38 | -/// Wrapper over the `VAEncPictureParameterBufferJPEG` FFI type. | ||
| 39 | -pub struct EncPictureParameterBufferJPEG(Box<bindings::VAEncPictureParameterBufferJPEG>); | ||
| 40 | - | ||
| 41 | -impl EncPictureParameterBufferJPEG { | ||
| 42 | - /// Creates the wrapper. | ||
| 43 | - pub fn new( | ||
| 44 | - reconstructed_picture: bindings::VASurfaceID, | ||
| 45 | - picture_width: u16, | ||
| 46 | - picture_height: u16, | ||
| 47 | - coded_buf: bindings::VABufferID, | ||
| 48 | - pic_flags: PicFlags, | ||
| 49 | - sample_bit_depth: u8, | ||
| 50 | - num_scan: u8, | ||
| 51 | - num_components: u16, | ||
| 52 | - component_id: [u8; 4usize], | ||
| 53 | - quantiser_table_selector: [u8; 4usize], | ||
| 54 | - quality: u8, | ||
| 55 | - ) -> Self { | ||
| 56 | - Self(Box::new(bindings::VAEncPictureParameterBufferJPEG { | ||
| 57 | - reconstructed_picture, | ||
| 58 | - picture_width, | ||
| 59 | - picture_height, | ||
| 60 | - coded_buf, | ||
| 61 | - pic_flags: pic_flags.0, | ||
| 62 | - sample_bit_depth, | ||
| 63 | - num_scan, | ||
| 64 | - num_components, | ||
| 65 | - component_id, | ||
| 66 | - quantiser_table_selector, | ||
| 67 | - quality, | ||
| 68 | - va_reserved: Default::default(), | ||
| 69 | - })) | ||
| 70 | - } | ||
| 71 | - | ||
| 72 | - pub(crate) fn inner_mut(&mut self) -> &mut bindings::VAEncPictureParameterBufferJPEG { | ||
| 73 | - self.0.as_mut() | ||
| 74 | - } | ||
| 75 | - | ||
| 76 | - /// Returns the inner FFI type. Useful for testing purposes. | ||
| 77 | - pub fn inner(&self) -> &bindings::VAEncPictureParameterBufferJPEG { | ||
| 78 | - self.0.as_ref() | ||
| 79 | - } | ||
| 80 | -} | ||
| 81 | - | ||
| 82 | -/// Wrapper over the `components` bindgen field in `VAEncSliceParameterBufferJPEG`. | ||
| 83 | -pub struct EncSliceParameterBufferJPEGComponent( | ||
| 84 | - bindings::_VAEncSliceParameterBufferJPEG__bindgen_ty_1, | ||
| 85 | -); | ||
| 86 | - | ||
| 87 | -impl EncSliceParameterBufferJPEGComponent { | ||
| 88 | - /// Creates the bindgen field. | ||
| 89 | - pub fn new(component_selector: u8, dc_table_selector: u8, ac_table_selector: u8) -> Self { | ||
| 90 | - Self(bindings::_VAEncSliceParameterBufferJPEG__bindgen_ty_1 { | ||
| 91 | - component_selector, | ||
| 92 | - dc_table_selector, | ||
| 93 | - ac_table_selector, | ||
| 94 | - }) | ||
| 95 | - } | ||
| 96 | - | ||
| 97 | - /// Returns the inner FFI type. Useful for testing purposes. | ||
| 98 | - pub fn inner(&self) -> &bindings::_VAEncSliceParameterBufferJPEG__bindgen_ty_1 { | ||
| 99 | - &self.0 | ||
| 100 | - } | ||
| 101 | -} | ||
| 102 | - | ||
| 103 | -/// Wrapper over the `VAEncSliceParameterBufferJPEG` FFI type. | ||
| 104 | -pub struct EncSliceParameterBufferJPEG(Box<bindings::VAEncSliceParameterBufferJPEG>); | ||
| 105 | - | ||
| 106 | -impl EncSliceParameterBufferJPEG { | ||
| 107 | - /// Creates the wrapper. | ||
| 108 | - pub fn new( | ||
| 109 | - restart_interval: u16, | ||
| 110 | - num_components: u16, | ||
| 111 | - components: [EncSliceParameterBufferJPEGComponent; 4usize], | ||
| 112 | - ) -> Self { | ||
| 113 | - Self(Box::new(bindings::VAEncSliceParameterBufferJPEG { | ||
| 114 | - restart_interval, | ||
| 115 | - num_components, | ||
| 116 | - components: components.map(|component| component.0), | ||
| 117 | - va_reserved: Default::default(), | ||
| 118 | - })) | ||
| 119 | - } | ||
| 120 | - | ||
| 121 | - pub(crate) fn inner_mut(&mut self) -> &mut bindings::VAEncSliceParameterBufferJPEG { | ||
| 122 | - self.0.as_mut() | ||
| 123 | - } | ||
| 124 | - | ||
| 125 | - /// Returns the inner FFI type. Useful for testing purposes. | ||
| 126 | - pub fn inner(&self) -> &bindings::VAEncSliceParameterBufferJPEG { | ||
| 127 | - self.0.as_ref() | ||
| 128 | - } | ||
| 129 | -} | ||
| 130 | - | ||
| 131 | -/// Wrapper over the `VAQMatrixBufferJPEG` FFI type. | ||
| 132 | -pub struct QMatrixBufferJPEG(Box<bindings::VAQMatrixBufferJPEG>); | ||
| 133 | - | ||
| 134 | -impl QMatrixBufferJPEG { | ||
| 135 | - /// Creates the wrapper. | ||
| 136 | - pub fn new( | ||
| 137 | - load_lum_quantiser_matrix: i32, | ||
| 138 | - load_chroma_quantiser_matrix: i32, | ||
| 139 | - lum_quantiser_matrix: [u8; 64usize], | ||
| 140 | - chroma_quantiser_matrix: [u8; 64usize], | ||
| 141 | - ) -> Self { | ||
| 142 | - Self(Box::new(bindings::VAQMatrixBufferJPEG { | ||
| 143 | - load_lum_quantiser_matrix, | ||
| 144 | - load_chroma_quantiser_matrix, | ||
| 145 | - lum_quantiser_matrix, | ||
| 146 | - chroma_quantiser_matrix, | ||
| 147 | - va_reserved: Default::default(), | ||
| 148 | - })) | ||
| 149 | - } | ||
| 150 | - | ||
| 151 | - pub(crate) fn inner_mut(&mut self) -> &mut bindings::VAQMatrixBufferJPEG { | ||
| 152 | - self.0.as_mut() | ||
| 153 | - } | ||
| 154 | - | ||
| 155 | - /// Returns the inner FFI type. Useful for testing purposes. | ||
| 156 | - pub fn inner(&self) -> &bindings::VAQMatrixBufferJPEG { | ||
| 157 | - self.0.as_ref() | ||
| 158 | - } | ||
| 159 | -} | ||
shims/cros-libva/src/buffer/jpeg_baseline.rsdeleted+0 -220
| @@ -1,220 +0,0 @@ | |||
| 1 | -// Copyright 2025 The ChromiumOS Authors | ||
| 2 | -// Use of this source code is governed by a BSD-style license that can be | ||
| 3 | -// found in the LICENSE file. | ||
| 4 | - | ||
| 5 | -//! Wrappers around JPEGBaseline `VABuffer` types. | ||
| 6 | - | ||
| 7 | -use crate::bindings; | ||
| 8 | - | ||
| 9 | -/// Wrapper over the `components` bindgen field in `VAPictureParameterBufferJPEGBaseline`. | ||
| 10 | -pub struct PictureParameterBufferJPEGBaselineComponent( | ||
| 11 | - bindings::_VAPictureParameterBufferJPEGBaseline__bindgen_ty_1, | ||
| 12 | -); | ||
| 13 | - | ||
| 14 | -impl PictureParameterBufferJPEGBaselineComponent { | ||
| 15 | - /// Creates the bindgen field. | ||
| 16 | - #[allow(clippy::too_many_arguments)] | ||
| 17 | - pub fn new( | ||
| 18 | - component_id: u8, | ||
| 19 | - h_sampling_factor: u8, | ||
| 20 | - v_sampling_factor: u8, | ||
| 21 | - quantiser_table_selector: u8, | ||
| 22 | - ) -> Self { | ||
| 23 | - Self( | ||
| 24 | - bindings::_VAPictureParameterBufferJPEGBaseline__bindgen_ty_1 { | ||
| 25 | - component_id, | ||
| 26 | - h_sampling_factor, | ||
| 27 | - v_sampling_factor, | ||
| 28 | - quantiser_table_selector, | ||
| 29 | - }, | ||
| 30 | - ) | ||
| 31 | - } | ||
| 32 | - | ||
| 33 | - /// Returns the inner FFI type. Useful for testing purposes. | ||
| 34 | - pub fn inner(&mut self) -> &bindings::_VAPictureParameterBufferJPEGBaseline__bindgen_ty_1 { | ||
| 35 | - &self.0 | ||
| 36 | - } | ||
| 37 | -} | ||
| 38 | - | ||
| 39 | -/// Wrapper over the `VAPictureParameterBufferJPEGBaseline` FFI type. | ||
| 40 | -pub struct PictureParameterBufferJPEGBaseline(Box<bindings::VAPictureParameterBufferJPEGBaseline>); | ||
| 41 | - | ||
| 42 | -impl PictureParameterBufferJPEGBaseline { | ||
| 43 | - /// Creates the wrapper. | ||
| 44 | - pub fn new( | ||
| 45 | - picture_width: u16, | ||
| 46 | - picture_height: u16, | ||
| 47 | - components: [PictureParameterBufferJPEGBaselineComponent; 255usize], | ||
| 48 | - num_components: u8, | ||
| 49 | - color_space: u8, | ||
| 50 | - rotation: u32, | ||
| 51 | - crop_rectangle: bindings::VARectangle, | ||
| 52 | - ) -> Self { | ||
| 53 | - Self(Box::new(bindings::VAPictureParameterBufferJPEGBaseline { | ||
| 54 | - picture_width, | ||
| 55 | - picture_height, | ||
| 56 | - components: components.map(|component| component.0), | ||
| 57 | - num_components, | ||
| 58 | - color_space, | ||
| 59 | - rotation, | ||
| 60 | - crop_rectangle, | ||
| 61 | - va_reserved: Default::default(), | ||
| 62 | - })) | ||
| 63 | - } | ||
| 64 | - | ||
| 65 | - pub(crate) fn inner_mut(&mut self) -> &mut bindings::VAPictureParameterBufferJPEGBaseline { | ||
| 66 | - self.0.as_mut() | ||
| 67 | - } | ||
| 68 | - | ||
| 69 | - /// Returns the inner FFI type. Useful for testing purposes. | ||
| 70 | - pub fn inner(&mut self) -> &bindings::VAPictureParameterBufferJPEGBaseline { | ||
| 71 | - self.0.as_ref() | ||
| 72 | - } | ||
| 73 | -} | ||
| 74 | - | ||
| 75 | -/// Wrapper over the `components` bindgen field in `VASliceParameterBufferJPEGBaseline`. | ||
| 76 | -pub struct VASliceParameterBufferJPEGBaselineComponent( | ||
| 77 | - bindings::_VASliceParameterBufferJPEGBaseline__bindgen_ty_1, | ||
| 78 | -); | ||
| 79 | - | ||
| 80 | -impl VASliceParameterBufferJPEGBaselineComponent { | ||
| 81 | - /// Creates the bindgen field. | ||
| 82 | - #[allow(clippy::too_many_arguments)] | ||
| 83 | - pub fn new(component_selector: u8, dc_table_selector: u8, ac_table_selector: u8) -> Self { | ||
| 84 | - Self( | ||
| 85 | - bindings::_VASliceParameterBufferJPEGBaseline__bindgen_ty_1 { | ||
| 86 | - component_selector, | ||
| 87 | - dc_table_selector, | ||
| 88 | - ac_table_selector, | ||
| 89 | - }, | ||
| 90 | - ) | ||
| 91 | - } | ||
| 92 | - | ||
| 93 | - /// Returns the inner FFI type. Useful for testing purposes. | ||
| 94 | - pub fn inner(&mut self) -> &bindings::_VASliceParameterBufferJPEGBaseline__bindgen_ty_1 { | ||
| 95 | - &self.0 | ||
| 96 | - } | ||
| 97 | -} | ||
| 98 | - | ||
| 99 | -/// Wrapper over the `VASliceParameterBufferJPEGBaseline` FFI type. | ||
| 100 | -pub struct SliceParameterBufferJPEGBaseline(Box<bindings::VASliceParameterBufferJPEGBaseline>); | ||
| 101 | - | ||
| 102 | -impl SliceParameterBufferJPEGBaseline { | ||
| 103 | - /// Creates the wrapper. | ||
| 104 | - pub fn new( | ||
| 105 | - slice_data_size: u32, | ||
| 106 | - slice_data_offset: u32, | ||
| 107 | - slice_data_flag: u32, | ||
| 108 | - slice_horizontal_position: u32, | ||
| 109 | - slice_vertical_position: u32, | ||
| 110 | - components: [VASliceParameterBufferJPEGBaselineComponent; 4usize], | ||
| 111 | - num_components: u8, | ||
| 112 | - restart_interval: u16, | ||
| 113 | - num_mcus: u32, | ||
| 114 | - ) -> Self { | ||
| 115 | - Self(Box::new(bindings::VASliceParameterBufferJPEGBaseline { | ||
| 116 | - slice_data_size, | ||
| 117 | - slice_data_offset, | ||
| 118 | - slice_data_flag, | ||
| 119 | - slice_horizontal_position, | ||
| 120 | - slice_vertical_position, | ||
| 121 | - components: components.map(|component| component.0), | ||
| 122 | - num_components, | ||
| 123 | - restart_interval, | ||
| 124 | - num_mcus, | ||
| 125 | - va_reserved: Default::default(), | ||
| 126 | - })) | ||
| 127 | - } | ||
| 128 | - | ||
| 129 | - pub(crate) fn inner_mut(&mut self) -> &mut bindings::VASliceParameterBufferJPEGBaseline { | ||
| 130 | - self.0.as_mut() | ||
| 131 | - } | ||
| 132 | - | ||
| 133 | - /// Returns the inner FFI type. Useful for testing purposes. | ||
| 134 | - pub fn inner(&mut self) -> &bindings::VASliceParameterBufferJPEGBaseline { | ||
| 135 | - self.0.as_ref() | ||
| 136 | - } | ||
| 137 | -} | ||
| 138 | - | ||
| 139 | -/// Wrapper over the `VAIQMatrixBufferJPEGBaseline` FFI type. | ||
| 140 | -pub struct IQMatrixBufferJPEGBaseline(Box<bindings::VAIQMatrixBufferJPEGBaseline>); | ||
| 141 | - | ||
| 142 | -impl IQMatrixBufferJPEGBaseline { | ||
| 143 | - /// Creates the wrapper. | ||
| 144 | - #[allow(clippy::too_many_arguments)] | ||
| 145 | - pub fn new( | ||
| 146 | - load_quantiser_table: [u8; 4usize], | ||
| 147 | - quantiser_table: [[u8; 64usize]; 4usize], | ||
| 148 | - ) -> Self { | ||
| 149 | - Self(Box::new(bindings::VAIQMatrixBufferJPEGBaseline { | ||
| 150 | - load_quantiser_table, | ||
| 151 | - quantiser_table, | ||
| 152 | - va_reserved: Default::default(), | ||
| 153 | - })) | ||
| 154 | - } | ||
| 155 | - | ||
| 156 | - pub(crate) fn inner_mut(&mut self) -> &mut bindings::VAIQMatrixBufferJPEGBaseline { | ||
| 157 | - self.0.as_mut() | ||
| 158 | - } | ||
| 159 | - | ||
| 160 | - /// Returns the inner FFI type. Useful for testing purposes. | ||
| 161 | - pub fn inner(&self) -> &bindings::VAIQMatrixBufferJPEGBaseline { | ||
| 162 | - self.0.as_ref() | ||
| 163 | - } | ||
| 164 | -} | ||
| 165 | - | ||
| 166 | -/// Wrapper over the `huffman_table` bindgen field in `VAHuffmanTableBufferJPEGBaseline`. | ||
| 167 | -pub struct HuffmanTableBufferJPEGBaselineHuffmanTable( | ||
| 168 | - bindings::_VAHuffmanTableBufferJPEGBaseline__bindgen_ty_1, | ||
| 169 | -); | ||
| 170 | - | ||
| 171 | -impl HuffmanTableBufferJPEGBaselineHuffmanTable { | ||
| 172 | - /// Creates the bindgen field. | ||
| 173 | - #[allow(clippy::too_many_arguments)] | ||
| 174 | - pub fn new( | ||
| 175 | - num_dc_codes: [u8; 16usize], | ||
| 176 | - dc_values: [u8; 12usize], | ||
| 177 | - num_ac_codes: [u8; 16usize], | ||
| 178 | - ac_values: [u8; 162usize], | ||
| 179 | - pad: [u8; 2usize], | ||
| 180 | - ) -> Self { | ||
| 181 | - Self(bindings::_VAHuffmanTableBufferJPEGBaseline__bindgen_ty_1 { | ||
| 182 | - num_dc_codes, | ||
| 183 | - dc_values, | ||
| 184 | - num_ac_codes, | ||
| 185 | - ac_values, | ||
| 186 | - pad, | ||
| 187 | - }) | ||
| 188 | - } | ||
| 189 | - | ||
| 190 | - /// Returns the inner FFI type. Useful for testing purposes. | ||
| 191 | - pub fn inner(&mut self) -> &bindings::_VAHuffmanTableBufferJPEGBaseline__bindgen_ty_1 { | ||
| 192 | - &self.0 | ||
| 193 | - } | ||
| 194 | -} | ||
| 195 | - | ||
| 196 | -/// Wrapper over the `VAHuffmanTableBufferJPEGBaseline` FFI type. | ||
| 197 | -pub struct HuffmanTableBufferJPEGBaseline(Box<bindings::VAHuffmanTableBufferJPEGBaseline>); | ||
| 198 | - | ||
| 199 | -impl HuffmanTableBufferJPEGBaseline { | ||
| 200 | - /// Creates the wrapper. | ||
| 201 | - pub fn new( | ||
| 202 | - load_huffman_table: [u8; 2usize], | ||
| 203 | - huffman_table: [HuffmanTableBufferJPEGBaselineHuffmanTable; 2usize], | ||
| 204 | - ) -> Self { | ||
| 205 | - Self(Box::new(bindings::VAHuffmanTableBufferJPEGBaseline { | ||
| 206 | - load_huffman_table, | ||
| 207 | - huffman_table: huffman_table.map(|component| component.0), | ||
| 208 | - va_reserved: Default::default(), | ||
| 209 | - })) | ||
| 210 | - } | ||
| 211 | - | ||
| 212 | - pub(crate) fn inner_mut(&mut self) -> &mut bindings::VAHuffmanTableBufferJPEGBaseline { | ||
| 213 | - self.0.as_mut() | ||
| 214 | - } | ||
| 215 | - | ||
| 216 | - /// Returns the inner FFI type. Useful for testing purposes. | ||
| 217 | - pub fn inner(&mut self) -> &bindings::VAHuffmanTableBufferJPEGBaseline { | ||
| 218 | - self.0.as_ref() | ||
| 219 | - } | ||
| 220 | -} | ||
shims/cros-libva/src/buffer/mpeg2.rsdeleted+0 -172
| @@ -1,172 +0,0 @@ | |||
| 1 | -// Copyright 2023 The ChromiumOS Authors | ||
| 2 | -// Use of this source code is governed by a BSD-style license that can be | ||
| 3 | -// found in the LICENSE file. | ||
| 4 | - | ||
| 5 | -//! Wrappers around MPEG2 `VABuffer` types. | ||
| 6 | - | ||
| 7 | -use crate::bindings; | ||
| 8 | - | ||
| 9 | -/// Wrapper over the `picture_coding_extension` bindgen field in `VAPictureParameterBufferMPEG2`. | ||
| 10 | -pub struct MPEG2PictureCodingExtension(bindings::_VAPictureParameterBufferMPEG2__bindgen_ty_1); | ||
| 11 | - | ||
| 12 | -impl MPEG2PictureCodingExtension { | ||
| 13 | - /// Creates the bindgen field. | ||
| 14 | - #[allow(clippy::too_many_arguments)] | ||
| 15 | - pub fn new( | ||
| 16 | - intra_dc_precision: u32, | ||
| 17 | - picture_structure: u32, | ||
| 18 | - top_field_first: u32, | ||
| 19 | - frame_pred_frame_dct: u32, | ||
| 20 | - concealment_motion_vectors: u32, | ||
| 21 | - q_scale_type: u32, | ||
| 22 | - intra_vlc_format: u32, | ||
| 23 | - alternate_scan: u32, | ||
| 24 | - repeat_first_field: u32, | ||
| 25 | - progressive_frame: u32, | ||
| 26 | - is_first_field: u32, | ||
| 27 | - ) -> Self { | ||
| 28 | - let _bitfield_1 = | ||
| 29 | - bindings::_VAPictureParameterBufferMPEG2__bindgen_ty_1__bindgen_ty_1::new_bitfield_1( | ||
| 30 | - intra_dc_precision, | ||
| 31 | - picture_structure, | ||
| 32 | - top_field_first, | ||
| 33 | - frame_pred_frame_dct, | ||
| 34 | - concealment_motion_vectors, | ||
| 35 | - q_scale_type, | ||
| 36 | - intra_vlc_format, | ||
| 37 | - alternate_scan, | ||
| 38 | - repeat_first_field, | ||
| 39 | - progressive_frame, | ||
| 40 | - is_first_field, | ||
| 41 | - ); | ||
| 42 | - | ||
| 43 | - Self(bindings::_VAPictureParameterBufferMPEG2__bindgen_ty_1 { | ||
| 44 | - bits: bindings::_VAPictureParameterBufferMPEG2__bindgen_ty_1__bindgen_ty_1 { | ||
| 45 | - _bitfield_align_1: Default::default(), | ||
| 46 | - _bitfield_1, | ||
| 47 | - __bindgen_padding_0: Default::default(), | ||
| 48 | - }, | ||
| 49 | - }) | ||
| 50 | - } | ||
| 51 | - | ||
| 52 | - /// Returns the inner FFI type. Useful for testing purposes. | ||
| 53 | - pub fn inner(&mut self) -> &bindings::_VAPictureParameterBufferMPEG2__bindgen_ty_1 { | ||
| 54 | - &self.0 | ||
| 55 | - } | ||
| 56 | -} | ||
| 57 | - | ||
| 58 | -/// Wrapper over the `PictureParameterBufferMPEG2` FFI type. | ||
| 59 | -pub struct PictureParameterBufferMPEG2(Box<bindings::VAPictureParameterBufferMPEG2>); | ||
| 60 | - | ||
| 61 | -impl PictureParameterBufferMPEG2 { | ||
| 62 | - /// Creates the wrapper. | ||
| 63 | - pub fn new( | ||
| 64 | - horizontal_size: u16, | ||
| 65 | - vertical_size: u16, | ||
| 66 | - forward_reference_picture: bindings::VASurfaceID, | ||
| 67 | - backward_reference_picture: bindings::VASurfaceID, | ||
| 68 | - picture_coding_type: i32, | ||
| 69 | - f_code: i32, | ||
| 70 | - picture_coding_extension: &MPEG2PictureCodingExtension, | ||
| 71 | - ) -> Self { | ||
| 72 | - let picture_coding_extension = picture_coding_extension.0; | ||
| 73 | - | ||
| 74 | - Self(Box::new(bindings::VAPictureParameterBufferMPEG2 { | ||
| 75 | - horizontal_size, | ||
| 76 | - vertical_size, | ||
| 77 | - forward_reference_picture, | ||
| 78 | - backward_reference_picture, | ||
| 79 | - picture_coding_type, | ||
| 80 | - f_code, | ||
| 81 | - picture_coding_extension, | ||
| 82 | - va_reserved: Default::default(), | ||
| 83 | - })) | ||
| 84 | - } | ||
| 85 | - | ||
| 86 | - pub(crate) fn inner_mut(&mut self) -> &mut bindings::VAPictureParameterBufferMPEG2 { | ||
| 87 | - self.0.as_mut() | ||
| 88 | - } | ||
| 89 | - | ||
| 90 | - /// Returns the inner FFI type. Useful for testing purposes. | ||
| 91 | - pub fn inner(&mut self) -> &bindings::VAPictureParameterBufferMPEG2 { | ||
| 92 | - self.0.as_ref() | ||
| 93 | - } | ||
| 94 | -} | ||
| 95 | - | ||
| 96 | -/// Wrapper over the `VASliceParameterBufferMPEG2` FFI type. | ||
| 97 | -pub struct SliceParameterBufferMPEG2(Box<bindings::VASliceParameterBufferMPEG2>); | ||
| 98 | - | ||
| 99 | -impl SliceParameterBufferMPEG2 { | ||
| 100 | - /// Creates the wrapper. | ||
| 101 | - #[allow(clippy::too_many_arguments)] | ||
| 102 | - pub fn new( | ||
| 103 | - slice_data_size: u32, | ||
| 104 | - slice_data_offset: u32, | ||
| 105 | - slice_data_flag: u32, | ||
| 106 | - macroblock_offset: u32, | ||
| 107 | - slice_horizontal_position: u32, | ||
| 108 | - slice_vertical_position: u32, | ||
| 109 | - quantiser_scale_code: i32, | ||
| 110 | - intra_slice_flag: i32, | ||
| 111 | - ) -> Self { | ||
| 112 | - Self(Box::new(bindings::VASliceParameterBufferMPEG2 { | ||
| 113 | - slice_data_size, | ||
| 114 | - slice_data_offset, | ||
| 115 | - slice_data_flag, | ||
| 116 | - macroblock_offset, | ||
| 117 | - slice_horizontal_position, | ||
| 118 | - slice_vertical_position, | ||
| 119 | - quantiser_scale_code, | ||
| 120 | - intra_slice_flag, | ||
| 121 | - va_reserved: Default::default(), | ||
| 122 | - })) | ||
| 123 | - } | ||
| 124 | - | ||
| 125 | - pub(crate) fn inner_mut(&mut self) -> &mut bindings::VASliceParameterBufferMPEG2 { | ||
| 126 | - self.0.as_mut() | ||
| 127 | - } | ||
| 128 | - | ||
| 129 | - /// Returns the inner FFI type. Useful for testing purposes. | ||
| 130 | - pub fn inner(&self) -> &bindings::VASliceParameterBufferMPEG2 { | ||
| 131 | - self.0.as_ref() | ||
| 132 | - } | ||
| 133 | -} | ||
| 134 | - | ||
| 135 | -/// Wrapper over the `VAIQMatrixBufferMPEG2` FFI type. | ||
| 136 | -pub struct IQMatrixBufferMPEG2(Box<bindings::VAIQMatrixBufferMPEG2>); | ||
| 137 | - | ||
| 138 | -impl IQMatrixBufferMPEG2 { | ||
| 139 | - /// Creates the wrapper. | ||
| 140 | - #[allow(clippy::too_many_arguments)] | ||
| 141 | - pub fn new( | ||
| 142 | - load_intra_quantiser_matrix: i32, | ||
| 143 | - load_non_intra_quantiser_matrix: i32, | ||
| 144 | - load_chroma_intra_quantiser_matrix: i32, | ||
| 145 | - load_chroma_non_intra_quantiser_matrix: i32, | ||
| 146 | - intra_quantiser_matrix: [u8; 64usize], | ||
| 147 | - non_intra_quantiser_matrix: [u8; 64usize], | ||
| 148 | - chroma_intra_quantiser_matrix: [u8; 64usize], | ||
| 149 | - chroma_non_intra_quantiser_matrix: [u8; 64usize], | ||
| 150 | - ) -> Self { | ||
| 151 | - Self(Box::new(bindings::VAIQMatrixBufferMPEG2 { | ||
| 152 | - load_intra_quantiser_matrix, | ||
| 153 | - load_non_intra_quantiser_matrix, | ||
| 154 | - load_chroma_intra_quantiser_matrix, | ||
| 155 | - load_chroma_non_intra_quantiser_matrix, | ||
| 156 | - intra_quantiser_matrix, | ||
| 157 | - non_intra_quantiser_matrix, | ||
| 158 | - chroma_intra_quantiser_matrix, | ||
| 159 | - chroma_non_intra_quantiser_matrix, | ||
| 160 | - va_reserved: Default::default(), | ||
| 161 | - })) | ||
| 162 | - } | ||
| 163 | - | ||
| 164 | - pub(crate) fn inner_mut(&mut self) -> &mut bindings::VAIQMatrixBufferMPEG2 { | ||
| 165 | - self.0.as_mut() | ||
| 166 | - } | ||
| 167 | - | ||
| 168 | - /// Returns the inner FFI type. Useful for testing purposes. | ||
| 169 | - pub fn inner(&self) -> &bindings::VAIQMatrixBufferMPEG2 { | ||
| 170 | - self.0.as_ref() | ||
| 171 | - } | ||
| 172 | -} | ||
shims/cros-libva/src/buffer/vp8.rsdeleted+0 -397
| @@ -1,397 +0,0 @@ | |||
| 1 | -// Copyright 2023 The ChromiumOS Authors | ||
| 2 | -// Use of this source code is governed by a BSD-style license that can be | ||
| 3 | -// found in the LICENSE file. | ||
| 4 | - | ||
| 5 | -//! Wrappers around VP8 `VABuffer` types. | ||
| 6 | - | ||
| 7 | -use crate::bindings; | ||
| 8 | - | ||
| 9 | -/// Wrapper over the `pic_fields` bindgen field in `VAPictureParameterBufferVP8`. | ||
| 10 | -pub struct VP8PicFields(bindings::_VAPictureParameterBufferVP8__bindgen_ty_1); | ||
| 11 | - | ||
| 12 | -impl VP8PicFields { | ||
| 13 | - /// Creates the bindgen field | ||
| 14 | - #[allow(clippy::too_many_arguments)] | ||
| 15 | - pub fn new( | ||
| 16 | - key_frame: u32, | ||
| 17 | - version: u32, | ||
| 18 | - segmentation_enabled: u32, | ||
| 19 | - update_mb_segmentation_map: u32, | ||
| 20 | - update_segment_feature_data: u32, | ||
| 21 | - filter_type: u32, | ||
| 22 | - sharpness_level: u32, | ||
| 23 | - loop_filter_adj_enable: u32, | ||
| 24 | - mode_ref_lf_delta_update: u32, | ||
| 25 | - sign_bias_golden: u32, | ||
| 26 | - sign_bias_alternate: u32, | ||
| 27 | - mb_no_coeff_skip: u32, | ||
| 28 | - loop_filter_disable: u32, | ||
| 29 | - ) -> Self { | ||
| 30 | - let _bitfield_1 = | ||
| 31 | - bindings::_VAPictureParameterBufferVP8__bindgen_ty_1__bindgen_ty_1::new_bitfield_1( | ||
| 32 | - key_frame, | ||
| 33 | - version, | ||
| 34 | - segmentation_enabled, | ||
| 35 | - update_mb_segmentation_map, | ||
| 36 | - update_segment_feature_data, | ||
| 37 | - filter_type, | ||
| 38 | - sharpness_level, | ||
| 39 | - loop_filter_adj_enable, | ||
| 40 | - mode_ref_lf_delta_update, | ||
| 41 | - sign_bias_golden, | ||
| 42 | - sign_bias_alternate, | ||
| 43 | - mb_no_coeff_skip, | ||
| 44 | - loop_filter_disable, | ||
| 45 | - ); | ||
| 46 | - | ||
| 47 | - Self(bindings::_VAPictureParameterBufferVP8__bindgen_ty_1 { | ||
| 48 | - bits: bindings::_VAPictureParameterBufferVP8__bindgen_ty_1__bindgen_ty_1 { | ||
| 49 | - _bitfield_align_1: Default::default(), | ||
| 50 | - _bitfield_1, | ||
| 51 | - __bindgen_padding_0: Default::default(), | ||
| 52 | - }, | ||
| 53 | - }) | ||
| 54 | - } | ||
| 55 | - | ||
| 56 | - /// Returns the inner FFI type. Useful for testing purposes. | ||
| 57 | - pub fn inner(&self) -> &bindings::_VAPictureParameterBufferVP8__bindgen_ty_1 { | ||
| 58 | - &self.0 | ||
| 59 | - } | ||
| 60 | -} | ||
| 61 | - | ||
| 62 | -/// Wrapper over the `VABoolCoderContextVPX` FFI type. | ||
| 63 | -pub struct BoolCoderContextVPX(bindings::VABoolCoderContextVPX); | ||
| 64 | - | ||
| 65 | -impl BoolCoderContextVPX { | ||
| 66 | - /// Creates the wrapper | ||
| 67 | - pub fn new(range: u8, value: u8, count: u8) -> Self { | ||
| 68 | - Self(bindings::VABoolCoderContextVPX { | ||
| 69 | - range, | ||
| 70 | - value, | ||
| 71 | - count, | ||
| 72 | - }) | ||
| 73 | - } | ||
| 74 | -} | ||
| 75 | - | ||
| 76 | -/// Wrapper over the `PictureParameterBufferVP8` FFI type. | ||
| 77 | -pub struct PictureParameterBufferVP8(Box<bindings::VAPictureParameterBufferVP8>); | ||
| 78 | - | ||
| 79 | -impl PictureParameterBufferVP8 { | ||
| 80 | - /// Creates the wrapper | ||
| 81 | - #[allow(clippy::too_many_arguments)] | ||
| 82 | - pub fn new( | ||
| 83 | - frame_width: u32, | ||
| 84 | - frame_height: u32, | ||
| 85 | - last_ref_frame: bindings::VASurfaceID, | ||
| 86 | - golden_ref_frame: bindings::VASurfaceID, | ||
| 87 | - alt_ref_frame: bindings::VASurfaceID, | ||
| 88 | - pic_fields: &VP8PicFields, | ||
| 89 | - mb_segment_tree_probs: [u8; 3usize], | ||
| 90 | - loop_filter_level: [u8; 4usize], | ||
| 91 | - loop_filter_deltas_ref_frame: [i8; 4usize], | ||
| 92 | - loop_filter_deltas_mode: [i8; 4usize], | ||
| 93 | - prob_skip_false: u8, | ||
| 94 | - prob_intra: u8, | ||
| 95 | - prob_last: u8, | ||
| 96 | - prob_gf: u8, | ||
| 97 | - y_mode_probs: [u8; 4usize], | ||
| 98 | - uv_mode_probs: [u8; 3usize], | ||
| 99 | - mv_probs: [[u8; 19usize]; 2usize], | ||
| 100 | - bool_coder_ctx: &BoolCoderContextVPX, | ||
| 101 | - ) -> Self { | ||
| 102 | - let pic_fields = pic_fields.0; | ||
| 103 | - let bool_coder_ctx = bool_coder_ctx.0; | ||
| 104 | - | ||
| 105 | - Self(Box::new(bindings::VAPictureParameterBufferVP8 { | ||
| 106 | - frame_width, | ||
| 107 | - frame_height, | ||
| 108 | - last_ref_frame, | ||
| 109 | - golden_ref_frame, | ||
| 110 | - alt_ref_frame, | ||
| 111 | - out_of_loop_frame: bindings::VA_INVALID_SURFACE, | ||
| 112 | - pic_fields, | ||
| 113 | - mb_segment_tree_probs, | ||
| 114 | - loop_filter_level, | ||
| 115 | - loop_filter_deltas_ref_frame, | ||
| 116 | - loop_filter_deltas_mode, | ||
| 117 | - prob_skip_false, | ||
| 118 | - prob_intra, | ||
| 119 | - prob_last, | ||
| 120 | - prob_gf, | ||
| 121 | - y_mode_probs, | ||
| 122 | - uv_mode_probs, | ||
| 123 | - mv_probs, | ||
| 124 | - bool_coder_ctx, | ||
| 125 | - va_reserved: Default::default(), | ||
| 126 | - })) | ||
| 127 | - } | ||
| 128 | - | ||
| 129 | - pub(crate) fn inner_mut(&mut self) -> &mut bindings::VAPictureParameterBufferVP8 { | ||
| 130 | - self.0.as_mut() | ||
| 131 | - } | ||
| 132 | - | ||
| 133 | - /// Returns the inner FFI type. Useful for testing purposes. | ||
| 134 | - pub fn inner(&self) -> &bindings::VAPictureParameterBufferVP8 { | ||
| 135 | - self.0.as_ref() | ||
| 136 | - } | ||
| 137 | -} | ||
| 138 | - | ||
| 139 | -/// Wrapper over the `VASliceParameterBufferVP8` FFI type. | ||
| 140 | -pub struct SliceParameterBufferVP8(Box<bindings::VASliceParameterBufferVP8>); | ||
| 141 | - | ||
| 142 | -impl SliceParameterBufferVP8 { | ||
| 143 | - /// Creates the wrapper. | ||
| 144 | - pub fn new( | ||
| 145 | - slice_data_size: u32, | ||
| 146 | - slice_data_offset: u32, | ||
| 147 | - slice_data_flag: u32, | ||
| 148 | - macroblock_offset: u32, | ||
| 149 | - num_of_partitions: u8, | ||
| 150 | - partition_size: [u32; 9usize], | ||
| 151 | - ) -> Self { | ||
| 152 | - Self(Box::new(bindings::VASliceParameterBufferVP8 { | ||
| 153 | - slice_data_size, | ||
| 154 | - slice_data_offset, | ||
| 155 | - slice_data_flag, | ||
| 156 | - macroblock_offset, | ||
| 157 | - num_of_partitions, | ||
| 158 | - partition_size, | ||
| 159 | - va_reserved: Default::default(), | ||
| 160 | - })) | ||
| 161 | - } | ||
| 162 | - | ||
| 163 | - pub(crate) fn inner_mut(&mut self) -> &mut bindings::VASliceParameterBufferVP8 { | ||
| 164 | - self.0.as_mut() | ||
| 165 | - } | ||
| 166 | - | ||
| 167 | - /// Returns the inner FFI type. Useful for testing purposes. | ||
| 168 | - pub fn inner(&self) -> &bindings::VASliceParameterBufferVP8 { | ||
| 169 | - self.0.as_ref() | ||
| 170 | - } | ||
| 171 | -} | ||
| 172 | - | ||
| 173 | -/// Wrapper over the `VAIQMatrixBufferVP8` FFI type. | ||
| 174 | -pub struct IQMatrixBufferVP8(Box<bindings::VAIQMatrixBufferVP8>); | ||
| 175 | - | ||
| 176 | -impl IQMatrixBufferVP8 { | ||
| 177 | - /// Creates the wrapper. | ||
| 178 | - pub fn new(quantization_index: [[u16; 6usize]; 4usize]) -> Self { | ||
| 179 | - Self(Box::new(bindings::VAIQMatrixBufferVP8 { | ||
| 180 | - quantization_index, | ||
| 181 | - va_reserved: Default::default(), | ||
| 182 | - })) | ||
| 183 | - } | ||
| 184 | - | ||
| 185 | - pub(crate) fn inner_mut(&mut self) -> &mut bindings::VAIQMatrixBufferVP8 { | ||
| 186 | - self.0.as_mut() | ||
| 187 | - } | ||
| 188 | - | ||
| 189 | - /// Returns the inner FFI type. Useful for testing purposes. | ||
| 190 | - pub fn inner(&self) -> &bindings::VAIQMatrixBufferVP8 { | ||
| 191 | - self.0.as_ref() | ||
| 192 | - } | ||
| 193 | -} | ||
| 194 | - | ||
| 195 | -/// Wrapper over the VAProbabilityDataBufferVP8 FFI type. | ||
| 196 | -pub struct ProbabilityDataBufferVP8(Box<bindings::VAProbabilityDataBufferVP8>); | ||
| 197 | - | ||
| 198 | -impl ProbabilityDataBufferVP8 { | ||
| 199 | - /// Creates the wrapper. | ||
| 200 | - pub fn new(dct_coeff_probs: [[[[u8; 11usize]; 3usize]; 8usize]; 4usize]) -> Self { | ||
| 201 | - Self(Box::new(bindings::VAProbabilityDataBufferVP8 { | ||
| 202 | - dct_coeff_probs, | ||
| 203 | - va_reserved: Default::default(), | ||
| 204 | - })) | ||
| 205 | - } | ||
| 206 | - | ||
| 207 | - pub(crate) fn inner_mut(&mut self) -> &mut bindings::VAProbabilityDataBufferVP8 { | ||
| 208 | - self.0.as_mut() | ||
| 209 | - } | ||
| 210 | - | ||
| 211 | - /// Returns the inner FFI type. Useful for testing purposes. | ||
| 212 | - pub fn inner(&self) -> &bindings::VAProbabilityDataBufferVP8 { | ||
| 213 | - self.0.as_ref() | ||
| 214 | - } | ||
| 215 | -} | ||
| 216 | - | ||
| 217 | -pub struct EncSequenceParameterBufferVP8(Box<bindings::VAEncSequenceParameterBufferVP8>); | ||
| 218 | - | ||
| 219 | -impl EncSequenceParameterBufferVP8 { | ||
| 220 | - #[allow(clippy::too_many_arguments)] | ||
| 221 | - pub fn new( | ||
| 222 | - frame_width: u32, | ||
| 223 | - frame_height: u32, | ||
| 224 | - frame_width_scale: u32, | ||
| 225 | - frame_height_scale: u32, | ||
| 226 | - error_resilient: u32, | ||
| 227 | - kf_auto: u32, | ||
| 228 | - kf_min_dist: u32, | ||
| 229 | - kf_max_dist: u32, | ||
| 230 | - bits_per_second: u32, | ||
| 231 | - intra_period: u32, | ||
| 232 | - reference_frames: [bindings::VASurfaceID; 4usize], | ||
| 233 | - ) -> Self { | ||
| 234 | - Self(Box::new(bindings::VAEncSequenceParameterBufferVP8 { | ||
| 235 | - frame_width, | ||
| 236 | - frame_height, | ||
| 237 | - frame_width_scale, | ||
| 238 | - frame_height_scale, | ||
| 239 | - error_resilient, | ||
| 240 | - kf_auto, | ||
| 241 | - kf_min_dist, | ||
| 242 | - kf_max_dist, | ||
| 243 | - bits_per_second, | ||
| 244 | - intra_period, | ||
| 245 | - reference_frames, | ||
| 246 | - va_reserved: Default::default(), | ||
| 247 | - })) | ||
| 248 | - } | ||
| 249 | - | ||
| 250 | - pub(crate) fn inner_mut(&mut self) -> &mut bindings::VAEncSequenceParameterBufferVP8 { | ||
| 251 | - &mut self.0 | ||
| 252 | - } | ||
| 253 | -} | ||
| 254 | - | ||
| 255 | -pub struct VP8EncRefFlags(bindings::_VAEncPictureParameterBufferVP8__bindgen_ty_1); | ||
| 256 | - | ||
| 257 | -impl VP8EncRefFlags { | ||
| 258 | - pub fn new( | ||
| 259 | - force_kf: u32, | ||
| 260 | - no_ref_last: u32, | ||
| 261 | - no_ref_gf: u32, | ||
| 262 | - no_ref_arf: u32, | ||
| 263 | - temporal_id: u32, | ||
| 264 | - first_ref: u32, | ||
| 265 | - second_ref: u32, | ||
| 266 | - ) -> Self { | ||
| 267 | - let _bitfield_1 = | ||
| 268 | - bindings::_VAEncPictureParameterBufferVP8__bindgen_ty_1__bindgen_ty_1::new_bitfield_1( | ||
| 269 | - force_kf, | ||
| 270 | - no_ref_last, | ||
| 271 | - no_ref_gf, | ||
| 272 | - no_ref_arf, | ||
| 273 | - temporal_id, | ||
| 274 | - first_ref, | ||
| 275 | - second_ref, | ||
| 276 | - Default::default(), | ||
| 277 | - ); | ||
| 278 | - | ||
| 279 | - Self(bindings::_VAEncPictureParameterBufferVP8__bindgen_ty_1 { | ||
| 280 | - bits: bindings::_VAEncPictureParameterBufferVP8__bindgen_ty_1__bindgen_ty_1 { | ||
| 281 | - _bitfield_align_1: Default::default(), | ||
| 282 | - _bitfield_1, | ||
| 283 | - }, | ||
| 284 | - }) | ||
| 285 | - } | ||
| 286 | -} | ||
| 287 | - | ||
| 288 | -pub struct VP8EncPicFlags(bindings::_VAEncPictureParameterBufferVP8__bindgen_ty_2); | ||
| 289 | - | ||
| 290 | -impl VP8EncPicFlags { | ||
| 291 | - #[allow(clippy::too_many_arguments)] | ||
| 292 | - pub fn new( | ||
| 293 | - frame_type: u32, | ||
| 294 | - version: u32, | ||
| 295 | - show_frame: u32, | ||
| 296 | - color_space: u32, | ||
| 297 | - recon_filter_type: u32, | ||
| 298 | - loop_filter_type: u32, | ||
| 299 | - auto_partitions: u32, | ||
| 300 | - num_token_partitions: u32, | ||
| 301 | - clamping_type: u32, | ||
| 302 | - segmentation_enabled: u32, | ||
| 303 | - update_mb_segmentation_map: u32, | ||
| 304 | - update_segment_feature_data: u32, | ||
| 305 | - loop_filter_adj_enable: u32, | ||
| 306 | - refresh_entropy_probs: u32, | ||
| 307 | - refresh_golden_frame: u32, | ||
| 308 | - refresh_alternate_frame: u32, | ||
| 309 | - refresh_last: u32, | ||
| 310 | - copy_buffer_to_golden: u32, | ||
| 311 | - copy_buffer_to_alternate: u32, | ||
| 312 | - sign_bias_golden: u32, | ||
| 313 | - sign_bias_alternate: u32, | ||
| 314 | - mb_no_coeff_skip: u32, | ||
| 315 | - forced_lf_adjustment: u32, | ||
| 316 | - ) -> Self { | ||
| 317 | - let _bitfield_1 = | ||
| 318 | - bindings::_VAEncPictureParameterBufferVP8__bindgen_ty_2__bindgen_ty_1::new_bitfield_1( | ||
| 319 | - frame_type, | ||
| 320 | - version, | ||
| 321 | - show_frame, | ||
| 322 | - color_space, | ||
| 323 | - recon_filter_type, | ||
| 324 | - loop_filter_type, | ||
| 325 | - auto_partitions, | ||
| 326 | - num_token_partitions, | ||
| 327 | - clamping_type, | ||
| 328 | - segmentation_enabled, | ||
| 329 | - update_mb_segmentation_map, | ||
| 330 | - update_segment_feature_data, | ||
| 331 | - loop_filter_adj_enable, | ||
| 332 | - refresh_entropy_probs, | ||
| 333 | - refresh_golden_frame, | ||
| 334 | - refresh_alternate_frame, | ||
| 335 | - refresh_last, | ||
| 336 | - copy_buffer_to_golden, | ||
| 337 | - copy_buffer_to_alternate, | ||
| 338 | - sign_bias_golden, | ||
| 339 | - sign_bias_alternate, | ||
| 340 | - mb_no_coeff_skip, | ||
| 341 | - forced_lf_adjustment, | ||
| 342 | - Default::default(), | ||
| 343 | - ); | ||
| 344 | - | ||
| 345 | - Self(bindings::_VAEncPictureParameterBufferVP8__bindgen_ty_2 { | ||
| 346 | - bits: bindings::_VAEncPictureParameterBufferVP8__bindgen_ty_2__bindgen_ty_1 { | ||
| 347 | - _bitfield_align_1: Default::default(), | ||
| 348 | - _bitfield_1, | ||
| 349 | - }, | ||
| 350 | - }) | ||
| 351 | - } | ||
| 352 | -} | ||
| 353 | - | ||
| 354 | -pub struct EncPictureParameterBufferVP8(Box<bindings::VAEncPictureParameterBufferVP8>); | ||
| 355 | - | ||
| 356 | -impl EncPictureParameterBufferVP8 { | ||
| 357 | - #[allow(clippy::too_many_arguments)] | ||
| 358 | - pub fn new( | ||
| 359 | - reconstructed_frame: bindings::VASurfaceID, | ||
| 360 | - ref_last_frame: bindings::VASurfaceID, | ||
| 361 | - ref_gf_frame: bindings::VASurfaceID, | ||
| 362 | - ref_arf_frame: bindings::VASurfaceID, | ||
| 363 | - coded_buf: bindings::VABufferID, | ||
| 364 | - ref_flags: &VP8EncRefFlags, | ||
| 365 | - pic_flags: &VP8EncPicFlags, | ||
| 366 | - loop_filter_level: [i8; 4usize], | ||
| 367 | - ref_lf_delta: [i8; 4usize], | ||
| 368 | - mode_lf_delta: [i8; 4usize], | ||
| 369 | - sharpness_level: u8, | ||
| 370 | - clamp_qindex_high: u8, | ||
| 371 | - clamp_qindex_low: u8, | ||
| 372 | - ) -> Self { | ||
| 373 | - let ref_flags = ref_flags.0; | ||
| 374 | - let pic_flags = pic_flags.0; | ||
| 375 | - | ||
| 376 | - Self(Box::new(bindings::VAEncPictureParameterBufferVP8 { | ||
| 377 | - reconstructed_frame, | ||
| 378 | - ref_last_frame, | ||
| 379 | - ref_gf_frame, | ||
| 380 | - ref_arf_frame, | ||
| 381 | - coded_buf, | ||
| 382 | - ref_flags, | ||
| 383 | - pic_flags, | ||
| 384 | - loop_filter_level, | ||
| 385 | - ref_lf_delta, | ||
| 386 | - mode_lf_delta, | ||
| 387 | - sharpness_level, | ||
| 388 | - clamp_qindex_high, | ||
| 389 | - clamp_qindex_low, | ||
| 390 | - va_reserved: Default::default(), | ||
| 391 | - })) | ||
| 392 | - } | ||
| 393 | - | ||
| 394 | - pub(crate) fn inner_mut(&mut self) -> &mut bindings::VAEncPictureParameterBufferVP8 { | ||
| 395 | - &mut self.0 | ||
| 396 | - } | ||
| 397 | -} | ||
shims/cros-libva/src/lib.rsmodified+0 -465
| @@ -69,468 +69,3 @@ fn va_check(code: VAStatus) -> Result<(), VaError> { | |||
| 69 | _ => Err(VaError(unsafe { NonZeroI32::new_unchecked(code) })), | 69 | _ => Err(VaError(unsafe { NonZeroI32::new_unchecked(code) })), |
| 70 | } | 70 | } |
| 71 | } | 71 | } |
| 72 | - | ||
| 73 | -#[cfg(test)] | ||
| 74 | -mod tests { | ||
| 75 | - use std::io::Write; | ||
| 76 | - use std::rc::Rc; | ||
| 77 | - | ||
| 78 | - use super::*; | ||
| 79 | - | ||
| 80 | - /// Returns a 32-bit CRC for the visible part of `image`, which must be in NV12 format. | ||
| 81 | - fn crc_nv12_image(image: &Image) -> u32 { | ||
| 82 | - let data = image.as_ref(); | ||
| 83 | - let va_image = image.image(); | ||
| 84 | - let offsets = &va_image.offsets; | ||
| 85 | - let pitches = &va_image.pitches; | ||
| 86 | - let width = va_image.width as usize; | ||
| 87 | - let height = va_image.height as usize; | ||
| 88 | - | ||
| 89 | - // We only support NV12 images | ||
| 90 | - assert_eq!(va_image.format.fourcc, u32::from_ne_bytes(*b"NV12")); | ||
| 91 | - // Consistency check | ||
| 92 | - assert_eq!(va_image.num_planes, 2); | ||
| 93 | - | ||
| 94 | - let mut hasher = crc32fast::Hasher::new(); | ||
| 95 | - | ||
| 96 | - let offset = offsets[0] as usize; | ||
| 97 | - let pitch = pitches[0] as usize; | ||
| 98 | - let y_plane = data[offset..(offset + pitch * height)] | ||
| 99 | - .chunks(pitch) | ||
| 100 | - .map(|line| &line[0..width]); | ||
| 101 | - | ||
| 102 | - let offset = offsets[1] as usize; | ||
| 103 | - let pitch = pitches[1] as usize; | ||
| 104 | - let uv_plane = data[offset..(offset + pitch * ((height + 1) / 2))] | ||
| 105 | - .chunks(pitch) | ||
| 106 | - .map(|line| &line[0..width]); | ||
| 107 | - | ||
| 108 | - for line in y_plane.chain(uv_plane) { | ||
| 109 | - hasher.update(line); | ||
| 110 | - } | ||
| 111 | - | ||
| 112 | - hasher.finalize() | ||
| 113 | - } | ||
| 114 | - | ||
| 115 | - #[test] | ||
| 116 | - // Ignore this test by default as it requires libva-compatible hardware. | ||
| 117 | - #[ignore] | ||
| 118 | - fn libva_utils_mpeg2vldemo() { | ||
| 119 | - // Adapted from <https://github.com/intel/libva-utils/blob/master/decode/mpeg2vldemo.cpp> | ||
| 120 | - let display = Display::open().unwrap(); | ||
| 121 | - | ||
| 122 | - assert!(!display.query_vendor_string().unwrap().is_empty()); | ||
| 123 | - let profiles = display.query_config_profiles().unwrap(); | ||
| 124 | - assert!(!profiles.is_empty()); | ||
| 125 | - | ||
| 126 | - let profile = bindings::VAProfile::VAProfileMPEG2Main; | ||
| 127 | - let entrypoints = display.query_config_entrypoints(profile).unwrap(); | ||
| 128 | - assert!(!entrypoints.is_empty()); | ||
| 129 | - assert!(entrypoints | ||
| 130 | - .iter() | ||
| 131 | - .any(|e| *e == bindings::VAEntrypoint::VAEntrypointVLD)); | ||
| 132 | - | ||
| 133 | - let format = bindings::VA_RT_FORMAT_YUV420; | ||
| 134 | - let width = 16u32; | ||
| 135 | - let height = 16u32; | ||
| 136 | - | ||
| 137 | - let mut attrs = vec![bindings::VAConfigAttrib { | ||
| 138 | - type_: bindings::VAConfigAttribType::VAConfigAttribRTFormat, | ||
| 139 | - value: 0, | ||
| 140 | - }]; | ||
| 141 | - | ||
| 142 | - let entrypoint = bindings::VAEntrypoint::VAEntrypointVLD; | ||
| 143 | - display | ||
| 144 | - .get_config_attributes(profile, entrypoint, &mut attrs) | ||
| 145 | - .unwrap(); | ||
| 146 | - assert!(attrs[0].value != bindings::VA_ATTRIB_NOT_SUPPORTED); | ||
| 147 | - assert!(attrs[0].value & bindings::VA_RT_FORMAT_YUV420 != 0); | ||
| 148 | - | ||
| 149 | - let config = display.create_config(attrs, profile, entrypoint).unwrap(); | ||
| 150 | - | ||
| 151 | - let mut surfaces = display | ||
| 152 | - .create_surfaces( | ||
| 153 | - format, | ||
| 154 | - None, | ||
| 155 | - width, | ||
| 156 | - height, | ||
| 157 | - Some(UsageHint::USAGE_HINT_DECODER), | ||
| 158 | - vec![()], | ||
| 159 | - ) | ||
| 160 | - .unwrap(); | ||
| 161 | - let context = display | ||
| 162 | - .create_context( | ||
| 163 | - &config, | ||
| 164 | - width, | ||
| 165 | - ((height + 15) / 16) * 16, | ||
| 166 | - Some(&surfaces), | ||
| 167 | - true, | ||
| 168 | - ) | ||
| 169 | - .unwrap(); | ||
| 170 | - | ||
| 171 | - // The picture data is adapted from libva-utils at decode/mpeg2vldemo.cpp | ||
| 172 | - // Data dump of a 16x16 MPEG2 video clip,it has one I frame | ||
| 173 | - let mut mpeg2_clip: Vec<u8> = vec![ | ||
| 174 | - 0x00, 0x00, 0x01, 0xb3, 0x01, 0x00, 0x10, 0x13, 0xff, 0xff, 0xe0, 0x18, 0x00, 0x00, | ||
| 175 | - 0x01, 0xb5, 0x14, 0x8a, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0xb8, 0x00, 0x08, | ||
| 176 | - 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x0f, 0xff, 0xf8, 0x00, 0x00, 0x01, 0xb5, | ||
| 177 | - 0x8f, 0xff, 0xf3, 0x41, 0x80, 0x00, 0x00, 0x01, 0x01, 0x13, 0xe1, 0x00, 0x15, 0x81, | ||
| 178 | - 0x54, 0xe0, 0x2a, 0x05, 0x43, 0x00, 0x2d, 0x60, 0x18, 0x01, 0x4e, 0x82, 0xb9, 0x58, | ||
| 179 | - 0xb1, 0x83, 0x49, 0xa4, 0xa0, 0x2e, 0x05, 0x80, 0x4b, 0x7a, 0x00, 0x01, 0x38, 0x20, | ||
| 180 | - 0x80, 0xe8, 0x05, 0xff, 0x60, 0x18, 0xe0, 0x1d, 0x80, 0x98, 0x01, 0xf8, 0x06, 0x00, | ||
| 181 | - 0x54, 0x02, 0xc0, 0x18, 0x14, 0x03, 0xb2, 0x92, 0x80, 0xc0, 0x18, 0x94, 0x42, 0x2c, | ||
| 182 | - 0xb2, 0x11, 0x64, 0xa0, 0x12, 0x5e, 0x78, 0x03, 0x3c, 0x01, 0x80, 0x0e, 0x80, 0x18, | ||
| 183 | - 0x80, 0x6b, 0xca, 0x4e, 0x01, 0x0f, 0xe4, 0x32, 0xc9, 0xbf, 0x01, 0x42, 0x69, 0x43, | ||
| 184 | - 0x50, 0x4b, 0x01, 0xc9, 0x45, 0x80, 0x50, 0x01, 0x38, 0x65, 0xe8, 0x01, 0x03, 0xf3, | ||
| 185 | - 0xc0, 0x76, 0x00, 0xe0, 0x03, 0x20, 0x28, 0x18, 0x01, 0xa9, 0x34, 0x04, 0xc5, 0xe0, | ||
| 186 | - 0x0b, 0x0b, 0x04, 0x20, 0x06, 0xc0, 0x89, 0xff, 0x60, 0x12, 0x12, 0x8a, 0x2c, 0x34, | ||
| 187 | - 0x11, 0xff, 0xf6, 0xe2, 0x40, 0xc0, 0x30, 0x1b, 0x7a, 0x01, 0xa9, 0x0d, 0x00, 0xac, | ||
| 188 | - 0x64, | ||
| 189 | - ]; | ||
| 190 | - | ||
| 191 | - let picture_coding_extension = | ||
| 192 | - MPEG2PictureCodingExtension::new(0, 3, 0, 1, 0, 0, 0, 0, 0, 1, 1); | ||
| 193 | - let pic_param = PictureParameterBufferMPEG2::new( | ||
| 194 | - 16, | ||
| 195 | - 16, | ||
| 196 | - 0xffffffff, | ||
| 197 | - 0xffffffff, | ||
| 198 | - 1, | ||
| 199 | - 0xffff, | ||
| 200 | - &picture_coding_extension, | ||
| 201 | - ); | ||
| 202 | - | ||
| 203 | - let pic_param = BufferType::PictureParameter(PictureParameter::MPEG2(pic_param)); | ||
| 204 | - | ||
| 205 | - let iq_matrix = IQMatrixBufferMPEG2::new( | ||
| 206 | - 1, | ||
| 207 | - 1, | ||
| 208 | - 0, | ||
| 209 | - 0, | ||
| 210 | - [ | ||
| 211 | - 8, 16, 16, 19, 16, 19, 22, 22, 22, 22, 22, 22, 26, 24, 26, 27, 27, 27, 26, 26, 26, | ||
| 212 | - 26, 27, 27, 27, 29, 29, 29, 34, 34, 34, 29, 29, 29, 27, 27, 29, 29, 32, 32, 34, 34, | ||
| 213 | - 37, 38, 37, 35, 35, 34, 35, 38, 38, 40, 40, 40, 48, 48, 46, 46, 56, 56, 58, 69, 69, | ||
| 214 | - 83, | ||
| 215 | - ], | ||
| 216 | - [ | ||
| 217 | - 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 218 | - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 219 | - 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 220 | - ], | ||
| 221 | - [0; 64], | ||
| 222 | - [0; 64], | ||
| 223 | - ); | ||
| 224 | - | ||
| 225 | - let iq_matrix = BufferType::IQMatrix(IQMatrix::MPEG2(iq_matrix)); | ||
| 226 | - | ||
| 227 | - let slice_param = SliceParameterBufferMPEG2::new(150, 0, 0, 38, 0, 0, 2, 0); | ||
| 228 | - | ||
| 229 | - let slice_param = BufferType::SliceParameter(SliceParameter::MPEG2(slice_param)); | ||
| 230 | - | ||
| 231 | - let test_data_offset = 47; | ||
| 232 | - let slice_data = BufferType::SliceData(mpeg2_clip.drain(test_data_offset..).collect()); | ||
| 233 | - | ||
| 234 | - let buffers = vec![ | ||
| 235 | - context.create_buffer(pic_param).unwrap(), | ||
| 236 | - context.create_buffer(slice_param).unwrap(), | ||
| 237 | - context.create_buffer(iq_matrix).unwrap(), | ||
| 238 | - context.create_buffer(slice_data).unwrap(), | ||
| 239 | - ]; | ||
| 240 | - | ||
| 241 | - let mut picture = Picture::new(0, Rc::clone(&context), surfaces.remove(0)); | ||
| 242 | - for buffer in buffers { | ||
| 243 | - picture.add_buffer(buffer); | ||
| 244 | - } | ||
| 245 | - | ||
| 246 | - // Actual client code can just chain the calls. | ||
| 247 | - let picture = picture.begin().unwrap(); | ||
| 248 | - let picture = picture.render().unwrap(); | ||
| 249 | - let picture = picture.end().unwrap(); | ||
| 250 | - let picture = picture.sync().map_err(|(e, _)| e).unwrap(); | ||
| 251 | - | ||
| 252 | - // Test whether we can map the resulting surface to obtain the raw yuv | ||
| 253 | - // data | ||
| 254 | - let image_fmts = display.query_image_formats().unwrap(); | ||
| 255 | - let image_fmt = image_fmts | ||
| 256 | - .into_iter() | ||
| 257 | - .find(|f| f.fourcc == bindings::VA_FOURCC_NV12) | ||
| 258 | - .expect("No valid VAImageFormat found for NV12"); | ||
| 259 | - | ||
| 260 | - let resolution = (width, height); | ||
| 261 | - let image = picture | ||
| 262 | - .create_image(image_fmt, resolution, resolution) | ||
| 263 | - .unwrap(); | ||
| 264 | - | ||
| 265 | - assert_eq!(crc_nv12_image(&image), 0xa5713e52); | ||
| 266 | - } | ||
| 267 | - | ||
| 268 | - #[test] | ||
| 269 | - // Ignore this test by default as it requires libva-compatible hardware. | ||
| 270 | - #[ignore] | ||
| 271 | - fn enc_h264_demo() { | ||
| 272 | - // Based on `gst-launch-1.0 videotestsrc num-buffers=1 ! video/x-raw,width=64,height=64,format=NV12 ! vaapih264enc ! filesink location=frame.h264` | ||
| 273 | - // Frame created using `gst-launch-1.0 videotestsrc num-buffers=1 ! video/x-raw,width=64,height=64,format=NV12 ! filesink location=src/test_frame.nv12` | ||
| 274 | - let raw_frame_nv12 = include_bytes!("test_frame.nv12"); | ||
| 275 | - | ||
| 276 | - let display = Display::open().unwrap(); | ||
| 277 | - | ||
| 278 | - let format = bindings::VA_RT_FORMAT_YUV420; | ||
| 279 | - let entrypoint = bindings::VAEntrypoint::VAEntrypointEncSliceLP; | ||
| 280 | - let profile = bindings::VAProfile::VAProfileH264ConstrainedBaseline; | ||
| 281 | - let width = 64u32; | ||
| 282 | - let height = 64u32; | ||
| 283 | - | ||
| 284 | - let mut attrs = vec![bindings::VAConfigAttrib { | ||
| 285 | - type_: bindings::VAConfigAttribType::VAConfigAttribRTFormat, | ||
| 286 | - value: 0, | ||
| 287 | - }]; | ||
| 288 | - | ||
| 289 | - display | ||
| 290 | - .get_config_attributes(profile, entrypoint, &mut attrs) | ||
| 291 | - .unwrap(); | ||
| 292 | - | ||
| 293 | - let config = display.create_config(attrs, profile, entrypoint).unwrap(); | ||
| 294 | - | ||
| 295 | - let mut surfaces = display | ||
| 296 | - .create_surfaces( | ||
| 297 | - format, | ||
| 298 | - None, | ||
| 299 | - width, | ||
| 300 | - height, | ||
| 301 | - Some(UsageHint::USAGE_HINT_ENCODER), | ||
| 302 | - vec![()], | ||
| 303 | - ) | ||
| 304 | - .unwrap(); | ||
| 305 | - | ||
| 306 | - let context = display | ||
| 307 | - .create_context(&config, width, height, Some(&surfaces), true) | ||
| 308 | - .unwrap(); | ||
| 309 | - | ||
| 310 | - let seq_fields = H264EncSeqFields::new( | ||
| 311 | - 1, // 4:2:0 | ||
| 312 | - 1, // Only frames | ||
| 313 | - 0, 0, 0, 1, 0, 2, 0, | ||
| 314 | - ); | ||
| 315 | - | ||
| 316 | - let image_fmts = display.query_image_formats().unwrap(); | ||
| 317 | - let image_fmt = image_fmts | ||
| 318 | - .into_iter() | ||
| 319 | - .find(|f| f.fourcc == bindings::VA_FOURCC_NV12) | ||
| 320 | - .expect("No valid VAImageFormat found for NV12"); | ||
| 321 | - | ||
| 322 | - let surface = surfaces.pop().unwrap(); | ||
| 323 | - let surface_id = surface.id(); | ||
| 324 | - | ||
| 325 | - let coded_buffer = context.create_enc_coded(raw_frame_nv12.len()).unwrap(); | ||
| 326 | - | ||
| 327 | - let mut image = | ||
| 328 | - Image::create_from(&surface, image_fmt, (width, height), (width, height)).unwrap(); | ||
| 329 | - | ||
| 330 | - let va_image = *image.image(); | ||
| 331 | - let dest = image.as_mut(); | ||
| 332 | - let data = &raw_frame_nv12[..]; | ||
| 333 | - let width = width as usize; | ||
| 334 | - let height = height as usize; | ||
| 335 | - | ||
| 336 | - let mut src = data; | ||
| 337 | - let mut dst = &mut dest[va_image.offsets[0] as usize..]; | ||
| 338 | - | ||
| 339 | - // Copy luma | ||
| 340 | - for _ in 0..height { | ||
| 341 | - dst[..width].copy_from_slice(&src[..width]); | ||
| 342 | - dst = &mut dst[va_image.pitches[0] as usize..]; | ||
| 343 | - src = &src[width..]; | ||
| 344 | - } | ||
| 345 | - | ||
| 346 | - // Advance to the offset of the chroma plane | ||
| 347 | - let mut src = &data[width * height..]; | ||
| 348 | - let mut dst = &mut dest[va_image.offsets[1] as usize..]; | ||
| 349 | - | ||
| 350 | - let height = height / 2; | ||
| 351 | - | ||
| 352 | - // Copy chroma | ||
| 353 | - for _ in 0..height { | ||
| 354 | - dst[..width].copy_from_slice(&src[..width]); | ||
| 355 | - dst = &mut dst[va_image.pitches[1] as usize..]; | ||
| 356 | - src = &src[width..]; | ||
| 357 | - } | ||
| 358 | - drop(image); | ||
| 359 | - | ||
| 360 | - let sps = BufferType::EncSequenceParameter(EncSequenceParameter::H264( | ||
| 361 | - EncSequenceParameterBufferH264::new( | ||
| 362 | - 0, | ||
| 363 | - 10, | ||
| 364 | - 10, | ||
| 365 | - 30, | ||
| 366 | - 1, | ||
| 367 | - 0, | ||
| 368 | - 1, | ||
| 369 | - (width / 16) as u16, // width / 16 | ||
| 370 | - (height / 16) as u16, // height / 16 | ||
| 371 | - &seq_fields, | ||
| 372 | - 0, | ||
| 373 | - 0, | ||
| 374 | - 0, | ||
| 375 | - 0, | ||
| 376 | - 0, | ||
| 377 | - [0; 256], | ||
| 378 | - None, | ||
| 379 | - Some(H264VuiFields::new(1, 1, 0, 0, 0, 1, 0, 0)), | ||
| 380 | - 255, | ||
| 381 | - 1, | ||
| 382 | - 1, | ||
| 383 | - 1, | ||
| 384 | - 60, | ||
| 385 | - ), | ||
| 386 | - )); | ||
| 387 | - | ||
| 388 | - let sps = context.create_buffer(sps).unwrap(); | ||
| 389 | - | ||
| 390 | - let ref_frames: [PictureH264; 16] = (0..16) | ||
| 391 | - .map(|_| { | ||
| 392 | - PictureH264::new( | ||
| 393 | - bindings::VA_INVALID_ID, | ||
| 394 | - 0, | ||
| 395 | - bindings::VA_INVALID_SURFACE, | ||
| 396 | - 0, | ||
| 397 | - 0, | ||
| 398 | - ) | ||
| 399 | - }) | ||
| 400 | - .collect::<Vec<_>>() | ||
| 401 | - .try_into() | ||
| 402 | - .unwrap_or_else(|_| { | ||
| 403 | - panic!(); | ||
| 404 | - }); | ||
| 405 | - | ||
| 406 | - let pps = BufferType::EncPictureParameter(EncPictureParameter::H264( | ||
| 407 | - EncPictureParameterBufferH264::new( | ||
| 408 | - PictureH264::new(surface_id, 0, 0, 0, 0), | ||
| 409 | - ref_frames, | ||
| 410 | - coded_buffer.id(), | ||
| 411 | - 0, | ||
| 412 | - 0, | ||
| 413 | - 0, | ||
| 414 | - 0, | ||
| 415 | - 26, | ||
| 416 | - 0, | ||
| 417 | - 0, | ||
| 418 | - 0, | ||
| 419 | - 0, | ||
| 420 | - &H264EncPicFields::new(1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0), | ||
| 421 | - ), | ||
| 422 | - )); | ||
| 423 | - | ||
| 424 | - let pps = context.create_buffer(pps).unwrap(); | ||
| 425 | - | ||
| 426 | - let ref_pic_list_0: [PictureH264; 32] = (0..32) | ||
| 427 | - .map(|_| { | ||
| 428 | - PictureH264::new( | ||
| 429 | - bindings::VA_INVALID_ID, | ||
| 430 | - 0, | ||
| 431 | - bindings::VA_INVALID_SURFACE, | ||
| 432 | - 0, | ||
| 433 | - 0, | ||
| 434 | - ) | ||
| 435 | - }) | ||
| 436 | - .collect::<Vec<_>>() | ||
| 437 | - .try_into() | ||
| 438 | - .unwrap_or_else(|_| { | ||
| 439 | - panic!(); | ||
| 440 | - }); | ||
| 441 | - | ||
| 442 | - let ref_pic_list_1: [PictureH264; 32] = (0..32) | ||
| 443 | - .map(|_| { | ||
| 444 | - PictureH264::new( | ||
| 445 | - bindings::VA_INVALID_ID, | ||
| 446 | - 0, | ||
| 447 | - bindings::VA_INVALID_SURFACE, | ||
| 448 | - 0, | ||
| 449 | - 0, | ||
| 450 | - ) | ||
| 451 | - }) | ||
| 452 | - .collect::<Vec<_>>() | ||
| 453 | - .try_into() | ||
| 454 | - .unwrap_or_else(|_| { | ||
| 455 | - panic!(); | ||
| 456 | - }); | ||
| 457 | - | ||
| 458 | - let slice = BufferType::EncSliceParameter(EncSliceParameter::H264( | ||
| 459 | - EncSliceParameterBufferH264::new( | ||
| 460 | - 0, | ||
| 461 | - ((width / 16) * (height / 16)) as u32, | ||
| 462 | - bindings::VA_INVALID_ID, | ||
| 463 | - 2, // I | ||
| 464 | - 0, | ||
| 465 | - 1, | ||
| 466 | - 0, | ||
| 467 | - 0, | ||
| 468 | - [0, 0], | ||
| 469 | - 1, | ||
| 470 | - 0, | ||
| 471 | - 0, | ||
| 472 | - 0, | ||
| 473 | - ref_pic_list_0, | ||
| 474 | - ref_pic_list_1, | ||
| 475 | - 0, | ||
| 476 | - 0, | ||
| 477 | - 0, | ||
| 478 | - [0; 32], | ||
| 479 | - [0; 32], | ||
| 480 | - 0, | ||
| 481 | - [[0; 2]; 32], | ||
| 482 | - [[0; 2]; 32], | ||
| 483 | - 0, | ||
| 484 | - [0; 32], | ||
| 485 | - [0; 32], | ||
| 486 | - 0, | ||
| 487 | - [[0; 2]; 32], | ||
| 488 | - [[0; 2]; 32], | ||
| 489 | - 0, | ||
| 490 | - 0, | ||
| 491 | - 0, | ||
| 492 | - 2, | ||
| 493 | - 2, | ||
| 494 | - ), | ||
| 495 | - )); | ||
| 496 | - | ||
| 497 | - let slice = context.create_buffer(slice).unwrap(); | ||
| 498 | - | ||
| 499 | - let mut picture = Picture::new(0, Rc::clone(&context), surface); | ||
| 500 | - picture.add_buffer(pps); | ||
| 501 | - picture.add_buffer(sps); | ||
| 502 | - picture.add_buffer(slice); | ||
| 503 | - | ||
| 504 | - let picture = picture.begin().unwrap(); | ||
| 505 | - let picture = picture.render().unwrap(); | ||
| 506 | - let picture = picture.end().unwrap(); | ||
| 507 | - let _ = picture.sync().map_err(|(e, _)| e).unwrap(); | ||
| 508 | - | ||
| 509 | - let coded_buf = MappedCodedBuffer::new(&coded_buffer).unwrap(); | ||
| 510 | - assert_ne!(coded_buf.segments().len(), 0); | ||
| 511 | - | ||
| 512 | - for segment in coded_buf.iter() { | ||
| 513 | - assert_ne!(segment.buf.len(), 0); | ||
| 514 | - } | ||
| 515 | - | ||
| 516 | - const WRITE_TO_FILE: bool = false; | ||
| 517 | - if WRITE_TO_FILE { | ||
| 518 | - let raw_sps_bitstream: Vec<u8> = vec![ | ||
| 519 | - 0x00, 0x00, 0x00, 0x01, 0x67, 0x42, 0xc0, 0x0a, 0xab, 0x42, 0x12, 0x7f, 0xe0, 0x00, | ||
| 520 | - 0x20, 0x00, 0x22, 0x00, 0x00, 0x03, 0x00, 0x02, 0x00, 0x00, 0x03, 0x00, 0x79, 0x28, | ||
| 521 | - ]; | ||
| 522 | - | ||
| 523 | - let raw_pps_bitstream: Vec<u8> = vec![0x00, 0x00, 0x00, 0x01, 0x68, 0xce, 0x3c, 0x80]; | ||
| 524 | - | ||
| 525 | - let mut raw_file = std::fs::File::create("libva_utils_enc_h264_demo.h264").unwrap(); | ||
| 526 | - raw_file.write_all(&raw_sps_bitstream).unwrap(); | ||
| 527 | - raw_file.write_all(&raw_pps_bitstream).unwrap(); | ||
| 528 | - | ||
| 529 | - for segment in coded_buf.segments() { | ||
| 530 | - raw_file.write_all(segment.buf).unwrap(); | ||
| 531 | - } | ||
| 532 | - | ||
| 533 | - raw_file.flush().unwrap(); | ||
| 534 | - } | ||
| 535 | - } | ||
| 536 | -} | ||
shims/cros-libva/src/test_frame.nv12deleted+0 -0
Binary file changed