Skip to content

utils

Functions:

get_field_difference

get_field_difference(
    clip: VideoNode, tff: FieldBasedLike | bool | None = None
) -> ConstantFormatVideoNode
Source code in vsdeinterlace/utils.py
18
19
20
21
22
23
24
25
26
27
def get_field_difference(clip: vs.VideoNode, tff: FieldBasedLike | bool | None = None) -> ConstantFormatVideoNode:
    assert check_variable(clip, get_field_difference)

    tff = FieldBased.from_param_or_video(tff, clip, True, get_field_difference).is_tff

    stats = clip.std.SeparateFields(tff).std.PlaneStats()

    return core.akarin.PropExpr(
        [clip, stats[::2], stats[1::2]], lambda: {"FieldDifference": "y.PlaneStatsAverage z.PlaneStatsAverage - abs"}
    )

reinterlace

reinterlace(
    clip: VideoNode, tff: FieldBasedLike | bool | None = None
) -> ConstantFormatVideoNode
Source code in vsdeinterlace/utils.py
47
48
49
50
51
52
def reinterlace(clip: vs.VideoNode, tff: FieldBasedLike | bool | None = None) -> ConstantFormatVideoNode:
    assert check_variable(clip, reinterlace)

    tff = FieldBased.from_param_or_video(tff, clip, True, reinterlace).is_tff

    return weave(clip.std.SeparateFields(tff).std.SelectEvery(4, (0, 3)), tff)

reweave

reweave(
    clipa: VideoNode, clipb: VideoNode, tff: FieldBasedLike | bool | None = None
) -> ConstantFormatVideoNode
Source code in vsdeinterlace/utils.py
38
39
40
41
42
43
44
def reweave(
    clipa: vs.VideoNode, clipb: vs.VideoNode, tff: FieldBasedLike | bool | None = None
) -> ConstantFormatVideoNode:
    assert check_variable(clipa, reweave)
    assert check_variable(clipb, reweave)

    return weave(core.std.Interleave([clipa, clipb]), tff)

telecine_patterns

telecine_patterns(
    clipa: VideoNode, clipb: VideoNode, length: int = 5
) -> list[ConstantFormatVideoNode]
Source code in vsdeinterlace/utils.py
 8
 9
10
11
12
13
14
15
def telecine_patterns(clipa: vs.VideoNode, clipb: vs.VideoNode, length: int = 5) -> list[ConstantFormatVideoNode]:
    assert check_variable(clipa, telecine_patterns)
    assert check_variable(clipb, telecine_patterns)

    a_select = [clipa.std.SelectEvery(length, i) for i in range(length)]
    b_select = [clipb.std.SelectEvery(length, i) for i in range(length)]

    return [core.std.Interleave([(b_select if i == j else a_select)[j] for j in range(length)]) for i in range(length)]

weave

weave(
    clip: VideoNode, tff: FieldBasedLike | bool | None = None
) -> ConstantFormatVideoNode
Source code in vsdeinterlace/utils.py
30
31
32
33
34
35
def weave(clip: vs.VideoNode, tff: FieldBasedLike | bool | None = None) -> ConstantFormatVideoNode:
    assert check_variable(clip, weave)

    tff = FieldBased.from_param_or_video(tff, clip, True, weave).is_tff

    return clip.std.DoubleWeave(tff)[::2]