GitCorner

Code

ossartcraftfilmcraft🌐
f67d38b35cc5
//! Linux LP64 layouts generated with GCC from the installed MIT-licensed NVIDIA
//! `dynlink_cuda.h`, `dynlink_cuviddec.h` and `dynlink_nvcuvid.h` (NVDEC API 13.1).
//! Regenerate with a C program printing sizeof, _Alignof, offsetof for every field
//! below, constant values, and the video-signal byte with each bit-field set alone.
use super::ffi::*;
use std::mem::{align_of, offset_of, size_of};
#[test]
fn cuvidpicparams_layout_matches_the_header() {
    assert_eq!(offset_of!(CUVIDPICPARAMS, nBitstreamDataLen), 24, "CUVIDPICPARAMS.nBitstreamDataLen");
    assert_eq!(offset_of!(CUVIDPICPARAMS, pBitstreamData), 32, "CUVIDPICPARAMS.pBitstreamData");
    assert_eq!(offset_of!(CUVIDPICPARAMS, nNumSlices), 40, "CUVIDPICPARAMS.nNumSlices");
    assert_eq!(offset_of!(CUVIDPICPARAMS, pSliceDataOffsets), 48, "CUVIDPICPARAMS.pSliceDataOffsets");
}

#[test]
fn cuvideoformat_layout_matches_the_header() {
    assert_eq!((size_of::<CUVIDEOFORMAT>(), align_of::<CUVIDEOFORMAT>()), (64, 4));
    assert_eq!(offset_of!(CUVIDEOFORMAT, codec), 0);
    assert_eq!(offset_of!(CUVIDEOFORMAT, frame_rate), 4);
    assert_eq!(offset_of!(CUVIDEOFORMAT, progressive_sequence), 12);
    assert_eq!(offset_of!(CUVIDEOFORMAT, bit_depth_luma_minus8), 13);
    assert_eq!(offset_of!(CUVIDEOFORMAT, bit_depth_chroma_minus8), 14);
    assert_eq!(offset_of!(CUVIDEOFORMAT, min_num_decode_surfaces), 15);
    assert_eq!(offset_of!(CUVIDEOFORMAT, coded_width), 16);
    assert_eq!(offset_of!(CUVIDEOFORMAT, coded_height), 20);
    assert_eq!(offset_of!(CUVIDEOFORMAT, display_area), 24);
    assert_eq!(offset_of!(CUVIDEOFORMAT, chroma_format), 40);
    assert_eq!(offset_of!(CUVIDEOFORMAT, bitrate), 44);
    assert_eq!(offset_of!(CUVIDEOFORMAT, display_aspect_ratio), 48);
    assert_eq!(offset_of!(CUVIDEOFORMAT, video_signal_description), 56);
    assert_eq!(offset_of!(CUVIDEOFORMAT, seqhdr_data_length), 60);
}

#[test]
fn cuviddecodecaps_layout_matches_the_header() {
    assert_eq!((size_of::<CUVIDDECODECAPS>(), align_of::<CUVIDDECODECAPS>()), (88, 4));
    assert_eq!(offset_of!(CUVIDDECODECAPS, eCodecType), 0);
    assert_eq!(offset_of!(CUVIDDECODECAPS, eChromaFormat), 4);
    assert_eq!(offset_of!(CUVIDDECODECAPS, nBitDepthMinus8), 8);
    assert_eq!(offset_of!(CUVIDDECODECAPS, reserved1), 12);
    assert_eq!(offset_of!(CUVIDDECODECAPS, bIsSupported), 24);
    assert_eq!(offset_of!(CUVIDDECODECAPS, nNumNVDECs), 25);
    assert_eq!(offset_of!(CUVIDDECODECAPS, nOutputFormatMask), 26);
    assert_eq!(offset_of!(CUVIDDECODECAPS, nMaxWidth), 28);
    assert_eq!(offset_of!(CUVIDDECODECAPS, nMaxHeight), 32);
    assert_eq!(offset_of!(CUVIDDECODECAPS, nMaxMBCount), 36);
    assert_eq!(offset_of!(CUVIDDECODECAPS, nMinWidth), 40);
    assert_eq!(offset_of!(CUVIDDECODECAPS, nMinHeight), 42);
    assert_eq!(offset_of!(CUVIDDECODECAPS, bIsHistogramSupported), 44);
    assert_eq!(offset_of!(CUVIDDECODECAPS, nCounterBitDepth), 45);
    assert_eq!(offset_of!(CUVIDDECODECAPS, nMaxHistogramBins), 46);
    assert_eq!(offset_of!(CUVIDDECODECAPS, bIsDecodeStatsSupported), 48);
    assert_eq!(offset_of!(CUVIDDECODECAPS, reserved4), 49);
    assert_eq!(offset_of!(CUVIDDECODECAPS, reserved3), 52);
}

#[test]
fn cuviddecodecreateinfo_layout_matches_the_header() {
    assert_eq!((size_of::<CUVIDDECODECREATEINFO>(), align_of::<CUVIDDECODECREATEINFO>()), (176, 8));
    assert_eq!(offset_of!(CUVIDDECODECREATEINFO, ulWidth), 0);
    assert_eq!(offset_of!(CUVIDDECODECREATEINFO, ulHeight), 8);
    assert_eq!(offset_of!(CUVIDDECODECREATEINFO, ulNumDecodeSurfaces), 16);
    assert_eq!(offset_of!(CUVIDDECODECREATEINFO, CodecType), 24);
    assert_eq!(offset_of!(CUVIDDECODECREATEINFO, ChromaFormat), 28);
    assert_eq!(offset_of!(CUVIDDECODECREATEINFO, ulCreationFlags), 32);
    assert_eq!(offset_of!(CUVIDDECODECREATEINFO, bitDepthMinus8), 40);
    assert_eq!(offset_of!(CUVIDDECODECREATEINFO, ulIntraDecodeOnly), 48);
    assert_eq!(offset_of!(CUVIDDECODECREATEINFO, ulMaxWidth), 56);
    assert_eq!(offset_of!(CUVIDDECODECREATEINFO, ulMaxHeight), 64);
    assert_eq!(offset_of!(CUVIDDECODECREATEINFO, Reserved1), 72);
    assert_eq!(offset_of!(CUVIDDECODECREATEINFO, display_area), 80);
    assert_eq!(offset_of!(CUVIDDECODECREATEINFO, OutputFormat), 88);
    assert_eq!(offset_of!(CUVIDDECODECREATEINFO, DeinterlaceMode), 92);
    assert_eq!(offset_of!(CUVIDDECODECREATEINFO, ulTargetWidth), 96);
    assert_eq!(offset_of!(CUVIDDECODECREATEINFO, ulTargetHeight), 104);
    assert_eq!(offset_of!(CUVIDDECODECREATEINFO, ulNumOutputSurfaces), 112);
    assert_eq!(offset_of!(CUVIDDECODECREATEINFO, vidLock), 120);
    assert_eq!(offset_of!(CUVIDDECODECREATEINFO, target_rect), 128);
    assert_eq!(offset_of!(CUVIDDECODECREATEINFO, enableHistogram), 136);
    assert_eq!(offset_of!(CUVIDDECODECREATEINFO, enableDecodeFeatures), 144);
    assert_eq!(offset_of!(CUVIDDECODECREATEINFO, Reserved2), 152);
}

#[test]
fn cuvidparserparams_layout_matches_the_header() {
    assert_eq!((size_of::<CUVIDPARSERPARAMS>(), align_of::<CUVIDPARSERPARAMS>()), (136, 8));
    assert_eq!(offset_of!(CUVIDPARSERPARAMS, CodecType), 0);
    assert_eq!(offset_of!(CUVIDPARSERPARAMS, ulMaxNumDecodeSurfaces), 4);
    assert_eq!(offset_of!(CUVIDPARSERPARAMS, ulClockRate), 8);
    assert_eq!(offset_of!(CUVIDPARSERPARAMS, ulErrorThreshold), 12);
    assert_eq!(offset_of!(CUVIDPARSERPARAMS, ulMaxDisplayDelay), 16);
    assert_eq!(offset_of!(CUVIDPARSERPARAMS, flags), 20);
    assert_eq!(offset_of!(CUVIDPARSERPARAMS, uReserved1), 24);
    assert_eq!(offset_of!(CUVIDPARSERPARAMS, pUserData), 40);
    assert_eq!(offset_of!(CUVIDPARSERPARAMS, pfnSequenceCallback), 48);
    assert_eq!(offset_of!(CUVIDPARSERPARAMS, pfnDecodePicture), 56);
    assert_eq!(offset_of!(CUVIDPARSERPARAMS, pfnDisplayPicture), 64);
    assert_eq!(offset_of!(CUVIDPARSERPARAMS, pfnGetOperatingPoint), 72);
    assert_eq!(offset_of!(CUVIDPARSERPARAMS, pfnGetSEIMsg), 80);
    assert_eq!(offset_of!(CUVIDPARSERPARAMS, pvReserved2), 88);
    assert_eq!(offset_of!(CUVIDPARSERPARAMS, pExtVideoInfo), 128);
}

#[test]
fn cuvidsourcedatapacket_layout_matches_the_header() {
    assert_eq!((size_of::<CUVIDSOURCEDATAPACKET>(), align_of::<CUVIDSOURCEDATAPACKET>()), (32, 8));
    assert_eq!(offset_of!(CUVIDSOURCEDATAPACKET, flags), 0);
    assert_eq!(offset_of!(CUVIDSOURCEDATAPACKET, payload_size), 8);
    assert_eq!(offset_of!(CUVIDSOURCEDATAPACKET, payload), 16);
    assert_eq!(offset_of!(CUVIDSOURCEDATAPACKET, timestamp), 24);
}

#[test]
fn cuvidparserdispinfo_layout_matches_the_header() {
    assert_eq!((size_of::<CUVIDPARSERDISPINFO>(), align_of::<CUVIDPARSERDISPINFO>()), (24, 8));
    assert_eq!(offset_of!(CUVIDPARSERDISPINFO, picture_index), 0);
    assert_eq!(offset_of!(CUVIDPARSERDISPINFO, progressive_frame), 4);
    assert_eq!(offset_of!(CUVIDPARSERDISPINFO, top_field_first), 8);
    assert_eq!(offset_of!(CUVIDPARSERDISPINFO, repeat_first_field), 12);
    assert_eq!(offset_of!(CUVIDPARSERDISPINFO, timestamp), 16);
}

#[test]
fn cuvidprocparams_layout_matches_the_header() {
    assert_eq!((size_of::<CUVIDPROCPARAMS>(), align_of::<CUVIDPROCPARAMS>()), (264, 8));
    assert_eq!(offset_of!(CUVIDPROCPARAMS, progressive_frame), 0);
    assert_eq!(offset_of!(CUVIDPROCPARAMS, second_field), 4);
    assert_eq!(offset_of!(CUVIDPROCPARAMS, top_field_first), 8);
    assert_eq!(offset_of!(CUVIDPROCPARAMS, unpaired_field), 12);
    assert_eq!(offset_of!(CUVIDPROCPARAMS, reserved_flags), 16);
    assert_eq!(offset_of!(CUVIDPROCPARAMS, reserved_zero), 20);
    assert_eq!(offset_of!(CUVIDPROCPARAMS, raw_input_dptr), 24);
    assert_eq!(offset_of!(CUVIDPROCPARAMS, raw_input_pitch), 32);
    assert_eq!(offset_of!(CUVIDPROCPARAMS, raw_input_format), 36);
    assert_eq!(offset_of!(CUVIDPROCPARAMS, raw_output_dptr), 40);
    assert_eq!(offset_of!(CUVIDPROCPARAMS, raw_output_pitch), 48);
    assert_eq!(offset_of!(CUVIDPROCPARAMS, Reserved1), 52);
    assert_eq!(offset_of!(CUVIDPROCPARAMS, output_stream), 56);
    assert_eq!(offset_of!(CUVIDPROCPARAMS, Reserved), 64);
    assert_eq!(offset_of!(CUVIDPROCPARAMS, histogram_dptr), 248);
    assert_eq!(offset_of!(CUVIDPROCPARAMS, pCuvidProcExt), 256);
}

#[test]
fn framerate_layout_matches_the_header() {
    assert_eq!((size_of::<FrameRate>(), align_of::<FrameRate>()), (8, 4));
}

#[test]
fn rect_layout_matches_the_header() {
    assert_eq!((size_of::<Rect>(), align_of::<Rect>()), (16, 4));
}

#[test]
fn shortrect_layout_matches_the_header() {
    assert_eq!((size_of::<ShortRect>(), align_of::<ShortRect>()), (8, 2));
}

#[test]
fn aspectratio_layout_matches_the_header() {
    assert_eq!((size_of::<AspectRatio>(), align_of::<AspectRatio>()), (8, 4));
}

#[test]
fn videosignal_layout_matches_the_header() {
    assert_eq!((size_of::<VideoSignal>(), align_of::<VideoSignal>()), (4, 1));
}
#[test]
fn constants_match_the_header() {
    assert_eq!(cudaVideoCodec_H264 as i64, 4);
    assert_eq!(cudaVideoCodec_HEVC as i64, 8);
    assert_eq!(cudaVideoChromaFormat_420 as i64, 1);
    assert_eq!(cudaVideoSurfaceFormat_NV12 as i64, 0);
    assert_eq!(cudaVideoSurfaceFormat_P016 as i64, 1);
    assert_eq!(cudaVideoDeinterlaceMode_Weave as i64, 0);
    assert_eq!(cudaVideoCreate_PreferCUVID as i64, 4);
    assert_eq!(CUVID_PKT_ENDOFSTREAM as i64, 1);
    assert_eq!(CUVID_PKT_TIMESTAMP as i64, 2);
    assert_eq!(CUVID_PKT_ENDOFPICTURE as i64, 8);
    assert_eq!(7u8, 7);
    assert_eq!(1u8 << 3, 8);
}