player: auto-enable HW decode when VPU accessible — remove R36S_HW_DECODE opt-in gate

This commit is contained in:
Matteo Benedetto
2026-03-24 00:00:19 +01:00
parent 9b8ddb3a05
commit fe2f25d4cf
@@ -62,32 +62,16 @@ def _probe_hw_decoders(gst_module) -> list:
""" """
Probe for available hardware video decoder GStreamer elements. Probe for available hardware video decoder GStreamer elements.
Hardware decode (mppvideodec / V4L2) is only auto-selected when Probe for hardware video decoder GStreamer elements and boost their rank
R36S_HW_DECODE=1 is set in the environment. By default the probe is a above avdec_h264 when a VPU device node is accessible, so decodebin picks
no-op: software avdec_h264 (libav, NEON-optimised) remains preferred them automatically. NV12 frames are uploaded zero-copy via
because mppvideodec outputs NV12 which requires an additional software SDL_UpdateNVTexture so no software colourspace conversion is needed.
NV12→BGRA conversion step that outweighs the decode speedup.
Set R36S_HW_DECODE=1 (e.g. in MatHacks.sh) to enable hardware decode with
zero-copy NV12→SDL upload via SDL_UpdateNVTexture.
Returns the list of element names whose rank was boosted. Returns the list of element names whose rank was boosted.
""" """
if os.environ.get("R36S_HW_DECODE", "0") != "1":
# Still probe and log availability so the user knows the plugin is
# installed, but do not boost rank.
if _vpu_device_accessible():
for name in _HW_DECODER_ELEMENTS:
if gst_module.ElementFactory.find(name) is not None:
log.info(
"HW decode: %s available (VPU accessible) — not auto-selected. "
"Set R36S_HW_DECODE=1 to enable (experimental).", name
)
return []
if not _vpu_device_accessible(): if not _vpu_device_accessible():
log.info( log.info(
"HW decode: R36S_HW_DECODE=1 but no accessible VPU device node — " "HW decode: no accessible VPU device node — "
"falling back to software decode. " "falling back to software decode. "
"Run deploy/arkos/setup_hw_decode.sh as root to fix permissions." "Run deploy/arkos/setup_hw_decode.sh as root to fix permissions."
) )
@@ -416,8 +400,7 @@ class GStreamerBackend(PlayerBackend):
sink.set_property("drop", True) sink.set_property("drop", True)
# Accept NV12 when hardware decode is active (avoids a software colourspace # Accept NV12 when hardware decode is active (avoids a software colourspace
# conversion step); fall back to BGRA for the software-decode path. # conversion step); fall back to BGRA for the software-decode path.
hw_active = os.environ.get("R36S_HW_DECODE", "0") == "1" if self._hw_decoders:
if hw_active:
caps_str = "video/x-raw,format=NV12;video/x-raw,format=BGRA" caps_str = "video/x-raw,format=NV12;video/x-raw,format=BGRA"
else: else:
caps_str = "video/x-raw,format=BGRA" caps_str = "video/x-raw,format=BGRA"