From e23c57318ff8a0fe763d6899ecbfff01c91acc8e Mon Sep 17 00:00:00 2001 From: Matteo Benedetto Date: Mon, 23 Mar 2026 22:49:16 +0100 Subject: [PATCH] player: disable mppvideodec auto-rank-boost, add R36S_HW_DECODE=1 opt-in MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit mppvideodec outputs NV12 (hardware format) which GStreamer videoconvert converts to BGRA in scalar software code — slower than avdec_h264 which uses libav's NEON-optimised YUV→BGRA path. Default behaviour: software decode (avdec_h264) at PRIMARY rank. The MPP plugin is still detected and logged so the user knows it is installed and operational. Set R36S_HW_DECODE=1 to re-enable the rank boost once a zero-copy NV12→SDL_UpdateNVTexture (or similar) upload path is implemented. --- .../player/gstreamer_backend.py | 32 +++++++++++++++---- 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/src/r36s_dlna_browser/player/gstreamer_backend.py b/src/r36s_dlna_browser/player/gstreamer_backend.py index 0caaab9..b6e74f4 100644 --- a/src/r36s_dlna_browser/player/gstreamer_backend.py +++ b/src/r36s_dlna_browser/player/gstreamer_backend.py @@ -60,15 +60,35 @@ def _vpu_device_accessible() -> bool: def _probe_hw_decoders(gst_module) -> list: """ - Probe for available hardware video decoder GStreamer elements and boost - their rank so that playbin's internal decodebin prefers them over software - decoders. Returns the list of element names that were found and boosted. - If no VPU device node is accessible the probe is skipped entirely so that - a half-initialised hardware element cannot stall the pipeline. + Probe for available hardware video decoder GStreamer elements. + + Hardware decode (mppvideodec / V4L2) is only auto-selected when + R36S_HW_DECODE=1 is set in the environment. By default the probe is a + no-op: software avdec_h264 (libav, NEON-optimised) remains preferred + because mppvideodec outputs NV12 which requires an additional software + NV12→BGRA conversion step that outweighs the decode speedup. + + Set R36S_HW_DECODE=1 (e.g. in MatHacks.sh) once a zero-copy NV12 SDL + texture upload path is implemented. + + 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(): log.info( - "HW decode: no accessible VPU device node — using software decode. " + "HW decode: R36S_HW_DECODE=1 but no accessible VPU device node — " + "falling back to software decode. " "Run deploy/arkos/setup_hw_decode.sh as root to fix permissions." ) return []