forge
Explore
Log in

Don't you dare go Hollow

edith

Clone
★ 0

0 watching0 forksRust18.3 MiB2e2ed69Tahinli3 months ago69 commits

hevc.rs1154 lines, 41.5 KiBHistoryRawDownload
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 HEVC `VABuffer` types.
6
7use crate::bindings;
8
9/// Wrapper over the `VAPictureH264` FFI type.
10#[derive(Debug, Default, Copy, Clone, PartialEq, Eq)]
11pub struct PictureHEVC(bindings::VAPictureHEVC);
12
13impl PictureHEVC {
14 /// Creates the wrapper
15 pub fn new(picture_id: bindings::VASurfaceID, pic_order_cnt: i32, flags: u32) -> Self {
16 Self(bindings::VAPictureHEVC {
17 picture_id,
18 pic_order_cnt,
19 flags,
20 va_reserved: Default::default(),
21 })
22 }
23
24 /// Returns the `picture_id` field.
25 pub fn picture_id(&self) -> u32 {
26 self.0.picture_id
27 }
28
29 /// Returns the `pic_order_cnt` field.
30 pub fn pic_order_cnt(&self) -> i32 {
31 self.0.pic_order_cnt
32 }
33
34 /// Returns the `flags` field.
35 pub fn flags(&self) -> u32 {
36 self.0.flags
37 }
38}
39
40/// Wrapper over the `pic_fields` bindgen field in `VAPictureParameterBufferHEVC`.
41pub struct HevcPicFields(bindings::_VAPictureParameterBufferHEVC__bindgen_ty_1);
42
43impl HevcPicFields {
44 /// Creates the bindgen field
45 #[allow(clippy::too_many_arguments)]
46 pub fn new(
47 chroma_format_idc: u32,
48 separate_colour_plane_flag: u32,
49 pcm_enabled_flag: u32,
50 scaling_list_enabled_flag: u32,
51 transform_skip_enabled_flag: u32,
52 amp_enabled_flag: u32,
53 strong_intra_smoothing_enabled_flag: u32,
54 sign_data_hiding_enabled_flag: u32,
55 constrained_intra_pred_flag: u32,
56 cu_qp_delta_enabled_flag: u32,
57 weighted_pred_flag: u32,
58 weighted_bipred_flag: u32,
59 transquant_bypass_enabled_flag: u32,
60 tiles_enabled_flag: u32,
61 entropy_coding_sync_enabled_flag: u32,
62 pps_loop_filter_across_slices_enabled_flag: u32,
63 loop_filter_across_tiles_enabled_flag: u32,
64 pcm_loop_filter_disabled_flag: u32,
65 no_pic_reordering_flag: u32,
66 no_bi_pred_flag: u32,
67 ) -> Self {
68 let _bitfield_1 =
69 bindings::_VAPictureParameterBufferHEVC__bindgen_ty_1__bindgen_ty_1::new_bitfield_1(
70 chroma_format_idc,
71 separate_colour_plane_flag,
72 pcm_enabled_flag,
73 scaling_list_enabled_flag,
74 transform_skip_enabled_flag,
75 amp_enabled_flag,
76 strong_intra_smoothing_enabled_flag,
77 sign_data_hiding_enabled_flag,
78 constrained_intra_pred_flag,
79 cu_qp_delta_enabled_flag,
80 weighted_pred_flag,
81 weighted_bipred_flag,
82 transquant_bypass_enabled_flag,
83 tiles_enabled_flag,
84 entropy_coding_sync_enabled_flag,
85 pps_loop_filter_across_slices_enabled_flag,
86 loop_filter_across_tiles_enabled_flag,
87 pcm_loop_filter_disabled_flag,
88 no_pic_reordering_flag,
89 no_bi_pred_flag,
90 0,
91 );
92
93 Self(bindings::_VAPictureParameterBufferHEVC__bindgen_ty_1 {
94 bits: bindings::_VAPictureParameterBufferHEVC__bindgen_ty_1__bindgen_ty_1 {
95 _bitfield_align_1: Default::default(),
96 _bitfield_1,
97 },
98 })
99 }
100
101 /// Returns the inner FFI type. Useful for testing purposes.
102 pub fn inner(&mut self) -> &bindings::_VAPictureParameterBufferHEVC__bindgen_ty_1 {
103 &self.0
104 }
105}
106
107/// Wrapper over the `slice_parsing_fields` bindgen field in `VAPictureParameterBufferHEVC`.
108pub struct HevcSliceParsingFields(bindings::_VAPictureParameterBufferHEVC__bindgen_ty_2);
109
110impl HevcSliceParsingFields {
111 /// Creates the bindgen field
112 #[allow(clippy::too_many_arguments)]
113 pub fn new(
114 lists_modification_present_flag: u32,
115 long_term_ref_pics_present_flag: u32,
116 sps_temporal_mvp_enabled_flag: u32,
117 cabac_init_present_flag: u32,
118 output_flag_present_flag: u32,
119 dependent_slice_segments_enabled_flag: u32,
120 pps_slice_chroma_qp_offsets_present_flag: u32,
121 sample_adaptive_offset_enabled_flag: u32,
122 deblocking_filter_override_enabled_flag: u32,
123 pps_disable_deblocking_filter_flag: u32,
124 slice_segment_header_extension_present_flag: u32,
125 rap_pic_flag: u32,
126 idr_pic_flag: u32,
127 intra_pic_flag: u32,
128 ) -> Self {
129 let _bitfield_1 =
130 bindings::_VAPictureParameterBufferHEVC__bindgen_ty_2__bindgen_ty_1::new_bitfield_1(
131 lists_modification_present_flag,
132 long_term_ref_pics_present_flag,
133 sps_temporal_mvp_enabled_flag,
134 cabac_init_present_flag,
135 output_flag_present_flag,
136 dependent_slice_segments_enabled_flag,
137 pps_slice_chroma_qp_offsets_present_flag,
138 sample_adaptive_offset_enabled_flag,
139 deblocking_filter_override_enabled_flag,
140 pps_disable_deblocking_filter_flag,
141 slice_segment_header_extension_present_flag,
142 rap_pic_flag,
143 idr_pic_flag,
144 intra_pic_flag,
145 0,
146 );
147
148 Self(bindings::_VAPictureParameterBufferHEVC__bindgen_ty_2 {
149 bits: bindings::_VAPictureParameterBufferHEVC__bindgen_ty_2__bindgen_ty_1 {
150 _bitfield_align_1: Default::default(),
151 _bitfield_1,
152 },
153 })
154 }
155
156 /// Returns the inner FFI type. Useful for testing purposes.
157 pub fn inner(&mut self) -> &bindings::_VAPictureParameterBufferHEVC__bindgen_ty_2 {
158 &self.0
159 }
160}
161
162/// A wrapper over `VAPictureParameterBufferHEVC` FFI type
163pub struct PictureParameterBufferHEVC(Box<bindings::VAPictureParameterBufferHEVC>);
164
165impl PictureParameterBufferHEVC {
166 /// Creates the wrapper
167 #[allow(clippy::too_many_arguments)]
168 pub fn new(
169 curr_pic: PictureHEVC,
170 reference_frames: [PictureHEVC; 15],
171 pic_width_in_luma_samples: u16,
172 pic_height_in_luma_samples: u16,
173 pic_fields: &HevcPicFields,
174 sps_max_dec_pic_buffering_minus1: u8,
175 bit_depth_luma_minus8: u8,
176 bit_depth_chroma_minus8: u8,
177 pcm_sample_bit_depth_luma_minus1: u8,
178 pcm_sample_bit_depth_chroma_minus1: u8,
179 log2_min_luma_coding_block_size_minus3: u8,
180 log2_diff_max_min_luma_coding_block_size: u8,
181 log2_min_transform_block_size_minus2: u8,
182 log2_diff_max_min_transform_block_size: u8,
183 log2_min_pcm_luma_coding_block_size_minus3: u8,
184 log2_diff_max_min_pcm_luma_coding_block_size: u8,
185 max_transform_hierarchy_depth_intra: u8,
186 max_transform_hierarchy_depth_inter: u8,
187 init_qp_minus26: i8,
188 diff_cu_qp_delta_depth: u8,
189 pps_cb_qp_offset: i8,
190 pps_cr_qp_offset: i8,
191 log2_parallel_merge_level_minus2: u8,
192 num_tile_columns_minus1: u8,
193 num_tile_rows_minus1: u8,
194 column_width_minus1: [u16; 19],
195 row_height_minus1: [u16; 21],
196 slice_parsing_fields: &HevcSliceParsingFields,
197 log2_max_pic_order_cnt_lsb_minus4: u8,
198 num_short_term_ref_pic_sets: u8,
199 num_long_term_ref_pic_sps: u8,
200 num_ref_idx_l0_default_active_minus1: u8,
201 num_ref_idx_l1_default_active_minus1: u8,
202 pps_beta_offset_div2: i8,
203 pps_tc_offset_div2: i8,
204 num_extra_slice_header_bits: u8,
205 st_rps_bits: u32,
206 ) -> Self {
207 let reference_frames = (0..15usize)
208 .map(|i| reference_frames[i].0)
209 .collect::<Vec<_>>()
210 .try_into()
211 // try_into is guaranteed to work because the iterator and target array have the same
212 // size.
213 .unwrap();
214
215 let pic_fields = pic_fields.0;
216 let slice_parsing_fields = slice_parsing_fields.0;
217
218 Self(Box::new(bindings::VAPictureParameterBufferHEVC {
219 CurrPic: curr_pic.0,
220 ReferenceFrames: reference_frames,
221 pic_width_in_luma_samples,
222 pic_height_in_luma_samples,
223 pic_fields,
224 sps_max_dec_pic_buffering_minus1,
225 bit_depth_luma_minus8,
226 bit_depth_chroma_minus8,
227 pcm_sample_bit_depth_luma_minus1,
228 pcm_sample_bit_depth_chroma_minus1,
229 log2_min_luma_coding_block_size_minus3,
230 log2_diff_max_min_luma_coding_block_size,
231 log2_min_transform_block_size_minus2,
232 log2_diff_max_min_transform_block_size,
233 log2_min_pcm_luma_coding_block_size_minus3,
234 log2_diff_max_min_pcm_luma_coding_block_size,
235 max_transform_hierarchy_depth_intra,
236 max_transform_hierarchy_depth_inter,
237 init_qp_minus26,
238 diff_cu_qp_delta_depth,
239 pps_cb_qp_offset,
240 pps_cr_qp_offset,
241 log2_parallel_merge_level_minus2,
242 num_tile_columns_minus1,
243 num_tile_rows_minus1,
244 column_width_minus1,
245 row_height_minus1,
246 slice_parsing_fields,
247 log2_max_pic_order_cnt_lsb_minus4,
248 num_short_term_ref_pic_sets,
249 num_long_term_ref_pic_sps,
250 num_ref_idx_l0_default_active_minus1,
251 num_ref_idx_l1_default_active_minus1,
252 pps_beta_offset_div2,
253 pps_tc_offset_div2,
254 num_extra_slice_header_bits,
255 st_rps_bits,
256 va_reserved: Default::default(),
257 }))
258 }
259
260 pub(crate) fn inner_mut(&mut self) -> &mut bindings::VAPictureParameterBufferHEVC {
261 self.0.as_mut()
262 }
263
264 /// Returns the inner FFI type. Useful for testing purposes.
265 pub fn inner(&self) -> &bindings::VAPictureParameterBufferHEVC {
266 self.0.as_ref()
267 }
268}
269
270/// Wrapper over the `range_extension_pic_fields` bindgen field in `VAPictureParameterBufferHEVCRext`.
271pub struct HevcRangeExtensionPicFields(bindings::_VAPictureParameterBufferHEVCRext__bindgen_ty_1);
272
273impl HevcRangeExtensionPicFields {
274 /// Creates the bindgen field
275 #[allow(clippy::too_many_arguments)]
276 pub fn new(
277 transform_skip_rotation_enabled_flag: u32,
278 transform_skip_context_enabled_flag: u32,
279 implicit_rdpcm_enabled_flag: u32,
280 explicit_rdpcm_enabled_flag: u32,
281 extended_precision_processing_flag: u32,
282 intra_smoothing_disabled_flag: u32,
283 high_precision_offsets_enabled_flag: u32,
284 persistent_rice_adaptation_enabled_flag: u32,
285 cabac_bypass_alignment_enabled_flag: u32,
286 cross_component_prediction_enabled_flag: u32,
287 chroma_qp_offset_list_enabled_flag: u32,
288 ) -> Self {
289 let _bitfield_1 =
290 bindings::_VAPictureParameterBufferHEVCRext__bindgen_ty_1__bindgen_ty_1::new_bitfield_1(
291 transform_skip_rotation_enabled_flag,
292 transform_skip_context_enabled_flag,
293 implicit_rdpcm_enabled_flag,
294 explicit_rdpcm_enabled_flag,
295 extended_precision_processing_flag,
296 intra_smoothing_disabled_flag,
297 high_precision_offsets_enabled_flag,
298 persistent_rice_adaptation_enabled_flag,
299 cabac_bypass_alignment_enabled_flag,
300 cross_component_prediction_enabled_flag,
301 chroma_qp_offset_list_enabled_flag,
302 0,
303 );
304
305 Self(bindings::_VAPictureParameterBufferHEVCRext__bindgen_ty_1 {
306 bits: bindings::_VAPictureParameterBufferHEVCRext__bindgen_ty_1__bindgen_ty_1 {
307 _bitfield_align_1: Default::default(),
308 _bitfield_1,
309 },
310 })
311 }
312
313 /// Returns the inner FFI type. Useful for testing purposes.
314 pub fn inner(&mut self) -> &bindings::_VAPictureParameterBufferHEVCRext__bindgen_ty_1 {
315 &self.0
316 }
317}
318
319/// A wrapper over `VAPictureParameterBufferHEVCRext` FFI type
320pub struct PictureParameterBufferHEVCRext(Box<bindings::VAPictureParameterBufferHEVCRext>);
321
322impl PictureParameterBufferHEVCRext {
323 /// Creates the wrapper
324 #[allow(clippy::too_many_arguments)]
325 pub fn new(
326 range_extension_pic_fields: &HevcRangeExtensionPicFields,
327 diff_cu_chroma_qp_offset_depth: u8,
328 chroma_qp_offset_list_len_minus1: u8,
329 log2_sao_offset_scale_luma: u8,
330 log2_sao_offset_scale_chroma: u8,
331 log2_max_transform_skip_block_size_minus2: u8,
332 cb_qp_offset_list: [i8; 6usize],
333 cr_qp_offset_list: [i8; 6usize],
334 ) -> Self {
335 let range_extension_pic_fields = range_extension_pic_fields.0;
336
337 Self(Box::new(bindings::VAPictureParameterBufferHEVCRext {
338 range_extension_pic_fields,
339 diff_cu_chroma_qp_offset_depth,
340 chroma_qp_offset_list_len_minus1,
341 log2_sao_offset_scale_luma,
342 log2_sao_offset_scale_chroma,
343 log2_max_transform_skip_block_size_minus2,
344 cb_qp_offset_list,
345 cr_qp_offset_list,
346 }))
347 }
348
349 pub(crate) fn inner_mut(&mut self) -> &mut bindings::VAPictureParameterBufferHEVCRext {
350 self.0.as_mut()
351 }
352
353 /// Returns the inner FFI type. Useful for testing purposes.
354 pub fn inner(&self) -> &bindings::VAPictureParameterBufferHEVCRext {
355 self.0.as_ref()
356 }
357}
358
359/// Wrapper over the `screen_content_pic_fields` bindgen field in `VAPictureParameterBufferHEVCScc`.
360pub struct HevcScreenContentPicFields(bindings::_VAPictureParameterBufferHEVCScc__bindgen_ty_1);
361
362impl HevcScreenContentPicFields {
363 /// Creates the bindgen field
364 #[allow(clippy::too_many_arguments)]
365 pub fn new(
366 pps_curr_pic_ref_enabled_flag: u32,
367 palette_mode_enabled_flag: u32,
368 motion_vector_resolution_control_idc: u32,
369 intra_boundary_filtering_disabled_flag: u32,
370 residual_adaptive_colour_transform_enabled_flag: u32,
371 pps_slice_act_qp_offsets_present_flag: u32,
372 ) -> Self {
373 let _bitfield_1 =
374 bindings::_VAPictureParameterBufferHEVCScc__bindgen_ty_1__bindgen_ty_1::new_bitfield_1(
375 pps_curr_pic_ref_enabled_flag,
376 palette_mode_enabled_flag,
377 motion_vector_resolution_control_idc,
378 intra_boundary_filtering_disabled_flag,
379 residual_adaptive_colour_transform_enabled_flag,
380 pps_slice_act_qp_offsets_present_flag,
381 0,
382 );
383
384 Self(bindings::_VAPictureParameterBufferHEVCScc__bindgen_ty_1 {
385 bits: bindings::_VAPictureParameterBufferHEVCScc__bindgen_ty_1__bindgen_ty_1 {
386 _bitfield_align_1: Default::default(),
387 _bitfield_1,
388 },
389 })
390 }
391
392 /// Returns the inner FFI type. Useful for testing purposes.
393 pub fn inner(&mut self) -> &bindings::_VAPictureParameterBufferHEVCScc__bindgen_ty_1 {
394 &self.0
395 }
396}
397
398/// A wrapper over `VAPictureParameterBufferScc` FFI type
399pub struct PictureParameterBufferHEVCScc(Box<bindings::VAPictureParameterBufferHEVCScc>);
400
401impl PictureParameterBufferHEVCScc {
402 /// Creates the wrapper
403 #[allow(clippy::too_many_arguments)]
404 pub fn new(
405 screen_content_pic_fields: &HevcScreenContentPicFields,
406 palette_max_size: u8,
407 delta_palette_max_predictor_size: u8,
408 predictor_palette_size: u8,
409 predictor_palette_entries: [[u16; 128usize]; 3usize],
410 pps_act_y_qp_offset_plus5: i8,
411 pps_act_cb_qp_offset_plus5: i8,
412 pps_act_cr_qp_offset_plus3: i8,
413 ) -> Self {
414 let screen_content_pic_fields = screen_content_pic_fields.0;
415
416 Self(Box::new(bindings::VAPictureParameterBufferHEVCScc {
417 screen_content_pic_fields,
418 palette_max_size,
419 delta_palette_max_predictor_size,
420 predictor_palette_size,
421 predictor_palette_entries,
422 pps_act_y_qp_offset_plus5,
423 pps_act_cb_qp_offset_plus5,
424 pps_act_cr_qp_offset_plus3,
425 }))
426 }
427
428 pub(crate) fn inner_mut(&mut self) -> &mut bindings::VAPictureParameterBufferHEVCScc {
429 self.0.as_mut()
430 }
431
432 /// Returns the inner FFI type. Useful for testing purposes.
433 pub fn inner(&self) -> &bindings::VAPictureParameterBufferHEVCScc {
434 self.0.as_ref()
435 }
436}
437
438/// Wrapper over the `long_slice_flags` bindgen field in `VASliceParameterBufferHEVC`.
439pub struct HevcLongSliceFlags(bindings::_VASliceParameterBufferHEVC__bindgen_ty_1);
440
441impl HevcLongSliceFlags {
442 /// Creates the bindgen field
443 #[allow(clippy::too_many_arguments)]
444 pub fn new(
445 last_slice_of_pic: u32,
446 dependent_slice_segment_flag: u32,
447 slice_type: u32,
448 color_plane_id: u32,
449 slice_sao_luma_flag: u32,
450 slice_sao_chroma_flag: u32,
451 mvd_l1_zero_flag: u32,
452 cabac_init_flag: u32,
453 slice_temporal_mvp_enabled_flag: u32,
454 slice_deblocking_filter_disabled_flag: u32,
455 collocated_from_l0_flag: u32,
456 slice_loop_filter_across_slices_enabled_flag: u32,
457 ) -> Self {
458 let _bitfield_1 =
459 bindings::_VASliceParameterBufferHEVC__bindgen_ty_1__bindgen_ty_1::new_bitfield_1(
460 last_slice_of_pic,
461 dependent_slice_segment_flag,
462 slice_type,
463 color_plane_id,
464 slice_sao_luma_flag,
465 slice_sao_chroma_flag,
466 mvd_l1_zero_flag,
467 cabac_init_flag,
468 slice_temporal_mvp_enabled_flag,
469 slice_deblocking_filter_disabled_flag,
470 collocated_from_l0_flag,
471 slice_loop_filter_across_slices_enabled_flag,
472 0,
473 );
474
475 Self(bindings::_VASliceParameterBufferHEVC__bindgen_ty_1 {
476 fields: bindings::_VASliceParameterBufferHEVC__bindgen_ty_1__bindgen_ty_1 {
477 _bitfield_align_1: Default::default(),
478 _bitfield_1,
479 },
480 })
481 }
482
483 /// Returns the inner FFI type. Useful for testing purposes.
484 pub fn inner(&mut self) -> &bindings::_VASliceParameterBufferHEVC__bindgen_ty_1 {
485 &self.0
486 }
487}
488
489/// A wrapper over `VASliceParameterBufferHEVC` FFI type
490pub struct SliceParameterBufferHEVC(Box<bindings::VASliceParameterBufferHEVC>);
491
492impl SliceParameterBufferHEVC {
493 /// Creates the wrapper
494 #[allow(clippy::too_many_arguments)]
495 pub fn new(
496 slice_data_size: u32,
497 slice_data_offset: u32,
498 slice_data_flag: u32,
499 slice_data_byte_offset: u32,
500 slice_segment_address: u32,
501 ref_pic_list: [[u8; 15usize]; 2usize],
502 long_slice_flags: &HevcLongSliceFlags,
503 collocated_ref_idx: u8,
504 num_ref_idx_l0_active_minus1: u8,
505 num_ref_idx_l1_active_minus1: u8,
506 slice_qp_delta: i8,
507 slice_cb_qp_offset: i8,
508 slice_cr_qp_offset: i8,
509 slice_beta_offset_div2: i8,
510 slice_tc_offset_div2: i8,
511 luma_log2_weight_denom: u8,
512 delta_chroma_log2_weight_denom: i8,
513 delta_luma_weight_l0: [i8; 15usize],
514 luma_offset_l0: [i8; 15usize],
515 delta_chroma_weight_l0: [[i8; 2usize]; 15usize],
516 chroma_offset_l0: [[i8; 2usize]; 15usize],
517 delta_luma_weight_l1: [i8; 15usize],
518 luma_offset_l1: [i8; 15usize],
519 delta_chroma_weight_l1: [[i8; 2usize]; 15usize],
520 chroma_offset_l1: [[i8; 2usize]; 15usize],
521 five_minus_max_num_merge_cand: u8,
522 num_entry_point_offsets: u16,
523 entry_offset_to_subset_array: u16,
524 slice_data_num_emu_prevn_bytes: u16,
525 ) -> Self {
526 let long_slice_flags = long_slice_flags.0;
527
528 Self(Box::new(bindings::VASliceParameterBufferHEVC {
529 slice_data_size,
530 slice_data_offset,
531 slice_data_flag,
532 slice_data_byte_offset,
533 slice_segment_address,
534 RefPicList: ref_pic_list,
535 LongSliceFlags: long_slice_flags,
536 collocated_ref_idx,
537 num_ref_idx_l0_active_minus1,
538 num_ref_idx_l1_active_minus1,
539 slice_qp_delta,
540 slice_cb_qp_offset,
541 slice_cr_qp_offset,
542 slice_beta_offset_div2,
543 slice_tc_offset_div2,
544 luma_log2_weight_denom,
545 delta_chroma_log2_weight_denom,
546 delta_luma_weight_l0,
547 luma_offset_l0,
548 delta_chroma_weight_l0,
549 ChromaOffsetL0: chroma_offset_l0,
550 delta_luma_weight_l1,
551 luma_offset_l1,
552 delta_chroma_weight_l1,
553 ChromaOffsetL1: chroma_offset_l1,
554 five_minus_max_num_merge_cand,
555 num_entry_point_offsets,
556 entry_offset_to_subset_array,
557 slice_data_num_emu_prevn_bytes,
558 va_reserved: Default::default(),
559 }))
560 }
561
562 /// Set this slice as the last one after creation. Implementations may only
563 /// be able to conveniently see if this is the last slice after it has been
564 /// created.
565 pub fn set_as_last(&mut self) {
566 // Safe because we know that both fields are valid at all times (just a
567 // different view on the data), and we are mutating through the bindgen
568 // function, respecting the padding in place.
569 unsafe { self.inner_mut().LongSliceFlags.fields.set_LastSliceOfPic(1) };
570 }
571
572 pub(crate) fn inner_mut(&mut self) -> &mut bindings::VASliceParameterBufferHEVC {
573 self.0.as_mut()
574 }
575
576 /// Returns the inner FFI type. Useful for testing purposes.
577 pub fn inner(&self) -> &bindings::VASliceParameterBufferHEVC {
578 self.0.as_ref()
579 }
580}
581
582/// Wrapper over the `slice_ext_flags` bindgen field in `VASliceParameterBufferHEVCRext`.
583pub struct HevcSliceExtFlags(bindings::_VASliceParameterBufferHEVCRext__bindgen_ty_1);
584
585impl HevcSliceExtFlags {
586 /// Creates the bindgen field
587 #[allow(clippy::too_many_arguments)]
588 pub fn new(cu_chroma_qp_offset_enabled_flag: u32, use_integer_mv_flag: u32) -> Self {
589 let _bitfield_1 =
590 bindings::_VASliceParameterBufferHEVCRext__bindgen_ty_1__bindgen_ty_1::new_bitfield_1(
591 cu_chroma_qp_offset_enabled_flag,
592 use_integer_mv_flag,
593 0,
594 );
595
596 Self(bindings::_VASliceParameterBufferHEVCRext__bindgen_ty_1 {
597 bits: bindings::_VASliceParameterBufferHEVCRext__bindgen_ty_1__bindgen_ty_1 {
598 _bitfield_align_1: Default::default(),
599 _bitfield_1,
600 },
601 })
602 }
603
604 /// Returns the inner FFI type. Useful for testing purposes.
605 pub fn inner(&mut self) -> &bindings::_VASliceParameterBufferHEVCRext__bindgen_ty_1 {
606 &self.0
607 }
608}
609
610/// A wrapper over `VASliceParameterBufferHEVCRext` FFI type
611pub struct SliceParameterBufferHEVCRext(Box<bindings::VASliceParameterBufferHEVCRext>);
612
613impl SliceParameterBufferHEVCRext {
614 /// Creates the wrapper
615 #[allow(clippy::too_many_arguments)]
616 pub fn new(
617 luma_offset_l0: [i16; 15usize],
618 chroma_offset_l0: [[i16; 2usize]; 15usize],
619 luma_offset_l1: [i16; 15usize],
620 chroma_offset_l1: [[i16; 2usize]; 15usize],
621 slice_ext_flags: &HevcSliceExtFlags,
622 slice_act_y_qp_offset: i8,
623 slice_act_cb_qp_offset: i8,
624 slice_act_cr_qp_offset: i8,
625 ) -> Self {
626 let slice_ext_flags = slice_ext_flags.0;
627
628 Self(Box::new(bindings::VASliceParameterBufferHEVCRext {
629 luma_offset_l0,
630 ChromaOffsetL0: chroma_offset_l0,
631 luma_offset_l1,
632 ChromaOffsetL1: chroma_offset_l1,
633 slice_ext_flags,
634 slice_act_y_qp_offset,
635 slice_act_cb_qp_offset,
636 slice_act_cr_qp_offset,
637 }))
638 }
639
640 pub(crate) fn inner_mut(&mut self) -> &mut bindings::VASliceParameterBufferHEVCRext {
641 self.0.as_mut()
642 }
643
644 /// Returns the inner FFI type. Useful for testing purposes.
645 pub fn inner(&self) -> &bindings::VASliceParameterBufferHEVCRext {
646 self.0.as_ref()
647 }
648}
649
650/// A wrapper over `VAIQMatrixBufferHEVC` FFI type
651pub struct IQMatrixBufferHEVC(Box<bindings::VAIQMatrixBufferHEVC>);
652
653impl IQMatrixBufferHEVC {
654 /// Creates the wrapper
655 #[allow(clippy::too_many_arguments)]
656 pub fn new(
657 scaling_list4x4: [[u8; 16usize]; 6usize],
658 scaling_list8x8: [[u8; 64usize]; 6usize],
659 scaling_list16x16: [[u8; 64usize]; 6usize],
660 scaling_list32x32: [[u8; 64usize]; 2usize],
661 scaling_list_dc16x16: [u8; 6usize],
662 scaling_list_dc32x32: [u8; 2usize],
663 ) -> Self {
664 Self(Box::new(bindings::VAIQMatrixBufferHEVC {
665 ScalingList4x4: scaling_list4x4,
666 ScalingList8x8: scaling_list8x8,
667 ScalingList16x16: scaling_list16x16,
668 ScalingList32x32: scaling_list32x32,
669 ScalingListDC16x16: scaling_list_dc16x16,
670 ScalingListDC32x32: scaling_list_dc32x32,
671 va_reserved: Default::default(),
672 }))
673 }
674
675 pub(crate) fn inner_mut(&mut self) -> &mut bindings::VAIQMatrixBufferHEVC {
676 self.0.as_mut()
677 }
678
679 /// Returns the inner FFI type. Useful for testing purposes.
680 pub fn inner(&self) -> &bindings::VAIQMatrixBufferHEVC {
681 self.0.as_ref()
682 }
683}
684
685pub struct HEVCEncSeqFields(bindings::_VAEncSequenceParameterBufferHEVC__bindgen_ty_1);
686
687impl HEVCEncSeqFields {
688 #[allow(clippy::too_many_arguments)]
689 pub fn new(
690 chroma_format_idc: u32,
691 separate_colour_plane_flag: u32,
692 bit_depth_luma_minus8: u32,
693 bit_depth_chroma_minus8: u32,
694 scaling_list_enabled_flag: u32,
695 strong_intra_smoothing_enabled_flag: u32,
696 amp_enabled_flag: u32,
697 sample_adaptive_offset_enabled_flag: u32,
698 pcm_enabled_flag: u32,
699 pcm_loop_filter_disabled_flag: u32,
700 sps_temporal_mvp_enabled_flag: u32,
701 low_delay_seq: u32,
702 hierachical_flag: u32,
703 ) -> Self {
704 let _bitfield_1 =
705 bindings::_VAEncSequenceParameterBufferHEVC__bindgen_ty_1__bindgen_ty_1::new_bitfield_1(
706 chroma_format_idc,
707 separate_colour_plane_flag,
708 bit_depth_luma_minus8,
709 bit_depth_chroma_minus8,
710 scaling_list_enabled_flag,
711 strong_intra_smoothing_enabled_flag,
712 amp_enabled_flag,
713 sample_adaptive_offset_enabled_flag,
714 pcm_enabled_flag,
715 pcm_loop_filter_disabled_flag,
716 sps_temporal_mvp_enabled_flag,
717 low_delay_seq,
718 hierachical_flag,
719 Default::default(),
720 );
721
722 Self(bindings::_VAEncSequenceParameterBufferHEVC__bindgen_ty_1 {
723 bits: bindings::_VAEncSequenceParameterBufferHEVC__bindgen_ty_1__bindgen_ty_1 {
724 _bitfield_align_1: Default::default(),
725 _bitfield_1,
726 },
727 })
728 }
729}
730
731#[derive(Default)]
732pub struct HevcEncVuiFields(bindings::_VAEncSequenceParameterBufferHEVC__bindgen_ty_2);
733
734impl HevcEncVuiFields {
735 #[allow(clippy::too_many_arguments)]
736 pub fn new(
737 aspect_ratio_info_present_flag: u32,
738 neutral_chroma_indication_flag: u32,
739 field_seq_flag: u32,
740 vui_timing_info_present_flag: u32,
741 bitstream_restriction_flag: u32,
742 tiles_fixed_structure_flag: u32,
743 motion_vectors_over_pic_boundaries_flag: u32,
744 restricted_ref_pic_lists_flag: u32,
745 log2_max_mv_length_horizontal: u32,
746 log2_max_mv_length_vertical: u32,
747 ) -> Self {
748 let _bitfield_1 =
749 bindings::_VAEncSequenceParameterBufferHEVC__bindgen_ty_2__bindgen_ty_1::new_bitfield_1(
750 aspect_ratio_info_present_flag,
751 neutral_chroma_indication_flag,
752 field_seq_flag,
753 vui_timing_info_present_flag,
754 bitstream_restriction_flag,
755 tiles_fixed_structure_flag,
756 motion_vectors_over_pic_boundaries_flag,
757 restricted_ref_pic_lists_flag,
758 log2_max_mv_length_horizontal,
759 log2_max_mv_length_vertical,
760 );
761
762 Self(bindings::_VAEncSequenceParameterBufferHEVC__bindgen_ty_2 {
763 bits: bindings::_VAEncSequenceParameterBufferHEVC__bindgen_ty_2__bindgen_ty_1 {
764 _bitfield_align_1: Default::default(),
765 _bitfield_1,
766 __bindgen_padding_0: Default::default(),
767 },
768 })
769 }
770}
771
772pub struct HevcEncSeqSccFields(bindings::_VAEncSequenceParameterBufferHEVC__bindgen_ty_3);
773
774impl HevcEncSeqSccFields {
775 pub fn new(palette_mode_enabled_flag: u32) -> Self {
776 let _bitfield_1 =
777 bindings::_VAEncSequenceParameterBufferHEVC__bindgen_ty_3__bindgen_ty_1::new_bitfield_1(
778 palette_mode_enabled_flag,
779 Default::default(),
780 );
781
782 Self(bindings::_VAEncSequenceParameterBufferHEVC__bindgen_ty_3 {
783 bits: bindings::_VAEncSequenceParameterBufferHEVC__bindgen_ty_3__bindgen_ty_1 {
784 _bitfield_align_1: Default::default(),
785 _bitfield_1,
786 },
787 })
788 }
789}
790
791pub struct EncSequenceParameterBufferHEVC(Box<bindings::VAEncSequenceParameterBufferHEVC>);
792
793impl EncSequenceParameterBufferHEVC {
794 #[allow(clippy::too_many_arguments)]
795 pub fn new(
796 general_profile_idc: u8,
797 general_level_idc: u8,
798 general_tier_flag: u8,
799 intra_period: u32,
800 intra_idr_period: u32,
801 ip_period: u32,
802 bits_per_second: u32,
803 pic_width_in_luma_samples: u16,
804 pic_height_in_luma_samples: u16,
805 seq_fields: &HEVCEncSeqFields,
806 log2_min_luma_coding_block_size_minus3: u8,
807 log2_diff_max_min_luma_coding_block_size: u8,
808 log2_min_transform_block_size_minus2: u8,
809 log2_diff_max_min_transform_block_size: u8,
810 max_transform_hierarchy_depth_inter: u8,
811 max_transform_hierarchy_depth_intra: u8,
812 pcm_sample_bit_depth_luma_minus1: u32,
813 pcm_sample_bit_depth_chroma_minus1: u32,
814 log2_min_pcm_luma_coding_block_size_minus3: u32,
815 log2_max_pcm_luma_coding_block_size_minus3: u32,
816 vui_fields: Option<HevcEncVuiFields>,
817 aspect_ratio_idc: u8,
818 sar_width: u32,
819 sar_height: u32,
820 vui_num_units_in_tick: u32,
821 vui_time_scale: u32,
822 min_spatial_segmentation_idc: u16,
823 max_bytes_per_pic_denom: u8,
824 max_bits_per_min_cu_denom: u8,
825 scc_fields: &HevcEncSeqSccFields,
826 ) -> Self {
827 let seq_fields = seq_fields.0;
828 let vui_parameters_present_flag = vui_fields.is_some() as u8;
829 let vui_fields = vui_fields.unwrap_or_default().0;
830 let scc_fields = scc_fields.0;
831
832 Self(Box::new(bindings::VAEncSequenceParameterBufferHEVC {
833 general_profile_idc,
834 general_level_idc,
835 general_tier_flag,
836 intra_period,
837 intra_idr_period,
838 ip_period,
839 bits_per_second,
840 pic_width_in_luma_samples,
841 pic_height_in_luma_samples,
842 seq_fields,
843 log2_min_luma_coding_block_size_minus3,
844 log2_diff_max_min_luma_coding_block_size,
845 log2_min_transform_block_size_minus2,
846 log2_diff_max_min_transform_block_size,
847 max_transform_hierarchy_depth_inter,
848 max_transform_hierarchy_depth_intra,
849 pcm_sample_bit_depth_luma_minus1,
850 pcm_sample_bit_depth_chroma_minus1,
851 log2_min_pcm_luma_coding_block_size_minus3,
852 log2_max_pcm_luma_coding_block_size_minus3,
853 vui_parameters_present_flag,
854 vui_fields,
855 aspect_ratio_idc,
856 sar_width,
857 sar_height,
858 vui_num_units_in_tick,
859 vui_time_scale,
860 min_spatial_segmentation_idc,
861 max_bytes_per_pic_denom,
862 max_bits_per_min_cu_denom,
863 scc_fields,
864 va_reserved: Default::default(),
865 }))
866 }
867
868 pub(crate) fn inner_mut(&mut self) -> &mut bindings::VAEncSequenceParameterBufferHEVC {
869 &mut self.0
870 }
871}
872
873pub struct HEVCEncPicFields(bindings::_VAEncPictureParameterBufferHEVC__bindgen_ty_1);
874
875impl HEVCEncPicFields {
876 #[allow(clippy::too_many_arguments)]
877 pub fn new(
878 idr_pic_flag: u32,
879 coding_type: u32,
880 reference_pic_flag: u32,
881 dependent_slice_segments_enabled_flag: u32,
882 sign_data_hiding_enabled_flag: u32,
883 constrained_intra_pred_flag: u32,
884 transform_skip_enabled_flag: u32,
885 cu_qp_delta_enabled_flag: u32,
886 weighted_pred_flag: u32,
887 weighted_bipred_flag: u32,
888 transquant_bypass_enabled_flag: u32,
889 tiles_enabled_flag: u32,
890 entropy_coding_sync_enabled_flag: u32,
891 loop_filter_across_tiles_enabled_flag: u32,
892 pps_loop_filter_across_slices_enabled_flag: u32,
893 scaling_list_data_present_flag: u32,
894 screen_content_flag: u32,
895 enable_gpu_weighted_prediction: u32,
896 no_output_of_prior_pics_flag: u32,
897 ) -> Self {
898 let _bitfield_1 =
899 bindings::_VAEncPictureParameterBufferHEVC__bindgen_ty_1__bindgen_ty_1::new_bitfield_1(
900 idr_pic_flag,
901 coding_type,
902 reference_pic_flag,
903 dependent_slice_segments_enabled_flag,
904 sign_data_hiding_enabled_flag,
905 constrained_intra_pred_flag,
906 transform_skip_enabled_flag,
907 cu_qp_delta_enabled_flag,
908 weighted_pred_flag,
909 weighted_bipred_flag,
910 transquant_bypass_enabled_flag,
911 tiles_enabled_flag,
912 entropy_coding_sync_enabled_flag,
913 loop_filter_across_tiles_enabled_flag,
914 pps_loop_filter_across_slices_enabled_flag,
915 scaling_list_data_present_flag,
916 screen_content_flag,
917 enable_gpu_weighted_prediction,
918 no_output_of_prior_pics_flag,
919 Default::default(),
920 );
921
922 Self(bindings::_VAEncPictureParameterBufferHEVC__bindgen_ty_1 {
923 bits: bindings::_VAEncPictureParameterBufferHEVC__bindgen_ty_1__bindgen_ty_1 {
924 _bitfield_align_1: Default::default(),
925 _bitfield_1,
926 },
927 })
928 }
929}
930
931pub struct HevcEncPicSccFields(bindings::_VAEncPictureParameterBufferHEVC__bindgen_ty_2);
932
933impl HevcEncPicSccFields {
934 pub fn new(pps_curr_pic_ref_enabled_flag: u16) -> Self {
935 let _bitfield_1 =
936 bindings::_VAEncPictureParameterBufferHEVC__bindgen_ty_2__bindgen_ty_1::new_bitfield_1(
937 pps_curr_pic_ref_enabled_flag,
938 Default::default(),
939 );
940
941 Self(bindings::_VAEncPictureParameterBufferHEVC__bindgen_ty_2 {
942 bits: bindings::_VAEncPictureParameterBufferHEVC__bindgen_ty_2__bindgen_ty_1 {
943 _bitfield_align_1: Default::default(),
944 _bitfield_1,
945 },
946 })
947 }
948}
949
950pub struct EncPictureParameterBufferHEVC(Box<bindings::VAEncPictureParameterBufferHEVC>);
951
952impl EncPictureParameterBufferHEVC {
953 #[allow(clippy::too_many_arguments)]
954 pub fn new(
955 decoded_curr_pic: PictureHEVC,
956 reference_frames: [PictureHEVC; 15usize],
957 coded_buf: bindings::VABufferID,
958 collocated_ref_pic_index: u8,
959 last_picture: u8,
960 pic_init_qp: u8,
961 diff_cu_qp_delta_depth: u8,
962 pps_cb_qp_offset: i8,
963 pps_cr_qp_offset: i8,
964 num_tile_columns_minus1: u8,
965 num_tile_rows_minus1: u8,
966 column_width_minus1: [u8; 19usize],
967 row_height_minus1: [u8; 21usize],
968 log2_parallel_merge_level_minus2: u8,
969 ctu_max_bitsize_allowed: u8,
970 num_ref_idx_l0_default_active_minus1: u8,
971 num_ref_idx_l1_default_active_minus1: u8,
972 slice_pic_parameter_set_id: u8,
973 nal_unit_type: u8,
974 pic_fields: &HEVCEncPicFields,
975 hierarchical_level_plus1: u8,
976 va_byte_reserved: u8,
977 scc_fields: &HevcEncPicSccFields,
978 ) -> Self {
979 let decoded_curr_pic = decoded_curr_pic.0;
980 let reference_frames = (0..15usize)
981 .map(|i| reference_frames[i].0)
982 .collect::<Vec<_>>()
983 .try_into()
984 // try_into is guaranteed to work because the iterator and target array have the same
985 // size.
986 .unwrap();
987
988 let pic_fields = pic_fields.0;
989 let scc_fields = scc_fields.0;
990
991 Self(Box::new(bindings::VAEncPictureParameterBufferHEVC {
992 decoded_curr_pic,
993 reference_frames,
994 coded_buf,
995 collocated_ref_pic_index,
996 last_picture,
997 pic_init_qp,
998 diff_cu_qp_delta_depth,
999 pps_cb_qp_offset,
1000 pps_cr_qp_offset,
1001 num_tile_columns_minus1,
1002 num_tile_rows_minus1,
1003 column_width_minus1,
1004 row_height_minus1,
1005 log2_parallel_merge_level_minus2,
1006 ctu_max_bitsize_allowed,
1007 num_ref_idx_l0_default_active_minus1,
1008 num_ref_idx_l1_default_active_minus1,
1009 slice_pic_parameter_set_id,
1010 nal_unit_type,
1011 pic_fields,
1012 hierarchical_level_plus1,
1013 va_byte_reserved,
1014 scc_fields,
1015 va_reserved: Default::default(),
1016 }))
1017 }
1018
1019 pub(crate) fn inner_mut(&mut self) -> &mut bindings::VAEncPictureParameterBufferHEVC {
1020 &mut self.0
1021 }
1022}
1023
1024pub struct HevcEncSliceFields(bindings::_VAEncSliceParameterBufferHEVC__bindgen_ty_1);
1025
1026impl HevcEncSliceFields {
1027 #[allow(clippy::too_many_arguments)]
1028 pub fn new(
1029 last_slice_of_pic_flag: u32,
1030 dependent_slice_segment_flag: u32,
1031 colour_plane_id: u32,
1032 slice_temporal_mvp_enabled_flag: u32,
1033 slice_sao_luma_flag: u32,
1034 slice_sao_chroma_flag: u32,
1035 num_ref_idx_active_override_flag: u32,
1036 mvd_l1_zero_flag: u32,
1037 cabac_init_flag: u32,
1038 slice_deblocking_filter_disabled_flag: u32,
1039 slice_loop_filter_across_slices_enabled_flag: u32,
1040 collocated_from_l0_flag: u32,
1041 ) -> Self {
1042 let _bitfield_1 =
1043 bindings::_VAEncSliceParameterBufferHEVC__bindgen_ty_1__bindgen_ty_1::new_bitfield_1(
1044 last_slice_of_pic_flag,
1045 dependent_slice_segment_flag,
1046 colour_plane_id,
1047 slice_temporal_mvp_enabled_flag,
1048 slice_sao_luma_flag,
1049 slice_sao_chroma_flag,
1050 num_ref_idx_active_override_flag,
1051 mvd_l1_zero_flag,
1052 cabac_init_flag,
1053 slice_deblocking_filter_disabled_flag,
1054 slice_loop_filter_across_slices_enabled_flag,
1055 collocated_from_l0_flag,
1056 );
1057
1058 Self(bindings::_VAEncSliceParameterBufferHEVC__bindgen_ty_1 {
1059 bits: bindings::_VAEncSliceParameterBufferHEVC__bindgen_ty_1__bindgen_ty_1 {
1060 _bitfield_align_1: Default::default(),
1061 _bitfield_1,
1062 __bindgen_padding_0: Default::default(),
1063 },
1064 })
1065 }
1066}
1067
1068pub struct EncSliceParameterBufferHEVC(Box<bindings::VAEncSliceParameterBufferHEVC>);
1069
1070impl EncSliceParameterBufferHEVC {
1071 #[allow(clippy::too_many_arguments)]
1072 pub fn new(
1073 slice_segment_address: u32,
1074 num_ctu_in_slice: u32,
1075 slice_type: u8,
1076 slice_pic_parameter_set_id: u8,
1077 num_ref_idx_l0_active_minus1: u8,
1078 num_ref_idx_l1_active_minus1: u8,
1079 ref_pic_list0: [PictureHEVC; 15usize],
1080 ref_pic_list1: [PictureHEVC; 15usize],
1081 luma_log2_weight_denom: u8,
1082 delta_chroma_log2_weight_denom: i8,
1083 delta_luma_weight_l0: [i8; 15usize],
1084 luma_offset_l0: [i8; 15usize],
1085 delta_chroma_weight_l0: [[i8; 2usize]; 15usize],
1086 chroma_offset_l0: [[i8; 2usize]; 15usize],
1087 delta_luma_weight_l1: [i8; 15usize],
1088 luma_offset_l1: [i8; 15usize],
1089 delta_chroma_weight_l1: [[i8; 2usize]; 15usize],
1090 chroma_offset_l1: [[i8; 2usize]; 15usize],
1091 max_num_merge_cand: u8,
1092 slice_qp_delta: i8,
1093 slice_cb_qp_offset: i8,
1094 slice_cr_qp_offset: i8,
1095 slice_beta_offset_div2: i8,
1096 slice_tc_offset_div2: i8,
1097 slice_fields: &HevcEncSliceFields,
1098 pred_weight_table_bit_offset: u32,
1099 pred_weight_table_bit_length: u32,
1100 ) -> Self {
1101 let ref_pic_list0 = (0..15usize)
1102 .map(|i| ref_pic_list0[i].0)
1103 .collect::<Vec<_>>()
1104 .try_into()
1105 // try_into is guaranteed to work because the iterator and target array have the same
1106 // size.
1107 .unwrap();
1108
1109 let ref_pic_list1 = (0..15usize)
1110 .map(|i| ref_pic_list1[i].0)
1111 .collect::<Vec<_>>()
1112 .try_into()
1113 // try_into is guaranteed to work because the iterator and target array have the same
1114 // size.
1115 .unwrap();
1116
1117 let slice_fields = slice_fields.0;
1118
1119 Self(Box::new(bindings::VAEncSliceParameterBufferHEVC {
1120 slice_segment_address,
1121 num_ctu_in_slice,
1122 slice_type,
1123 slice_pic_parameter_set_id,
1124 num_ref_idx_l0_active_minus1,
1125 num_ref_idx_l1_active_minus1,
1126 ref_pic_list0,
1127 ref_pic_list1,
1128 luma_log2_weight_denom,
1129 delta_chroma_log2_weight_denom,
1130 delta_luma_weight_l0,
1131 luma_offset_l0,
1132 delta_chroma_weight_l0,
1133 chroma_offset_l0,
1134 delta_luma_weight_l1,
1135 luma_offset_l1,
1136 delta_chroma_weight_l1,
1137 chroma_offset_l1,
1138 max_num_merge_cand,
1139 slice_qp_delta,
1140 slice_cb_qp_offset,
1141 slice_cr_qp_offset,
1142 slice_beta_offset_div2,
1143 slice_tc_offset_div2,
1144 slice_fields,
1145 pred_weight_table_bit_offset,
1146 pred_weight_table_bit_length,
1147 va_reserved: Default::default(),
1148 }))
1149 }
1150
1151 pub(crate) fn inner_mut(&mut self) -> &mut bindings::VAEncSliceParameterBufferHEVC {
1152 &mut self.0
1153 }
1154}