forge
Explore
Log in

Don't you dare go Hollow

edith

Clone
★ 0

0 watching0 forksRust18.3 MiB8c7bf80Tahinli3 months ago114 commits

simple_test.py46 lines, 1.7 KiBHistoryRawDownload
1import glob
2import os
3import subprocess
4
5CCDEC_BINARY_PATH = 'target/debug/examples/ccdec'
6
7def validate_decode(bitstream_path, codec):
8 if not os.path.isfile(bitstream_path + '.md5'): # Missing golden, skip this vector
9 return
10
11 with open(bitstream_path + '.md5', 'r') as golden_file:
12 golden = golden_file.read()
13
14 ccdec_process = subprocess.run([CCDEC_BINARY_PATH, bitstream_path, '--frame-memory', 'prime', '--input-format', codec, '--output-format', 'nv12', '--compute-md5', 'frame'], capture_output=True)
15 if ccdec_process.returncode != 0:
16 print('Error running ccdec for bitstream ' + bitstream_path)
17 print(ccdec_process.stderr.decode('utf-8'))
18 return
19
20 test_output = ccdec_process.stdout.decode('utf-8')
21 if test_output != golden:
22 print('MD5 mistmatch on bitstream ' + bitstream_path)
23 test_lines = test_output.split('\n')
24 golden_lines = golden.split('\n')
25 if len(test_lines) > len(golden_lines):
26 print('Found more frames in ccdec output than expected')
27 elif len(test_lines) < len(golden_lines):
28 print('Found fewer frames in ccdec output than expected')
29 else:
30 for i in range(0, len(test_lines)):
31 if test_lines[i] != golden_lines[i]:
32 print('First mismatch on frame ' + str(i))
33 print('Expected: ' + golden_lines[i])
34 print('Got: ' + test_lines[i])
35 break
36
37
38if not os.path.isfile(CCDEC_BINARY_PATH):
39 print('Error! ccdec not found. Have you compiled examples yet?')
40
41extensions = ['.h264', '.h265', '.av1', '.vp8', '.vp9', '.ivf']
42for extension in extensions:
43 for bitstream_path in glob.glob('src/codec/*/test_data/*' + extension):
44 codec = bitstream_path[len('src/codec/'):]
45 codec = codec[:codec.find('/')]
46 validate_decode(bitstream_path, codec)