| 1 | |
| 2 | |
| 3 | use ec_va::sys::{VAPictureParameterBufferType, VASliceParameterBufferType, VASurfaceID}; |
| 4 | |
| 5 | use super::{INVALID_SURFACE, VaParam}; |
| 6 | use crate::va_bits; |
| 7 | |
| 8 | va_bits! { |
| 9 | |
| 10 | PicFields: u32 { |
| 11 | subsampling_x: 1, |
| 12 | subsampling_y: 1, |
| 13 | frame_type: 1, |
| 14 | show_frame: 1, |
| 15 | error_resilient_mode: 1, |
| 16 | intra_only: 1, |
| 17 | allow_high_precision_mv: 1, |
| 18 | mcomp_filter_type: 3, |
| 19 | frame_parallel_decoding_mode: 1, |
| 20 | reset_frame_context: 2, |
| 21 | refresh_frame_context: 1, |
| 22 | frame_context_idx: 2, |
| 23 | segmentation_enabled: 1, |
| 24 | segmentation_temporal_update: 1, |
| 25 | segmentation_update_map: 1, |
| 26 | last_ref_frame: 3, |
| 27 | last_ref_frame_sign_bias: 1, |
| 28 | golden_ref_frame: 3, |
| 29 | golden_ref_frame_sign_bias: 1, |
| 30 | alt_ref_frame: 3, |
| 31 | alt_ref_frame_sign_bias: 1, |
| 32 | lossless_flag: 1, |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | |
| 37 | #[repr(C)] |
| 38 | #[derive(Debug, Clone, Copy)] |
| 39 | pub struct PictureParameterBufferVP9 { |
| 40 | |
| 41 | pub frame_width: u16, |
| 42 | |
| 43 | pub frame_height: u16, |
| 44 | |
| 45 | pub reference_frames: [VASurfaceID; 8], |
| 46 | |
| 47 | pub pic_fields: PicFields, |
| 48 | |
| 49 | pub filter_level: u8, |
| 50 | |
| 51 | pub sharpness_level: u8, |
| 52 | |
| 53 | pub log2_tile_rows: u8, |
| 54 | |
| 55 | pub log2_tile_columns: u8, |
| 56 | |
| 57 | pub frame_header_length_in_bytes: u8, |
| 58 | |
| 59 | pub first_partition_size: u16, |
| 60 | |
| 61 | pub mb_segment_tree_probs: [u8; 7], |
| 62 | |
| 63 | pub segment_pred_probs: [u8; 3], |
| 64 | |
| 65 | pub profile: u8, |
| 66 | |
| 67 | pub bit_depth: u8, |
| 68 | pub(crate) va_reserved: [u32; 8], |
| 69 | } |
| 70 | |
| 71 | impl Default for PictureParameterBufferVP9 { |
| 72 | fn default() -> Self { |
| 73 | PictureParameterBufferVP9 { |
| 74 | frame_width: 0, |
| 75 | frame_height: 0, |
| 76 | reference_frames: [INVALID_SURFACE; 8], |
| 77 | pic_fields: PicFields::default(), |
| 78 | filter_level: 0, |
| 79 | sharpness_level: 0, |
| 80 | log2_tile_rows: 0, |
| 81 | log2_tile_columns: 0, |
| 82 | frame_header_length_in_bytes: 0, |
| 83 | first_partition_size: 0, |
| 84 | |
| 85 | |
| 86 | mb_segment_tree_probs: [255; 7], |
| 87 | segment_pred_probs: [255; 3], |
| 88 | profile: 0, |
| 89 | bit_depth: 8, |
| 90 | va_reserved: [0; 8], |
| 91 | } |
| 92 | } |
| 93 | } |
| 94 | |
| 95 | |
| 96 | |
| 97 | unsafe impl VaParam for PictureParameterBufferVP9 { |
| 98 | const TYPE: i32 = VAPictureParameterBufferType; |
| 99 | } |
| 100 | |
| 101 | va_bits! { |
| 102 | |
| 103 | SegmentFlags: u16 { |
| 104 | segment_reference_enabled: 1, |
| 105 | segment_reference: 2, |
| 106 | segment_reference_skipped: 1, |
| 107 | } |
| 108 | } |
| 109 | |
| 110 | |
| 111 | #[repr(C)] |
| 112 | #[derive(Debug, Clone, Copy, Default)] |
| 113 | pub struct SegmentParameterVP9 { |
| 114 | |
| 115 | pub segment_flags: SegmentFlags, |
| 116 | |
| 117 | pub filter_level: [[u8; 2]; 4], |
| 118 | |
| 119 | pub luma_ac_quant_scale: i16, |
| 120 | |
| 121 | pub luma_dc_quant_scale: i16, |
| 122 | |
| 123 | pub chroma_ac_quant_scale: i16, |
| 124 | |
| 125 | pub chroma_dc_quant_scale: i16, |
| 126 | pub(crate) va_reserved: [u32; 4], |
| 127 | } |
| 128 | |
| 129 | |
| 130 | #[repr(C)] |
| 131 | #[derive(Debug, Clone, Copy, Default)] |
| 132 | pub struct SliceParameterBufferVP9 { |
| 133 | |
| 134 | pub slice_data_size: u32, |
| 135 | |
| 136 | pub slice_data_offset: u32, |
| 137 | |
| 138 | pub slice_data_flag: u32, |
| 139 | |
| 140 | pub seg_param: [SegmentParameterVP9; 8], |
| 141 | pub(crate) va_reserved: [u32; 4], |
| 142 | } |
| 143 | |
| 144 | |
| 145 | unsafe impl VaParam for SliceParameterBufferVP9 { |
| 146 | const TYPE: i32 = VASliceParameterBufferType; |
| 147 | } |
| 148 | |
| 149 | |
| 150 | |
| 151 | |
| 152 | |
| 153 | |
| 154 | |
| 155 | |
| 156 | |
| 157 | |
| 158 | |
| 159 | |
| 160 | const _: () = { |
| 161 | use std::mem::{align_of, offset_of, size_of}; |
| 162 | |
| 163 | assert!( |
| 164 | size_of::<PictureParameterBufferVP9>() == 92 |
| 165 | && align_of::<PictureParameterBufferVP9>() == 4 |
| 166 | ); |
| 167 | assert!(offset_of!(PictureParameterBufferVP9, reference_frames) == 4); |
| 168 | assert!(offset_of!(PictureParameterBufferVP9, pic_fields) == 36); |
| 169 | assert!(offset_of!(PictureParameterBufferVP9, filter_level) == 40); |
| 170 | assert!(offset_of!(PictureParameterBufferVP9, first_partition_size) == 46); |
| 171 | assert!(offset_of!(PictureParameterBufferVP9, mb_segment_tree_probs) == 48); |
| 172 | assert!(offset_of!(PictureParameterBufferVP9, profile) == 58); |
| 173 | |
| 174 | assert!(size_of::<SegmentParameterVP9>() == 36 && align_of::<SegmentParameterVP9>() == 4); |
| 175 | assert!(offset_of!(SegmentParameterVP9, filter_level) == 2); |
| 176 | assert!(offset_of!(SegmentParameterVP9, luma_ac_quant_scale) == 10); |
| 177 | |
| 178 | assert!( |
| 179 | size_of::<SliceParameterBufferVP9>() == 316 && align_of::<SliceParameterBufferVP9>() == 4 |
| 180 | ); |
| 181 | assert!(offset_of!(SliceParameterBufferVP9, seg_param) == 12); |
| 182 | }; |