| 1 |
// TODO: Use core::ffi once we depend on Rust >= 1.64 |
| 2 |
use std::os::raw::{c_char, c_int, c_uint, c_void}; |
| 3 |
|
| 4 |
pub const DAV1D_OBU_SEQ_HDR: Dav1dObuType = 1; |
| 5 |
pub const DAV1D_OBU_TD: Dav1dObuType = 2; |
| 6 |
pub const DAV1D_OBU_FRAME_HDR: Dav1dObuType = 3; |
| 7 |
pub const DAV1D_OBU_TILE_GRP: Dav1dObuType = 4; |
| 8 |
pub const DAV1D_OBU_METADATA: Dav1dObuType = 5; |
| 9 |
pub const DAV1D_OBU_FRAME: Dav1dObuType = 6; |
| 10 |
pub const DAV1D_OBU_REDUNDANT_FRAME_HDR: Dav1dObuType = 7; |
| 11 |
pub const DAV1D_OBU_PADDING: Dav1dObuType = 15; |
| 12 |
pub type Dav1dObuType = c_uint; |
| 13 |
|
| 14 |
pub const DAV1D_TX_4X4_ONLY: Dav1dTxfmMode = 0; |
| 15 |
pub const DAV1D_TX_LARGEST: Dav1dTxfmMode = 1; |
| 16 |
pub const DAV1D_TX_SWITCHABLE: Dav1dTxfmMode = 2; |
| 17 |
pub const DAV1D_N_TX_MODES: Dav1dTxfmMode = 3; |
| 18 |
pub type Dav1dTxfmMode = c_uint; |
| 19 |
|
| 20 |
pub const DAV1D_FILTER_8TAP_REGULAR: Dav1dFilterMode = 0; |
| 21 |
pub const DAV1D_FILTER_8TAP_SMOOTH: Dav1dFilterMode = 1; |
| 22 |
pub const DAV1D_FILTER_8TAP_SHARP: Dav1dFilterMode = 2; |
| 23 |
pub const DAV1D_N_SWITCHABLE_FILTERS: Dav1dFilterMode = 3; |
| 24 |
pub const DAV1D_FILTER_BILINEAR: Dav1dFilterMode = 3; |
| 25 |
pub const DAV1D_N_FILTERS: Dav1dFilterMode = 4; |
| 26 |
pub const DAV1D_FILTER_SWITCHABLE: Dav1dFilterMode = 4; |
| 27 |
pub type Dav1dFilterMode = c_uint; |
| 28 |
|
| 29 |
pub const DAV1D_OFF: Dav1dAdaptiveBoolean = 0; |
| 30 |
pub const DAV1D_ON: Dav1dAdaptiveBoolean = 1; |
| 31 |
pub const DAV1D_ADAPTIVE: Dav1dAdaptiveBoolean = 2; |
| 32 |
pub type Dav1dAdaptiveBoolean = c_uint; |
| 33 |
|
| 34 |
pub const DAV1D_RESTORATION_NONE: Dav1dRestorationType = 0; |
| 35 |
pub const DAV1D_RESTORATION_SWITCHABLE: Dav1dRestorationType = 1; |
| 36 |
pub const DAV1D_RESTORATION_WIENER: Dav1dRestorationType = 2; |
| 37 |
pub const DAV1D_RESTORATION_SGRPROJ: Dav1dRestorationType = 3; |
| 38 |
pub type Dav1dRestorationType = c_uint; |
| 39 |
|
| 40 |
pub const DAV1D_WM_TYPE_IDENTITY: Dav1dWarpedMotionType = 0; |
| 41 |
pub const DAV1D_WM_TYPE_TRANSLATION: Dav1dWarpedMotionType = 1; |
| 42 |
pub const DAV1D_WM_TYPE_ROT_ZOOM: Dav1dWarpedMotionType = 2; |
| 43 |
pub const DAV1D_WM_TYPE_AFFINE: Dav1dWarpedMotionType = 3; |
| 44 |
pub type Dav1dWarpedMotionType = c_uint; |
| 45 |
|
| 46 |
pub const DAV1D_PIXEL_LAYOUT_I400: Dav1dPixelLayout = 0; |
| 47 |
pub const DAV1D_PIXEL_LAYOUT_I420: Dav1dPixelLayout = 1; |
| 48 |
pub const DAV1D_PIXEL_LAYOUT_I422: Dav1dPixelLayout = 2; |
| 49 |
pub const DAV1D_PIXEL_LAYOUT_I444: Dav1dPixelLayout = 3; |
| 50 |
pub type Dav1dPixelLayout = c_uint; |
| 51 |
|
| 52 |
pub const DAV1D_FRAME_TYPE_KEY: Dav1dFrameType = 0; |
| 53 |
pub const DAV1D_FRAME_TYPE_INTER: Dav1dFrameType = 1; |
| 54 |
pub const DAV1D_FRAME_TYPE_INTRA: Dav1dFrameType = 2; |
| 55 |
pub const DAV1D_FRAME_TYPE_SWITCH: Dav1dFrameType = 3; |
| 56 |
pub type Dav1dFrameType = c_uint; |
| 57 |
|
| 58 |
pub const DAV1D_COLOR_PRI_BT709: Dav1dColorPrimaries = 1; |
| 59 |
pub const DAV1D_COLOR_PRI_UNKNOWN: Dav1dColorPrimaries = 2; |
| 60 |
pub const DAV1D_COLOR_PRI_BT470M: Dav1dColorPrimaries = 4; |
| 61 |
pub const DAV1D_COLOR_PRI_BT470BG: Dav1dColorPrimaries = 5; |
| 62 |
pub const DAV1D_COLOR_PRI_BT601: Dav1dColorPrimaries = 6; |
| 63 |
pub const DAV1D_COLOR_PRI_SMPTE240: Dav1dColorPrimaries = 7; |
| 64 |
pub const DAV1D_COLOR_PRI_FILM: Dav1dColorPrimaries = 8; |
| 65 |
pub const DAV1D_COLOR_PRI_BT2020: Dav1dColorPrimaries = 9; |
| 66 |
pub const DAV1D_COLOR_PRI_XYZ: Dav1dColorPrimaries = 10; |
| 67 |
pub const DAV1D_COLOR_PRI_SMPTE431: Dav1dColorPrimaries = 11; |
| 68 |
pub const DAV1D_COLOR_PRI_SMPTE432: Dav1dColorPrimaries = 12; |
| 69 |
pub const DAV1D_COLOR_PRI_EBU3213: Dav1dColorPrimaries = 22; |
| 70 |
pub const DAV1D_COLOR_PRI_RESERVED: Dav1dColorPrimaries = 255; |
| 71 |
pub type Dav1dColorPrimaries = c_uint; |
| 72 |
|
| 73 |
pub const DAV1D_TRC_BT709: Dav1dTransferCharacteristics = 1; |
| 74 |
pub const DAV1D_TRC_UNKNOWN: Dav1dTransferCharacteristics = 2; |
| 75 |
pub const DAV1D_TRC_BT470M: Dav1dTransferCharacteristics = 4; |
| 76 |
pub const DAV1D_TRC_BT470BG: Dav1dTransferCharacteristics = 5; |
| 77 |
pub const DAV1D_TRC_BT601: Dav1dTransferCharacteristics = 6; |
| 78 |
pub const DAV1D_TRC_SMPTE240: Dav1dTransferCharacteristics = 7; |
| 79 |
pub const DAV1D_TRC_LINEAR: Dav1dTransferCharacteristics = 8; |
| 80 |
pub const DAV1D_TRC_LOG100: Dav1dTransferCharacteristics = 9; |
| 81 |
pub const DAV1D_TRC_LOG100_SQRT10: Dav1dTransferCharacteristics = 10; |
| 82 |
pub const DAV1D_TRC_IEC61966: Dav1dTransferCharacteristics = 11; |
| 83 |
pub const DAV1D_TRC_BT1361: Dav1dTransferCharacteristics = 12; |
| 84 |
pub const DAV1D_TRC_SRGB: Dav1dTransferCharacteristics = 13; |
| 85 |
pub const DAV1D_TRC_BT2020_10BIT: Dav1dTransferCharacteristics = 14; |
| 86 |
pub const DAV1D_TRC_BT2020_12BIT: Dav1dTransferCharacteristics = 15; |
| 87 |
pub const DAV1D_TRC_SMPTE2084: Dav1dTransferCharacteristics = 16; |
| 88 |
pub const DAV1D_TRC_SMPTE428: Dav1dTransferCharacteristics = 17; |
| 89 |
pub const DAV1D_TRC_HLG: Dav1dTransferCharacteristics = 18; |
| 90 |
pub const DAV1D_TRC_RESERVED: Dav1dTransferCharacteristics = 255; |
| 91 |
pub type Dav1dTransferCharacteristics = c_uint; |
| 92 |
|
| 93 |
pub const DAV1D_MC_IDENTITY: Dav1dMatrixCoefficients = 0; |
| 94 |
pub const DAV1D_MC_BT709: Dav1dMatrixCoefficients = 1; |
| 95 |
pub const DAV1D_MC_UNKNOWN: Dav1dMatrixCoefficients = 2; |
| 96 |
pub const DAV1D_MC_FCC: Dav1dMatrixCoefficients = 4; |
| 97 |
pub const DAV1D_MC_BT470BG: Dav1dMatrixCoefficients = 5; |
| 98 |
pub const DAV1D_MC_BT601: Dav1dMatrixCoefficients = 6; |
| 99 |
pub const DAV1D_MC_SMPTE240: Dav1dMatrixCoefficients = 7; |
| 100 |
pub const DAV1D_MC_SMPTE_YCGCO: Dav1dMatrixCoefficients = 8; |
| 101 |
pub const DAV1D_MC_BT2020_NCL: Dav1dMatrixCoefficients = 9; |
| 102 |
pub const DAV1D_MC_BT2020_CL: Dav1dMatrixCoefficients = 10; |
| 103 |
pub const DAV1D_MC_SMPTE2085: Dav1dMatrixCoefficients = 11; |
| 104 |
pub const DAV1D_MC_CHROMAT_NCL: Dav1dMatrixCoefficients = 12; |
| 105 |
pub const DAV1D_MC_CHROMAT_CL: Dav1dMatrixCoefficients = 13; |
| 106 |
pub const DAV1D_MC_ICTCP: Dav1dMatrixCoefficients = 14; |
| 107 |
pub const DAV1D_MC_RESERVED: Dav1dMatrixCoefficients = 255; |
| 108 |
pub type Dav1dMatrixCoefficients = c_uint; |
| 109 |
|
| 110 |
pub const DAV1D_CHR_UNKNOWN: Dav1dChromaSamplePosition = 0; |
| 111 |
pub const DAV1D_CHR_VERTICAL: Dav1dChromaSamplePosition = 1; |
| 112 |
pub const DAV1D_CHR_COLOCATED: Dav1dChromaSamplePosition = 2; |
| 113 |
pub type Dav1dChromaSamplePosition = c_uint; |
| 114 |
|
| 115 |
pub const DAV1D_INLOOPFILTER_NONE: Dav1dInloopFilterType = 0; |
| 116 |
pub const DAV1D_INLOOPFILTER_DEBLOCK: Dav1dInloopFilterType = 1; |
| 117 |
pub const DAV1D_INLOOPFILTER_CDEF: Dav1dInloopFilterType = 2; |
| 118 |
pub const DAV1D_INLOOPFILTER_RESTORATION: Dav1dInloopFilterType = 4; |
| 119 |
pub const DAV1D_INLOOPFILTER_ALL: Dav1dInloopFilterType = 7; |
| 120 |
pub type Dav1dInloopFilterType = c_uint; |
| 121 |
|
| 122 |
pub const DAV1D_EVENT_FLAG_NEW_SEQUENCE: Dav1dEventFlags = 1; |
| 123 |
pub const DAV1D_EVENT_FLAG_NEW_OP_PARAMS_INFO: Dav1dEventFlags = 2; |
| 124 |
pub type Dav1dEventFlags = c_uint; |
| 125 |
|
| 126 |
pub const DAV1D_MAX_THREADS: c_int = 256; |
| 127 |
pub const DAV1D_MAX_FRAME_DELAY: c_int = 256; |
| 128 |
|
| 129 |
pub const DAV1D_MAX_CDEF_STRENGTHS: usize = 8; |
| 130 |
pub const DAV1D_MAX_OPERATING_POINTS: usize = 32; |
| 131 |
pub const DAV1D_MAX_TILE_COLS: usize = 64; |
| 132 |
pub const DAV1D_MAX_TILE_ROWS: usize = 64; |
| 133 |
pub const DAV1D_MAX_SEGMENTS: usize = 8; |
| 134 |
pub const DAV1D_NUM_REF_FRAMES: usize = 8; |
| 135 |
pub const DAV1D_PRIMARY_REF_NONE: usize = 7; |
| 136 |
pub const DAV1D_REFS_PER_FRAME: usize = 7; |
| 137 |
pub const DAV1D_TOTAL_REFS_PER_FRAME: usize = DAV1D_REFS_PER_FRAME + 1; |
| 138 |
|
| 139 |
pub const DAV1D_DECODEFRAMETYPE_ALL: Dav1dDecodeFrameType = 0; |
| 140 |
pub const DAV1D_DECODEFRAMETYPE_REFERENCE: Dav1dDecodeFrameType = 1; |
| 141 |
pub const DAV1D_DECODEFRAMETYPE_INTRA: Dav1dDecodeFrameType = 2; |
| 142 |
pub const DAV1D_DECODEFRAMETYPE_KEY: Dav1dDecodeFrameType = 3; |
| 143 |
pub type Dav1dDecodeFrameType = c_uint; |
| 144 |
|
| 145 |
// Conversion of the C DAV1D_ERR macro |
| 146 |
pub const fn dav1d_err(errno: c_int) -> c_int { |
| 147 |
if libc::EPERM < 0 { |
| 148 |
errno |
| 149 |
} else { |
| 150 |
-errno |
| 151 |
} |
| 152 |
} |
| 153 |
|
| 154 |
pub const DAV1D_ERR_AGAIN: c_int = dav1d_err(libc::EAGAIN); |
| 155 |
pub const DAV1D_ERR_INVAL: c_int = dav1d_err(libc::EINVAL); |
| 156 |
pub const DAV1D_ERR_NOMEM: c_int = dav1d_err(libc::ENOMEM); |
| 157 |
pub const DAV1D_ERR_NOPROTOOPT: c_int = dav1d_err(libc::ENOPROTOOPT); |
| 158 |
|
| 159 |
#[repr(C)] |
| 160 |
#[derive(Debug, Copy, Clone)] |
| 161 |
pub struct Dav1dUserData { |
| 162 |
pub data: *const u8, |
| 163 |
pub ref_: *mut Dav1dRef, |
| 164 |
} |
| 165 |
|
| 166 |
#[repr(C)] |
| 167 |
#[derive(Debug, Copy, Clone)] |
| 168 |
pub struct Dav1dDataProps { |
| 169 |
pub timestamp: i64, |
| 170 |
pub duration: i64, |
| 171 |
pub offset: i64, |
| 172 |
pub size: usize, |
| 173 |
pub user_data: Dav1dUserData, |
| 174 |
} |
| 175 |
|
| 176 |
#[repr(C)] |
| 177 |
#[derive(Copy, Clone)] |
| 178 |
pub struct Dav1dWarpedMotionParams { |
| 179 |
pub type_: Dav1dWarpedMotionType, |
| 180 |
pub matrix: [i32; 6usize], |
| 181 |
pub u: Dav1dWarpedMotionParamsU, |
| 182 |
} |
| 183 |
|
| 184 |
#[repr(C)] |
| 185 |
#[derive(Copy, Clone)] |
| 186 |
pub union Dav1dWarpedMotionParamsU { |
| 187 |
pub p: Dav1dWarpedMotionParamsUP, |
| 188 |
pub abcd: [i16; 4usize], |
| 189 |
} |
| 190 |
|
| 191 |
#[repr(C)] |
| 192 |
#[derive(Debug, Copy, Clone)] |
| 193 |
pub struct Dav1dWarpedMotionParamsUP { |
| 194 |
pub alpha: i16, |
| 195 |
pub beta: i16, |
| 196 |
pub gamma: i16, |
| 197 |
pub delta: i16, |
| 198 |
} |
| 199 |
|
| 200 |
#[repr(C)] |
| 201 |
#[derive(Debug, Copy, Clone)] |
| 202 |
pub struct Dav1dContentLightLevel { |
| 203 |
pub max_content_light_level: u16, |
| 204 |
pub max_frame_average_light_level: u16, |
| 205 |
} |
| 206 |
|
| 207 |
#[repr(C)] |
| 208 |
#[derive(Debug, Copy, Clone)] |
| 209 |
pub struct Dav1dMasteringDisplay { |
| 210 |
pub primaries: [[u16; 2usize]; 3usize], |
| 211 |
pub white_point: [u16; 2usize], |
| 212 |
pub max_luminance: u32, |
| 213 |
pub min_luminance: u32, |
| 214 |
} |
| 215 |
|
| 216 |
#[repr(C)] |
| 217 |
#[derive(Debug, Copy, Clone)] |
| 218 |
pub struct Dav1dITUTT35 { |
| 219 |
pub country_code: u8, |
| 220 |
pub country_code_extension_byte: u8, |
| 221 |
pub payload_size: usize, |
| 222 |
pub payload: *mut u8, |
| 223 |
} |
| 224 |
|
| 225 |
#[repr(C)] |
| 226 |
#[derive(Debug, Copy, Clone)] |
| 227 |
pub struct Dav1dSequenceHeader { |
| 228 |
pub profile: u8, |
| 229 |
pub max_width: c_int, |
| 230 |
pub max_height: c_int, |
| 231 |
pub layout: Dav1dPixelLayout, |
| 232 |
pub pri: Dav1dColorPrimaries, |
| 233 |
pub trc: Dav1dTransferCharacteristics, |
| 234 |
pub mtrx: Dav1dMatrixCoefficients, |
| 235 |
pub chr: Dav1dChromaSamplePosition, |
| 236 |
pub hbd: u8, |
| 237 |
pub color_range: u8, |
| 238 |
pub num_operating_points: u8, |
| 239 |
pub operating_points: [Dav1dSequenceHeaderOperatingPoint; DAV1D_MAX_OPERATING_POINTS], |
| 240 |
pub still_picture: u8, |
| 241 |
pub reduced_still_picture_header: u8, |
| 242 |
pub timing_info_present: u8, |
| 243 |
pub num_units_in_tick: u32, |
| 244 |
pub time_scale: u32, |
| 245 |
pub equal_picture_interval: u8, |
| 246 |
pub num_ticks_per_picture: u32, |
| 247 |
pub decoder_model_info_present: u8, |
| 248 |
pub encoder_decoder_buffer_delay_length: u8, |
| 249 |
pub num_units_in_decoding_tick: u32, |
| 250 |
pub buffer_removal_delay_length: u8, |
| 251 |
pub frame_presentation_delay_length: u8, |
| 252 |
pub display_model_info_present: u8, |
| 253 |
pub width_n_bits: u8, |
| 254 |
pub height_n_bits: u8, |
| 255 |
pub frame_id_numbers_present: u8, |
| 256 |
pub delta_frame_id_n_bits: u8, |
| 257 |
pub frame_id_n_bits: u8, |
| 258 |
pub sb128: u8, |
| 259 |
pub filter_intra: u8, |
| 260 |
pub intra_edge_filter: u8, |
| 261 |
pub inter_intra: u8, |
| 262 |
pub masked_compound: u8, |
| 263 |
pub warped_motion: u8, |
| 264 |
pub dual_filter: u8, |
| 265 |
pub order_hint: u8, |
| 266 |
pub jnt_comp: u8, |
| 267 |
pub ref_frame_mvs: u8, |
| 268 |
pub screen_content_tools: Dav1dAdaptiveBoolean, |
| 269 |
pub force_integer_mv: Dav1dAdaptiveBoolean, |
| 270 |
pub order_hint_n_bits: u8, |
| 271 |
pub super_res: u8, |
| 272 |
pub cdef: u8, |
| 273 |
pub restoration: u8, |
| 274 |
pub ss_hor: u8, |
| 275 |
pub ss_ver: u8, |
| 276 |
pub monochrome: u8, |
| 277 |
pub color_description_present: u8, |
| 278 |
pub separate_uv_delta_q: u8, |
| 279 |
pub film_grain_present: u8, |
| 280 |
pub operating_parameter_info: |
| 281 |
[Dav1dSequenceHeaderOperatingParameterInfo; DAV1D_MAX_OPERATING_POINTS], |
| 282 |
} |
| 283 |
|
| 284 |
#[repr(C)] |
| 285 |
#[derive(Debug, Copy, Clone)] |
| 286 |
pub struct Dav1dSequenceHeaderOperatingPoint { |
| 287 |
pub major_level: u8, |
| 288 |
pub minor_level: u8, |
| 289 |
pub initial_display_delay: u16, |
| 290 |
pub idc: u8, |
| 291 |
pub tier: u8, |
| 292 |
pub decoder_model_param_present: u8, |
| 293 |
pub display_model_param_present: u8, |
| 294 |
} |
| 295 |
|
| 296 |
#[repr(C)] |
| 297 |
#[derive(Debug, Copy, Clone)] |
| 298 |
pub struct Dav1dSequenceHeaderOperatingParameterInfo { |
| 299 |
pub decoder_buffer_delay: u32, |
| 300 |
pub encoder_buffer_delay: u32, |
| 301 |
pub low_delay_mode: u8, |
| 302 |
} |
| 303 |
|
| 304 |
#[repr(C)] |
| 305 |
#[derive(Debug, Copy, Clone)] |
| 306 |
pub struct Dav1dSegmentationData { |
| 307 |
pub delta_q: i16, |
| 308 |
pub delta_lf_y_v: i8, |
| 309 |
pub delta_lf_y_h: i8, |
| 310 |
pub delta_lf_u: i8, |
| 311 |
pub delta_lf_v: i8, |
| 312 |
pub ref_: i8, |
| 313 |
pub skip: u8, |
| 314 |
pub globalmv: u8, |
| 315 |
} |
| 316 |
|
| 317 |
#[repr(C)] |
| 318 |
#[derive(Debug, Copy, Clone)] |
| 319 |
pub struct Dav1dSegmentationDataSet { |
| 320 |
pub d: [Dav1dSegmentationData; DAV1D_MAX_SEGMENTS], |
| 321 |
pub preskip: u8, |
| 322 |
pub last_active_segid: i8, |
| 323 |
} |
| 324 |
|
| 325 |
#[repr(C)] |
| 326 |
#[derive(Debug, Copy, Clone)] |
| 327 |
pub struct Dav1dLoopfilterModeRefDeltas { |
| 328 |
pub mode_delta: [i8; 2usize], |
| 329 |
pub ref_delta: [i8; DAV1D_TOTAL_REFS_PER_FRAME], |
| 330 |
} |
| 331 |
|
| 332 |
#[repr(C)] |
| 333 |
#[derive(Debug, Copy, Clone)] |
| 334 |
pub struct Dav1dFilmGrainData { |
| 335 |
pub seed: c_uint, |
| 336 |
pub num_y_points: c_int, |
| 337 |
pub y_points: [[u8; 2usize]; 14usize], |
| 338 |
pub chroma_scaling_from_luma: c_int, |
| 339 |
pub num_uv_points: [c_int; 2usize], |
| 340 |
pub uv_points: [[[u8; 2usize]; 10usize]; 2usize], |
| 341 |
pub scaling_shift: c_int, |
| 342 |
pub ar_coeff_lag: c_int, |
| 343 |
pub ar_coeffs_y: [i8; 24usize], |
| 344 |
pub ar_coeffs_uv: [[i8; 28usize]; 2usize], |
| 345 |
pub ar_coeff_shift: u64, |
| 346 |
pub grain_scale_shift: c_int, |
| 347 |
pub uv_mult: [c_int; 2usize], |
| 348 |
pub uv_luma_mult: [c_int; 2usize], |
| 349 |
pub uv_offset: [c_int; 2usize], |
| 350 |
pub overlap_flag: c_int, |
| 351 |
pub clip_to_restricted_range: c_int, |
| 352 |
} |
| 353 |
|
| 354 |
#[repr(C)] |
| 355 |
#[derive(Copy, Clone)] |
| 356 |
pub struct Dav1dFrameHeader { |
| 357 |
pub film_grain: Dav1dFrameHeaderFilmGrain, |
| 358 |
pub frame_type: Dav1dFrameType, |
| 359 |
pub width: [c_int; 2usize], |
| 360 |
pub height: c_int, |
| 361 |
pub frame_offset: u8, |
| 362 |
pub temporal_id: u8, |
| 363 |
pub spatial_id: u8, |
| 364 |
pub show_existing_frame: u8, |
| 365 |
pub existing_frame_idx: u8, |
| 366 |
pub frame_id: u32, |
| 367 |
pub frame_presentation_delay: u32, |
| 368 |
pub show_frame: u8, |
| 369 |
pub showable_frame: u8, |
| 370 |
pub error_resilient_mode: u8, |
| 371 |
pub disable_cdf_update: u8, |
| 372 |
pub allow_screen_content_tools: u8, |
| 373 |
pub force_integer_mv: u8, |
| 374 |
pub frame_size_override: u8, |
| 375 |
pub primary_ref_frame: u8, |
| 376 |
pub buffer_removal_time_present: u8, |
| 377 |
pub operating_points: [Dav1dFrameHeaderOperatingPoint; DAV1D_MAX_OPERATING_POINTS], |
| 378 |
pub refresh_frame_flags: u8, |
| 379 |
pub render_width: c_int, |
| 380 |
pub render_height: c_int, |
| 381 |
pub super_res: Dav1dFrameHeaderSuperRes, |
| 382 |
pub have_render_size: u8, |
| 383 |
pub allow_intrabc: u8, |
| 384 |
pub frame_ref_short_signaling: u8, |
| 385 |
pub refidx: [i8; DAV1D_REFS_PER_FRAME], |
| 386 |
pub hp: u8, |
| 387 |
pub subpel_filter_mode: Dav1dFilterMode, |
| 388 |
pub switchable_motion_mode: u8, |
| 389 |
pub use_ref_frame_mvs: u8, |
| 390 |
pub refresh_context: u8, |
| 391 |
pub tiling: Dav1dFrameHeaderTiling, |
| 392 |
pub quant: Dav1dFrameHeaderQuant, |
| 393 |
pub segmentation: Dav1dFrameHeaderSegmentation, |
| 394 |
pub delta: Dav1dFrameHeaderDelta, |
| 395 |
pub all_lossless: u8, |
| 396 |
pub loopfilter: Dav1dFrameHeaderLoopfilter, |
| 397 |
pub cdef: Dav1dFrameHeaderCDef, |
| 398 |
pub restoration: Dav1dFrameHeaderRestoration, |
| 399 |
pub txfm_mode: Dav1dTxfmMode, |
| 400 |
pub switchable_comp_refs: u8, |
| 401 |
pub skip_mode_allowed: u8, |
| 402 |
pub skip_mode_enabled: u8, |
| 403 |
pub skip_mode_refs: [i8; 2usize], |
| 404 |
pub warp_motion: u8, |
| 405 |
pub reduced_txtp_set: u8, |
| 406 |
pub gmv: [Dav1dWarpedMotionParams; DAV1D_REFS_PER_FRAME], |
| 407 |
} |
| 408 |
|
| 409 |
#[repr(C)] |
| 410 |
#[derive(Debug, Copy, Clone)] |
| 411 |
pub struct Dav1dFrameHeaderFilmGrain { |
| 412 |
pub data: Dav1dFilmGrainData, |
| 413 |
pub present: u8, |
| 414 |
pub update: u8, |
| 415 |
} |
| 416 |
|
| 417 |
#[repr(C)] |
| 418 |
#[derive(Debug, Copy, Clone)] |
| 419 |
pub struct Dav1dFrameHeaderOperatingPoint { |
| 420 |
pub buffer_removal_time: u32, |
| 421 |
} |
| 422 |
|
| 423 |
#[repr(C)] |
| 424 |
#[derive(Debug, Copy, Clone)] |
| 425 |
pub struct Dav1dFrameHeaderSuperRes { |
| 426 |
pub width_scale_denominator: u8, |
| 427 |
pub enabled: u8, |
| 428 |
} |
| 429 |
|
| 430 |
#[repr(C)] |
| 431 |
#[derive(Debug, Copy, Clone)] |
| 432 |
pub struct Dav1dFrameHeaderTiling { |
| 433 |
pub uniform: u8, |
| 434 |
pub n_bytes: u8, |
| 435 |
pub min_log2_cols: u8, |
| 436 |
pub max_log2_cols: u8, |
| 437 |
pub log2_cols: u8, |
| 438 |
pub cols: u8, |
| 439 |
pub min_log2_rows: u8, |
| 440 |
pub max_log2_rows: u8, |
| 441 |
pub log2_rows: u8, |
| 442 |
pub rows: u8, |
| 443 |
pub col_start_sb: [u16; DAV1D_MAX_TILE_COLS + 1], |
| 444 |
pub row_start_sb: [u16; DAV1D_MAX_TILE_ROWS + 1], |
| 445 |
pub update: u16, |
| 446 |
} |
| 447 |
|
| 448 |
#[repr(C)] |
| 449 |
#[derive(Debug, Copy, Clone)] |
| 450 |
pub struct Dav1dFrameHeaderQuant { |
| 451 |
pub yac: u8, |
| 452 |
pub ydc_delta: i8, |
| 453 |
pub udc_delta: i8, |
| 454 |
pub uac_delta: i8, |
| 455 |
pub vdc_delta: i8, |
| 456 |
pub vac_delta: i8, |
| 457 |
pub qm: u8, |
| 458 |
pub qm_y: u8, |
| 459 |
pub qm_u: u8, |
| 460 |
pub qm_v: u8, |
| 461 |
} |
| 462 |
|
| 463 |
#[repr(C)] |
| 464 |
#[derive(Debug, Copy, Clone)] |
| 465 |
pub struct Dav1dFrameHeaderSegmentation { |
| 466 |
pub enabled: u8, |
| 467 |
pub update_map: u8, |
| 468 |
pub temporal: u8, |
| 469 |
pub update_data: u8, |
| 470 |
pub seg_data: Dav1dSegmentationDataSet, |
| 471 |
pub lossless: [u8; DAV1D_MAX_SEGMENTS], |
| 472 |
pub qidx: [u8; DAV1D_MAX_SEGMENTS], |
| 473 |
} |
| 474 |
|
| 475 |
#[repr(C)] |
| 476 |
#[derive(Debug, Copy, Clone)] |
| 477 |
pub struct Dav1dFrameHeaderDelta { |
| 478 |
pub q: Dav1dDeltaQ, |
| 479 |
pub lf: Dav1dDeltaLF, |
| 480 |
} |
| 481 |
|
| 482 |
#[repr(C)] |
| 483 |
#[derive(Debug, Copy, Clone)] |
| 484 |
pub struct Dav1dDeltaQ { |
| 485 |
pub present: u8, |
| 486 |
pub res_log2: u8, |
| 487 |
} |
| 488 |
|
| 489 |
#[repr(C)] |
| 490 |
#[derive(Debug, Copy, Clone)] |
| 491 |
pub struct Dav1dDeltaLF { |
| 492 |
pub present: u8, |
| 493 |
pub res_log2: u8, |
| 494 |
pub multi: u8, |
| 495 |
} |
| 496 |
|
| 497 |
#[repr(C)] |
| 498 |
#[derive(Debug, Copy, Clone)] |
| 499 |
pub struct Dav1dFrameHeaderLoopfilter { |
| 500 |
pub level_y: [u8; 2usize], |
| 501 |
pub level_u: u8, |
| 502 |
pub level_v: u8, |
| 503 |
pub mode_ref_delta_enabled: u8, |
| 504 |
pub mode_ref_delta_update: u8, |
| 505 |
pub mode_ref_deltas: Dav1dLoopfilterModeRefDeltas, |
| 506 |
pub sharpness: u8, |
| 507 |
} |
| 508 |
|
| 509 |
#[repr(C)] |
| 510 |
#[derive(Debug, Copy, Clone)] |
| 511 |
pub struct Dav1dFrameHeaderCDef { |
| 512 |
pub damping: u8, |
| 513 |
pub n_bits: u8, |
| 514 |
pub y_strength: [u8; DAV1D_MAX_CDEF_STRENGTHS], |
| 515 |
pub uv_strength: [u8; DAV1D_MAX_CDEF_STRENGTHS], |
| 516 |
} |
| 517 |
|
| 518 |
#[repr(C)] |
| 519 |
#[derive(Debug, Copy, Clone)] |
| 520 |
pub struct Dav1dFrameHeaderRestoration { |
| 521 |
pub type_: [Dav1dRestorationType; 3usize], |
| 522 |
pub unit_size: [u8; 2usize], |
| 523 |
} |
| 524 |
|
| 525 |
#[repr(C)] |
| 526 |
#[derive(Debug, Copy, Clone)] |
| 527 |
pub struct Dav1dPictureParameters { |
| 528 |
pub w: c_int, |
| 529 |
pub h: c_int, |
| 530 |
pub layout: Dav1dPixelLayout, |
| 531 |
pub bpc: c_int, |
| 532 |
} |
| 533 |
|
| 534 |
#[repr(C)] |
| 535 |
#[derive(Debug, Copy, Clone)] |
| 536 |
pub struct Dav1dPicture { |
| 537 |
pub seq_hdr: *mut Dav1dSequenceHeader, |
| 538 |
pub frame_hdr: *mut Dav1dFrameHeader, |
| 539 |
pub data: [*mut c_void; 3usize], |
| 540 |
pub stride: [isize; 2usize], |
| 541 |
pub p: Dav1dPictureParameters, |
| 542 |
pub m: Dav1dDataProps, |
| 543 |
pub content_light: *mut Dav1dContentLightLevel, |
| 544 |
pub mastering_display: *mut Dav1dMasteringDisplay, |
| 545 |
pub itut_t35: *mut Dav1dITUTT35, |
| 546 |
pub reserved: [usize; 4usize], |
| 547 |
pub frame_hdr_ref: *mut Dav1dRef, |
| 548 |
pub seq_hdr_ref: *mut Dav1dRef, |
| 549 |
pub content_light_ref: *mut Dav1dRef, |
| 550 |
pub mastering_display_ref: *mut Dav1dRef, |
| 551 |
pub itut_t35_ref: *mut Dav1dRef, |
| 552 |
pub n_itut_t34: usize, |
| 553 |
pub reserved_ref: [usize; 4usize], |
| 554 |
pub ref_: *mut Dav1dRef, |
| 555 |
pub allocator_data: *mut c_void, |
| 556 |
} |
| 557 |
|
| 558 |
#[repr(C)] |
| 559 |
#[derive(Debug, Copy, Clone)] |
| 560 |
pub struct Dav1dPicAllocator { |
| 561 |
pub cookie: *mut c_void, |
| 562 |
pub alloc_picture_callback: |
| 563 |
Option<unsafe extern "C" fn(pic: *mut Dav1dPicture, cookie: *mut c_void) -> c_int>, |
| 564 |
pub release_picture_callback: |
| 565 |
Option<unsafe extern "C" fn(pic: *mut Dav1dPicture, cookie: *mut c_void)>, |
| 566 |
} |
| 567 |
|
| 568 |
#[repr(C)] |
| 569 |
#[derive(Debug, Copy, Clone)] |
| 570 |
pub struct Dav1dData { |
| 571 |
pub data: *const u8, |
| 572 |
pub sz: usize, |
| 573 |
pub ref_: *mut Dav1dRef, |
| 574 |
pub m: Dav1dDataProps, |
| 575 |
} |
| 576 |
|
| 577 |
#[repr(transparent)] |
| 578 |
#[derive(Debug)] |
| 579 |
pub struct Dav1dContext(c_void); |
| 580 |
|
| 581 |
#[repr(C)] |
| 582 |
#[derive(Debug, Copy, Clone)] |
| 583 |
pub struct Dav1dLogger { |
| 584 |
pub cookie: *mut c_void, |
| 585 |
pub callback: *mut c_void, |
| 586 |
// FIXME: Use the following once std::ffi::VaList is stable |
| 587 |
// Option< |
| 588 |
// unsafe extern "C" fn( |
| 589 |
// cookie: *mut c_void, |
| 590 |
// format: *const c_char, |
| 591 |
// ap: *mut ::std::ffi::VaList, |
| 592 |
// ), |
| 593 |
// >, |
| 594 |
} |
| 595 |
|
| 596 |
#[repr(C)] |
| 597 |
#[derive(Debug, Copy, Clone)] |
| 598 |
pub struct Dav1dSettings { |
| 599 |
pub n_threads: c_int, |
| 600 |
pub max_frame_delay: c_int, |
| 601 |
pub apply_grain: c_int, |
| 602 |
pub operating_point: c_int, |
| 603 |
pub all_layers: c_int, |
| 604 |
pub frame_size_limit: c_uint, |
| 605 |
pub allocator: Dav1dPicAllocator, |
| 606 |
pub logger: Dav1dLogger, |
| 607 |
pub strict_std_compliance: c_int, |
| 608 |
pub output_invisible_frames: c_int, |
| 609 |
pub inloop_filters: Dav1dInloopFilterType, |
| 610 |
pub decode_frame_type: Dav1dDecodeFrameType, |
| 611 |
pub reserved: [u8; 16usize], |
| 612 |
} |
| 613 |
|
| 614 |
#[repr(transparent)] |
| 615 |
#[derive(Debug)] |
| 616 |
pub struct Dav1dRef(c_void); |
| 617 |
|
| 618 |
extern "C" { |
| 619 |
pub fn dav1d_version() -> *const c_char; |
| 620 |
|
| 621 |
pub fn dav1d_version_api() -> u32; |
| 622 |
|
| 623 |
pub fn dav1d_default_settings(s: *mut Dav1dSettings); |
| 624 |
|
| 625 |
pub fn dav1d_parse_sequence_header( |
| 626 |
out: *mut Dav1dSequenceHeader, |
| 627 |
buf: *const u8, |
| 628 |
sz: usize, |
| 629 |
) -> c_int; |
| 630 |
|
| 631 |
pub fn dav1d_open(c_out: *mut *mut Dav1dContext, s: *const Dav1dSettings) -> c_int; |
| 632 |
|
| 633 |
pub fn dav1d_send_data(c: *mut Dav1dContext, in_: *mut Dav1dData) -> c_int; |
| 634 |
|
| 635 |
pub fn dav1d_flush(c: *mut Dav1dContext); |
| 636 |
|
| 637 |
pub fn dav1d_get_picture(c: *mut Dav1dContext, out: *mut Dav1dPicture) -> c_int; |
| 638 |
|
| 639 |
pub fn dav1d_get_decode_error_data_props( |
| 640 |
c: *mut Dav1dContext, |
| 641 |
out: *mut Dav1dDataProps, |
| 642 |
) -> c_int; |
| 643 |
|
| 644 |
pub fn dav1d_get_frame_delay(c: *mut Dav1dContext) -> c_int; |
| 645 |
|
| 646 |
pub fn dav1d_apply_grain( |
| 647 |
c: *mut Dav1dContext, |
| 648 |
out: *mut Dav1dPicture, |
| 649 |
in_: *const Dav1dPicture, |
| 650 |
) -> c_int; |
| 651 |
|
| 652 |
pub fn dav1d_get_event_flags(c: *mut Dav1dContext, flags: *mut Dav1dEventFlags) -> c_int; |
| 653 |
|
| 654 |
pub fn dav1d_close(c_out: *mut *mut Dav1dContext); |
| 655 |
|
| 656 |
pub fn dav1d_picture_unref(p: *mut Dav1dPicture); |
| 657 |
|
| 658 |
pub fn dav1d_data_props_unref(props: *mut Dav1dDataProps); |
| 659 |
|
| 660 |
pub fn dav1d_data_create(data: *mut Dav1dData, sz: usize) -> *mut u8; |
| 661 |
|
| 662 |
pub fn dav1d_data_wrap( |
| 663 |
data: *mut Dav1dData, |
| 664 |
buf: *const u8, |
| 665 |
sz: usize, |
| 666 |
free_callback: Option<unsafe extern "C" fn(buf: *const u8, cookie: *mut c_void)>, |
| 667 |
cookie: *mut c_void, |
| 668 |
) -> c_int; |
| 669 |
|
| 670 |
pub fn dav1d_data_wrap_user_data( |
| 671 |
data: *mut Dav1dData, |
| 672 |
user_data: *const u8, |
| 673 |
free_callback: Option<unsafe extern "C" fn(user_data: *const u8, cookie: *mut c_void)>, |
| 674 |
cookie: *mut c_void, |
| 675 |
) -> c_int; |
| 676 |
|
| 677 |
pub fn dav1d_data_unref(data: *mut Dav1dData); |
| 678 |
} |
| 679 |
|
| 680 |
#[cfg(test)] |
| 681 |
mod tests { |
| 682 |
use super::*; |
| 683 |
use std::ffi::CStr; |
| 684 |
|
| 685 |
macro_rules! assert_size ( |
| 686 |
($t:ty, $sz:expr) => ( |
| 687 |
assert_eq!(::std::mem::size_of::<$t>(), $sz); |
| 688 |
); |
| 689 |
); |
| 690 |
|
| 691 |
#[test] |
| 692 |
fn size() { |
| 693 |
#[cfg(target_pointer_width = "64")] |
| 694 |
assert_size!(Dav1dSettings, 96); |
| 695 |
#[cfg(target_pointer_width = "32")] |
| 696 |
assert_size!(Dav1dSettings, 76); |
| 697 |
} |
| 698 |
|
| 699 |
#[test] |
| 700 |
fn version() { |
| 701 |
println!("{}", unsafe { |
| 702 |
CStr::from_ptr(dav1d_version()).to_string_lossy() |
| 703 |
}); |
| 704 |
} |
| 705 |
} |