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)] new( intra_dc_precision: u32, picture_structure: u32, top_field_first: u32, frame_pred_frame_dct: u32, concealment_motion_vectors: u32, q_scale_type: u32, intra_vlc_format: u32, alternate_scan: u32, repeat_first_field: u32, progressive_frame: u32, is_first_field: u32, ) -> Self15 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. inner(&mut self) -> &bindings::_VAPictureParameterBufferMPEG2__bindgen_ty_153 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. new( horizontal_size: u16, vertical_size: u16, forward_reference_picture: bindings::VASurfaceID, backward_reference_picture: bindings::VASurfaceID, picture_coding_type: i32, f_code: i32, picture_coding_extension: &MPEG2PictureCodingExtension, ) -> Self63 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 inner_mut(&mut self) -> &mut bindings::VAPictureParameterBufferMPEG286 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. inner(&mut self) -> &bindings::VAPictureParameterBufferMPEG291 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)] new( slice_data_size: u32, slice_data_offset: u32, slice_data_flag: u32, macroblock_offset: u32, slice_horizontal_position: u32, slice_vertical_position: u32, quantiser_scale_code: i32, intra_slice_flag: i32, ) -> Self102 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 inner_mut(&mut self) -> &mut bindings::VASliceParameterBufferMPEG2125 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. inner(&self) -> &bindings::VASliceParameterBufferMPEG2130 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)] new( load_intra_quantiser_matrix: i32, load_non_intra_quantiser_matrix: i32, load_chroma_intra_quantiser_matrix: i32, load_chroma_non_intra_quantiser_matrix: i32, intra_quantiser_matrix: [u8; 64usize], non_intra_quantiser_matrix: [u8; 64usize], chroma_intra_quantiser_matrix: [u8; 64usize], chroma_non_intra_quantiser_matrix: [u8; 64usize], ) -> Self141 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 inner_mut(&mut self) -> &mut bindings::VAIQMatrixBufferMPEG2164 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. inner(&self) -> &bindings::VAIQMatrixBufferMPEG2169 pub fn inner(&self) -> &bindings::VAIQMatrixBufferMPEG2 { 170 self.0.as_ref() 171 } 172 } 173