forked from intel/vaapi-fits
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdecoder.py
More file actions
92 lines (73 loc) · 2.77 KB
/
decoder.py
File metadata and controls
92 lines (73 loc) · 2.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
###
### Copyright (C) 2024 Intel Corporation
###
### SPDX-License-Identifier: BSD-3-Clause
###
import os
import slash
from ....lib import platform
from ....lib.codecs import Codec
from ....lib.common import get_media
from ....lib.formats import PixelFormat
from ....lib.gstreamer.decoderbase import BaseDecoderTest, Decoder as GstDecoder
from ....lib.gstreamer.util import have_gst_element
from ....lib.gstreamer.d3d11.util import mapformat, mapformatu
class Decoder(GstDecoder):
format = property(lambda s: mapformatu(super().format))
pformat = property(lambda s: mapformat(super().format))
@slash.requires(*have_gst_element("d3d11"))
class DecoderTest(BaseDecoderTest):
DecoderClass = Decoder
def before(self):
super().before()
def decode_test_class(codec, bitdepth, **kwargs):
# caps lookup translation
capcodec = codec
if codec in [Codec.HEVC, Codec.VP9, Codec.AV1]:
capcodec = f"{codec}_{bitdepth}"
# gst element codec translation
gstcodec = {
Codec.AVC : "h264",
Codec.HEVC : "h265",
}.get(codec, codec)
gstparser = {
Codec.MPEG2 : "mpegvideoparse",
Codec.VP8 : None,
}.get(codec, f"{gstcodec}parse")
hwdevice = get_media().render_device.split('/')[-1]
hw = hwdevice if hwdevice not in ['renderD128','renderD129','0'] else ""
@slash.requires(*have_gst_element(f"d3d11{hw}{gstcodec}dec"))
@slash.requires(*platform.have_caps("decode", capcodec))
class CodecDecoderTest(DecoderTest):
def before(self):
super().before()
vars(self).update(
caps = platform.get_caps("decode", capcodec),
codec = codec,
gstdecoder = f"d3d11{hw}{gstcodec}dec",
gstparser = gstparser,
**kwargs,
)
def validate_caps(self):
assert PixelFormat(self.format).bitdepth == bitdepth
super().validate_caps()
return CodecDecoderTest
## AVC ##
AVCDecoderTest = decode_test_class(codec = Codec.AVC, bitdepth = 8)
## HEVC ##
HEVC_8DecoderTest = decode_test_class(codec = Codec.HEVC, bitdepth = 8)
HEVC_10DecoderTest = decode_test_class(codec = Codec.HEVC, bitdepth = 10)
HEVC_12DecoderTest = decode_test_class(codec = Codec.HEVC, bitdepth = 12)
## AV1 ##
AV1_8DecoderTest = decode_test_class(codec = Codec.AV1, bitdepth = 8)
AV1_10DecoderTest = decode_test_class(codec = Codec.AV1, bitdepth = 10)
## VP9 ##
VP9_8DecoderTest = decode_test_class(codec = Codec.VP9, bitdepth = 8)
VP9_10DecoderTest = decode_test_class(codec = Codec.VP9, bitdepth = 10)
VP9_12DecoderTest = decode_test_class(codec = Codec.VP9, bitdepth = 12)
## VP8 ##
VP8DecoderTest = decode_test_class(codec = Codec.VP8, bitdepth = 8)
## JPEG/MJPEG ##
JPEGDecoderTest = decode_test_class(codec = Codec.JPEG, bitdepth = 8)
## MPEG2 ##
MPEG2DecoderTest = decode_test_class(codec = Codec.MPEG2, bitdepth = 8)