Fix things on case-insensitive file systems.
[vapoursynth-svn.git] / test / filter_test.py
blob1a8dd079e517af9656e6cb9c0a843463bf02df46
1 import unittest
2 import vapoursynth as vs
4 class FilterTestSequence(unittest.TestCase):
6 def setUp(self):
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])
23 lut = []
24 for x in range(2 ** clip.format.bits_per_sample):
25 lut.append(x)
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])
35 lut = []
36 for y in range(2 ** clipy.format.bits_per_sample):
37 for x in range(2 ** clipx.format.bits_per_sample):
38 lut.append(x)
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])
52 lut = []
53 for y in range(2 ** clipy.format.bits_per_sample):
54 for x in range(2 ** clipx.format.bits_per_sample):
55 lut.append(x)
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])
69 lut = []
70 for y in range(2 ** clipy.format.bits_per_sample):
71 for x in range(2 ** clipx.format.bits_per_sample):
72 lut.append(x)
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])
86 lut = []
87 for y in range(2 ** clipy.format.bits_per_sample):
88 for x in range(2 ** clipx.format.bits_per_sample):
89 lut.append(x)
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])
102 lut = []
103 for y in range(2 ** clipy.format.bits_per_sample):
104 for x in range(2 ** clipx.format.bits_per_sample):
105 lut.append(x)
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__':
116 unittest.main()