Skip to content

Commit

Permalink
Add support for new decoders of Fluendo
Browse files Browse the repository at this point in the history
Fluendo divided their decoders by backend and codec, so where before there
were just `fluhwvadec` or `fluhwvah264dec`, now there are
`fluhwva{backend}{codec}` (`fluhwvavaapih264dec` for example).

This commit generate the types for this decoders programmatically, to
reduce the amount of code required otherwise.

Issue: OCP_5454
  • Loading branch information
carlosfg-flu committed Mar 28, 2024
1 parent a18c795 commit cd10980
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions fluster/decoders/gstreamer.py
Original file line number Diff line number Diff line change
Expand Up @@ -912,3 +912,46 @@ class FluendoFluLCEVCVAH264DecGst10Decoder(GStreamer10Video):
api = "HW"
hw_acceleration = True
name = f"{provider}-{codec.value}-{api}-lcevchwvah264dec-Gst1.0"

# Auxiliary function for generate a H264 Fluendo decoder based on the HW API
def new_fluhwvah264dec(api: str):
new_class_name = f"FluendoHWVA{api}H264Gst10Decoder"

new_class = type(new_class_name, (GStreamer10Video,), {})
new_class.provider = "Fluendoo"
new_class.api = api
new_class.codec = Codec.H264
new_class.decoder_bin = f" h264parse ! fluhwva{api.lower()}h264dec "

register_decoder(new_class)

# Auxiliary function for generate a H265 Fluendo decoder based on the HW API
def new_fluhwvah265dec(api: str, strict_format: str, alignment: str):
new_class_name = f"FluendoHWVA{api}H265Gst10Decoder"

def __init__(self):
super(GStreamer10Video, self).__init__()
variant = f"{self.codec.value}-{self.stream_format}-{self.alignment}"
self.name = f"{self.provider}-{variant}-{self.api}-Gst{self.gst_api}"
self.description = f"{self.provider} {variant} {self.api} decoder for GStreamer {self.gst_api}"

new_class = type(new_class_name, (GStreamer10Video,), {"__init__": __init__})
new_class.provider = "Fluendo"
new_class.api = api
new_class.codec = Codec.H265
new_class.stream_format = stream_format
new_class.alignment = alignment
new_class.decoder_bin = (
" h265parse !"
f" video/x-h265,stream-format={stream_format},alignment={alignment} !"
f" fluhwva{api.lower()}h265dec "
)

register_decoder(new_class)

# Generate all Fluendo decoders variants for H264 and H265
for api in ["VAAPI", "VDPAU", "DXVA2", "VDA", "VT"]:
new_fluhwvah264dec(api)
for stream_format in ["byte-stream", "hev1", "hvc1"]:
for alignment in ["au", "nal"]:
new_fluhwvah265dec(api, stream_format, alignment)

0 comments on commit cd10980

Please sign in to comment.