]>
Commit | Line | Data |
---|---|---|
68362724 KS |
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::constants::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 | } |