forge
Explore
Log in

Don't you dare go Hollow

edith_codecs

Clone
★ 0

0 watching0 forksRust370.3 MiB9b67700Tahinli3 days ago4021 commits

jpeg_baseline.rs220 lines, 7.1 KiBHistoryRawDownload
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
7use crate::bindings;
8
9/// Wrapper over the `components` bindgen field in `VAPictureParameterBufferJPEGBaseline`.
10pub struct PictureParameterBufferJPEGBaselineComponent(
11 bindings::_VAPictureParameterBufferJPEGBaseline__bindgen_ty_1,
12);
13
14impl 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.
40pub struct PictureParameterBufferJPEGBaseline(Box<bindings::VAPictureParameterBufferJPEGBaseline>);
41
42impl 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`.
76pub struct VASliceParameterBufferJPEGBaselineComponent(
77 bindings::_VASliceParameterBufferJPEGBaseline__bindgen_ty_1,
78);
79
80impl 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.
100pub struct SliceParameterBufferJPEGBaseline(Box<bindings::VASliceParameterBufferJPEGBaseline>);
101
102impl 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.
140pub struct IQMatrixBufferJPEGBaseline(Box<bindings::VAIQMatrixBufferJPEGBaseline>);
141
142impl 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`.
167pub struct HuffmanTableBufferJPEGBaselineHuffmanTable(
168 bindings::_VAHuffmanTableBufferJPEGBaseline__bindgen_ty_1,
169);
170
171impl 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.
197pub struct HuffmanTableBufferJPEGBaseline(Box<bindings::VAHuffmanTableBufferJPEGBaseline>);
198
199impl 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}