Skip to content

utils

Functions:

get_c_dtype_long

get_c_dtype_long(clip: HoldsVideoFormatT) -> str
Source code
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
def get_c_dtype_long(clip: HoldsVideoFormatT) -> str:
    fmt = get_video_format(clip)

    if fmt.sample_type is vs.FLOAT:
        if fmt.bytes_per_sample == 2:
            return 'half'
        return 'float'

    if fmt.bytes_per_sample == 1:
        return 'unsigned char'
    elif fmt.bytes_per_sample == 2:
        return 'unsigned short'
    elif fmt.bytes_per_sample == 4:
        return 'unsigned int'

    raise CustomRuntimeError(func=get_c_dtype_long)

get_c_dtype_short

get_c_dtype_short(clip: HoldsVideoFormatT) -> str
Source code
12
13
14
15
16
17
18
19
20
21
22
23
24
25
def get_c_dtype_short(clip: HoldsVideoFormatT) -> str:
    fmt = get_video_format(clip)

    if fmt.sample_type is vs.FLOAT:
        return get_c_dtype_long(clip)

    if fmt.bytes_per_sample == 1:
        return 'uchar'
    elif fmt.bytes_per_sample == 2:
        return 'ushort'
    elif fmt.bytes_per_sample == 4:
        return 'uint'

    raise CustomRuntimeError(func=get_c_dtype_short)