From cd109808621bcd6ccac4d2623e5f95a270f26f34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Falgueras=20Garc=C3=ADa?= Date: Thu, 28 Mar 2024 13:49:46 +0100 Subject: [PATCH] Add support for new decoders of Fluendo 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 --- fluster/decoders/gstreamer.py | 43 +++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/fluster/decoders/gstreamer.py b/fluster/decoders/gstreamer.py index ecd12894..f639ea07 100644 --- a/fluster/decoders/gstreamer.py +++ b/fluster/decoders/gstreamer.py @@ -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)