2 import vapoursynth
as vs
4 class FilterTestSequence(unittest
.TestCase
):
7 self
.core
= vs
.get_core()
9 def checkDifference(self
, cpu
, gpu
):
10 diff
= self
.core
.std
.PlaneDifference([cpu
, gpu
], 0, prop
="PlaneDifference0")
11 diff
= self
.core
.std
.PlaneDifference([diff
, gpu
], 1, prop
="PlaneDifference1")
12 diff
= self
.core
.std
.PlaneDifference([diff
, gpu
], 2, prop
="PlaneDifference2")
14 for i
in range(diff
.num_frames
):
15 frame
= diff
.get_frame(i
)
16 self
.assertEqual(frame
.props
.PlaneDifference0
[0], 0)
17 self
.assertEqual(frame
.props
.PlaneDifference1
[0], 0)
18 self
.assertEqual(frame
.props
.PlaneDifference2
[0], 0)
20 def testLUT16Bit(self
):
21 clip
= self
.core
.std
.BlankClip(format
=vs
.YUV420P16
, color
=[69, 242, 115])
24 for x
in range(2 ** clip
.format
.bits_per_sample
):
27 ret
= self
.core
.std
.Lut(clip
, lut
, [0, 1, 2])
29 self
.checkDifference(clip
, ret
)
31 def testLUT2_8Bit(self
):
32 clipx
= self
.core
.std
.BlankClip(format
=vs
.YUV420P8
, color
=[69, 242, 115])
33 clipy
= self
.core
.std
.BlankClip(format
=vs
.YUV420P8
, color
=[115, 103, 205])
36 for y
in range(2 ** clipy
.format
.bits_per_sample
):
37 for x
in range(2 ** clipx
.format
.bits_per_sample
):
40 ret
= self
.core
.std
.Lut2(clips
=[clipx
, clipy
], lut
=lut
, planes
=[0, 1, 2], bits
=8)
41 self
.checkDifference(clipx
, ret
)
43 ret
= self
.core
.std
.Lut2(clips
=[clipx
, clipy
], lut
=lut
, planes
=[0, 1, 2], bits
=10)
44 comp
= self
.core
.std
.BlankClip(format
=vs
.YUV420P10
, color
=[69, 242, 115])
45 self
.checkDifference(comp
, ret
)
47 def testLUT2_8Bit_10Bit(self
):
48 # Check 8-bit, 10-bit source.
49 clipx
= self
.core
.std
.BlankClip(format
=vs
.YUV420P8
, color
=[69, 242, 115])
50 clipy
= self
.core
.std
.BlankClip(format
=vs
.YUV420P10
, color
=[15, 900, 442])
53 for y
in range(2 ** clipy
.format
.bits_per_sample
):
54 for x
in range(2 ** clipx
.format
.bits_per_sample
):
57 ret
= self
.core
.std
.Lut2(clips
=[clipx
, clipy
], lut
=lut
, planes
=[0, 1, 2], bits
=8)
58 self
.checkDifference(clipx
, ret
)
60 ret
= self
.core
.std
.Lut2(clips
=[clipx
, clipy
], lut
=lut
, planes
=[0, 1, 2], bits
=10)
61 comp
= self
.core
.std
.BlankClip(format
=vs
.YUV420P10
, color
=[69, 242, 115])
62 self
.checkDifference(comp
, ret
)
64 # Check 10-bit, 8-bit source.
65 # Colors are 8-bit levels for 10-bit clip so that we can verify output.
66 clipx
= self
.core
.std
.BlankClip(format
=vs
.YUV420P10
, color
=[15, 235, 115])
67 clipy
= self
.core
.std
.BlankClip(format
=vs
.YUV420P8
, color
=[69, 242, 115])
70 for y
in range(2 ** clipy
.format
.bits_per_sample
):
71 for x
in range(2 ** clipx
.format
.bits_per_sample
):
74 ret
= self
.core
.std
.Lut2(clips
=[clipx
, clipy
], lut
=lut
, planes
=[0, 1, 2], bits
=8)
75 comp
= self
.core
.std
.BlankClip(format
=vs
.YUV420P8
, color
=[15, 235, 115])
76 self
.checkDifference(comp
, ret
)
78 ret
= self
.core
.std
.Lut2(clips
=[clipx
, clipy
], lut
=lut
, planes
=[0, 1, 2], bits
=10)
79 self
.checkDifference(clipx
, ret
)
81 def testLUT2_9Bit_10Bit(self
):
82 # Check 9-bit, 10-bit source.
83 clipx
= self
.core
.std
.BlankClip(format
=vs
.YUV420P9
, color
=[384, 10, 500])
84 clipy
= self
.core
.std
.BlankClip(format
=vs
.YUV420P10
, color
=[15, 600, 900])
87 for y
in range(2 ** clipy
.format
.bits_per_sample
):
88 for x
in range(2 ** clipx
.format
.bits_per_sample
):
91 ret
= self
.core
.std
.Lut2(clips
=[clipx
, clipy
], lut
=lut
, planes
=[0, 1, 2], bits
=9)
92 self
.checkDifference(clipx
, ret
)
94 ret
= self
.core
.std
.Lut2(clips
=[clipx
, clipy
], lut
=lut
, planes
=[0, 1, 2], bits
=8)
95 comp
= self
.core
.std
.BlankClip(format
=vs
.YUV420P8
, color
=[128, 10, 244])
96 self
.checkDifference(comp
, ret
)
98 # Check 10-bit, 9-bit source.
99 clipx
= self
.core
.std
.BlankClip(format
=vs
.YUV420P10
, color
=[384, 10, 500])
100 clipy
= self
.core
.std
.BlankClip(format
=vs
.YUV420P9
, color
=[15, 384, 511])
103 for y
in range(2 ** clipy
.format
.bits_per_sample
):
104 for x
in range(2 ** clipx
.format
.bits_per_sample
):
107 ret
= self
.core
.std
.Lut2(clips
=[clipx
, clipy
], lut
=lut
, planes
=[0, 1, 2], bits
=9)
108 comp
= self
.core
.std
.BlankClip(format
=vs
.YUV420P9
, color
=[384, 10, 500])
109 self
.checkDifference(comp
, ret
)
111 ret
= self
.core
.std
.Lut2(clips
=[clipx
, clipy
], lut
=lut
, planes
=[0, 1, 2], bits
=8)
112 comp
= self
.core
.std
.BlankClip(format
=vs
.YUV420P8
, color
=[128, 10, 244])
113 self
.checkDifference(comp
, ret
)
115 if __name__
== '__main__':