]>
Commit | Line | Data |
---|---|---|
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 VP9 `VABuffer` types. | |
6 | ||
7 | use crate::bindings; | |
8 | ||
9 | /// Wrapper over the `pic_fields` bindgen field in `VAPictureParameterBufferVP9`. | |
10 | pub struct VP9PicFields(bindings::_VADecPictureParameterBufferVP9__bindgen_ty_1); | |
11 | ||
12 | impl VP9PicFields { | |
13 | /// Creates the bindgen field | |
14 | #[allow(clippy::too_many_arguments)] | |
15 | pub fn new( | |
16 | subsampling_x: u32, | |
17 | subsampling_y: u32, | |
18 | frame_type: u32, | |
19 | show_frame: u32, | |
20 | error_resilient_mode: u32, | |
21 | intra_only: u32, | |
22 | allow_high_precision_mv: u32, | |
23 | mcomp_filter_type: u32, | |
24 | frame_parallel_decoding_mode: u32, | |
25 | reset_frame_context: u32, | |
26 | refresh_frame_context: u32, | |
27 | frame_context_idx: u32, | |
28 | segmentation_enabled: u32, | |
29 | segmentation_temporal_update: u32, | |
30 | segmentation_update_map: u32, | |
31 | last_ref_frame: u32, | |
32 | last_ref_frame_sign_bias: u32, | |
33 | golden_ref_frame: u32, | |
34 | golden_ref_frame_sign_bias: u32, | |
35 | alt_ref_frame: u32, | |
36 | alt_ref_frame_sign_bias: u32, | |
37 | lossless_flag: u32, | |
38 | ) -> Self { | |
39 | let _bitfield_1 = | |
40 | bindings::_VADecPictureParameterBufferVP9__bindgen_ty_1__bindgen_ty_1::new_bitfield_1( | |
41 | subsampling_x, | |
42 | subsampling_y, | |
43 | frame_type, | |
44 | show_frame, | |
45 | error_resilient_mode, | |
46 | intra_only, | |
47 | allow_high_precision_mv, | |
48 | mcomp_filter_type, | |
49 | frame_parallel_decoding_mode, | |
50 | reset_frame_context, | |
51 | refresh_frame_context, | |
52 | frame_context_idx, | |
53 | segmentation_enabled, | |
54 | segmentation_temporal_update, | |
55 | segmentation_update_map, | |
56 | last_ref_frame, | |
57 | last_ref_frame_sign_bias, | |
58 | golden_ref_frame, | |
59 | golden_ref_frame_sign_bias, | |
60 | alt_ref_frame, | |
61 | alt_ref_frame_sign_bias, | |
62 | lossless_flag, | |
63 | ); | |
64 | ||
65 | Self(bindings::_VADecPictureParameterBufferVP9__bindgen_ty_1 { | |
66 | bits: bindings::_VADecPictureParameterBufferVP9__bindgen_ty_1__bindgen_ty_1 { | |
67 | _bitfield_align_1: Default::default(), | |
68 | _bitfield_1, | |
69 | }, | |
70 | }) | |
71 | } | |
72 | ||
73 | /// Returns the inner FFI type. Useful for testing purposes. | |
74 | pub fn inner(&mut self) -> &bindings::_VADecPictureParameterBufferVP9__bindgen_ty_1 { | |
75 | &self.0 | |
76 | } | |
77 | } | |
78 | ||
79 | /// Wrapper over the `PictureParameterBufferVP9` FFI type. | |
80 | pub struct PictureParameterBufferVP9(Box<bindings::VADecPictureParameterBufferVP9>); | |
81 | ||
82 | impl PictureParameterBufferVP9 { | |
83 | /// Creates the wrapper | |
84 | #[allow(clippy::too_many_arguments)] | |
85 | pub fn new( | |
86 | frame_width: u16, | |
87 | frame_height: u16, | |
88 | reference_frames: [bindings::VASurfaceID; 8], | |
89 | pic_fields: &VP9PicFields, | |
90 | filter_level: u8, | |
91 | sharpness_level: u8, | |
92 | log2_tile_rows: u8, | |
93 | log2_tile_columns: u8, | |
94 | frame_header_length_in_bytes: u8, | |
95 | first_partition_size: u16, | |
96 | mb_segment_tree_probs: [u8; 7usize], | |
97 | segment_pred_probs: [u8; 3usize], | |
98 | profile: u8, | |
99 | bit_depth: u8, | |
100 | ) -> Self { | |
101 | let pic_fields = pic_fields.0; | |
102 | ||
103 | Self(Box::new(bindings::VADecPictureParameterBufferVP9 { | |
104 | frame_width, | |
105 | frame_height, | |
106 | reference_frames, | |
107 | pic_fields, | |
108 | filter_level, | |
109 | sharpness_level, | |
110 | log2_tile_rows, | |
111 | log2_tile_columns, | |
112 | frame_header_length_in_bytes, | |
113 | first_partition_size, | |
114 | mb_segment_tree_probs, | |
115 | segment_pred_probs, | |
116 | profile, | |
117 | bit_depth, | |
118 | va_reserved: Default::default(), | |
119 | })) | |
120 | } | |
121 | ||
122 | pub(crate) fn inner_mut(&mut self) -> &mut bindings::VADecPictureParameterBufferVP9 { | |
123 | self.0.as_mut() | |
124 | } | |
125 | ||
126 | /// Returns the inner FFI type. Useful for testing purposes. | |
127 | pub fn inner(&self) -> &bindings::VADecPictureParameterBufferVP9 { | |
128 | self.0.as_ref() | |
129 | } | |
130 | } | |
131 | ||
132 | /// Wrapper over the `segment_flags` bindgen field in `VASegmentParameterVP9`. | |
133 | pub struct VP9SegmentFlags(bindings::_VASegmentParameterVP9__bindgen_ty_1); | |
134 | ||
135 | impl VP9SegmentFlags { | |
136 | /// Creates the wrapper. | |
137 | pub fn new( | |
138 | segment_reference_enabled: u16, | |
139 | segment_reference: u16, | |
140 | segment_reference_skipped: u16, | |
141 | ) -> Self { | |
142 | let _bitfield_1 = | |
143 | bindings::_VASegmentParameterVP9__bindgen_ty_1__bindgen_ty_1::new_bitfield_1( | |
144 | segment_reference_enabled, | |
145 | segment_reference, | |
146 | segment_reference_skipped, | |
147 | ); | |
148 | ||
149 | Self(bindings::_VASegmentParameterVP9__bindgen_ty_1 { | |
150 | fields: bindings::_VASegmentParameterVP9__bindgen_ty_1__bindgen_ty_1 { | |
151 | _bitfield_align_1: Default::default(), | |
152 | _bitfield_1, | |
153 | __bindgen_padding_0: Default::default(), | |
154 | }, | |
155 | }) | |
156 | } | |
157 | ||
158 | /// Returns the inner FFI type. Useful for testing purposes. | |
159 | pub fn inner(&mut self) -> &bindings::_VASegmentParameterVP9__bindgen_ty_1 { | |
160 | &self.0 | |
161 | } | |
162 | } | |
163 | ||
164 | /// Wrapper over the `VASegmentParameterVP9` FFI type. | |
165 | pub struct SegmentParameterVP9(bindings::VASegmentParameterVP9); | |
166 | ||
167 | impl SegmentParameterVP9 { | |
168 | /// Creates the wrapper. | |
169 | pub fn new( | |
170 | segment_flags: &VP9SegmentFlags, | |
171 | filter_level: [[u8; 2usize]; 4usize], | |
172 | luma_ac_quant_scale: i16, | |
173 | luma_dc_quant_scale: i16, | |
174 | chroma_ac_quant_scale: i16, | |
175 | chroma_dc_quant_scale: i16, | |
176 | ) -> Self { | |
177 | let segment_flags = segment_flags.0; | |
178 | ||
179 | Self(bindings::VASegmentParameterVP9 { | |
180 | segment_flags, | |
181 | filter_level, | |
182 | luma_ac_quant_scale, | |
183 | luma_dc_quant_scale, | |
184 | chroma_ac_quant_scale, | |
185 | chroma_dc_quant_scale, | |
186 | va_reserved: Default::default(), | |
187 | }) | |
188 | } | |
189 | } | |
190 | ||
191 | /// Wrapper over the `VASliceParameterBufferVP9` FFI type. | |
192 | pub struct SliceParameterBufferVP9(Box<bindings::VASliceParameterBufferVP9>); | |
193 | ||
194 | impl SliceParameterBufferVP9 { | |
195 | /// Creates the wrapper. | |
196 | pub fn new( | |
197 | slice_data_size: u32, | |
198 | slice_data_offset: u32, | |
199 | slice_data_flag: u32, | |
200 | seg_param: [SegmentParameterVP9; 8usize], | |
201 | ) -> Self { | |
202 | let seg_param = seg_param.map(|param| param.0); | |
203 | ||
204 | Self(Box::new(bindings::VASliceParameterBufferVP9 { | |
205 | slice_data_size, | |
206 | slice_data_offset, | |
207 | slice_data_flag, | |
208 | seg_param, | |
209 | va_reserved: Default::default(), | |
210 | })) | |
211 | } | |
212 | ||
213 | pub(crate) fn inner_mut(&mut self) -> &mut bindings::VASliceParameterBufferVP9 { | |
214 | self.0.as_mut() | |
215 | } | |
216 | ||
217 | /// Returns the inner FFI type. Useful for testing purposes. | |
218 | pub fn inner(&self) -> &bindings::VASliceParameterBufferVP9 { | |
219 | self.0.as_ref() | |
220 | } | |
221 | } |