Skip to main content

moq_vaapi/buffer/
hevc.rs

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