Commit Graph

190 Commits

Author SHA1 Message Date
Cameron Gutman 5faa5fece8 Don't manually override v4l2m2m buffer counts
This causes POLLERR when decoding from meson-vdec on the Libre
Computer Alta (and likely other Amlogic boards). Our requried buffer
counts were already lower than the default 16/20 configuration that
FFmpeg uses, so overriding them was just a memory usage optimization.
2026-04-20 00:25:21 -05:00
Cameron Gutman 88b4a17fe1 Use AV_CODEC_RECEIVE_FRAME_FLAG_SYNCHRONOUS for decoder probing on FFmpeg 8.1 2026-03-28 16:30:28 -05:00
Cameron Gutman 8326223220 Revert "Use EOS to force decoder test frame output"
It causes hangs on defective v4l2m2m decoders, and it's not always
well-supported by out-of-tree decoders either.

This reverts commit 66a30c66f3.
2026-03-28 16:24:20 -05:00
Cameron Gutman 6f4ced5ed6 Assume GPUs on non-x86 platforms are slow by default
This can be overriden with GL_IS_SLOW=0 at runtime
for systems with a fast GPU, though it doesn't make
much difference either way for non-KMSDRM cases.

For slower GPUs, this enables important scaling and
rendering optimizations that can substantially
improve performance (especially on fillrate-limited
GPUs common in SBCs).
2026-02-05 23:17:23 -06:00
Cameron Gutman 792f762c15 Standardize on QString::toUtf8() 2026-01-26 21:49:08 -06:00
Cameron Gutman 8c9c799f81 Fix Clazy non-pod-global-static warnings 2026-01-26 21:49:08 -06:00
Cameron Gutman 218ffc2d55 Set explicit scaling mode for all SDL textures 2026-01-17 02:34:54 -06:00
Cameron Gutman 66a30c66f3 Use EOS to force decoder test frame output 2026-01-16 01:08:51 -06:00
Cameron Gutman d865c77975 Crop the incoming frames if they deviate slightly from the expected size
Fixes #1466
2026-01-11 20:58:48 -06:00
Cameron Gutman c14ebb1ad7 Adjust buffer count for hwaccel and v4l2m2m decoders
- For hwaccel decoders, don't depend on FFmpeg's 4 working surfaces.
  The decoders might need one or more of them internally.

- For V4L2M2M decoders, adjust the buffer counts to match our needs
  and requirements regarding Pacer-held frames.
2026-01-11 14:18:22 -06:00
Cameron Gutman d3957b3cbb Fix race condition where a separate test decoder could ingest a real frame 2026-01-11 13:41:12 -06:00
Cameron Gutman b41c4022ea Ensure there are enough hwframes for Pacer 2026-01-10 18:13:49 -06:00
Cameron Gutman b108684edc Handle missing bitstream restrictions element in H.264 SPS fixup
NVENC on the 591.59 driver seems to not include the bitstream
restrictions element, which renders our attempt to set the
max_dec_frame_buffering value ineffective. Handle this by
providing inserting default bitstream restrictions if one
is not present.
2025-12-30 17:12:37 -06:00
Cameron Gutman 249c29b74c Allow GL_IS_SLOW and VULKAN_IS_SLOW to be overridden at runtime 2025-12-27 21:40:32 -06:00
Cameron Gutman 1cf207de07 Allow overriding FFmpeg AVOptions via environment variable 2025-12-27 21:07:04 -06:00
Cameron Gutman 41ad3c0938 Add environment variable override helper function
This allows FORCE_QT_GLES and SEPARATE_TEST_DECODER to override both true and false.
2025-12-27 15:33:39 -06:00
Cameron Gutman 85ea28287e Add workaround for AV1 reinit bug and quiet some debug output 2025-12-23 00:59:19 -06:00
Cameron Gutman a6f8901a18 Reuse the test decoder to improve startup performance 2025-12-23 00:32:36 -06:00
Cameron Gutman d501a627f0 Test all renderers before use
Every renderer except SDL had opted-in for testing due to various
quirks discovered over the years, so just do away with this option
and test all renderers.
2025-12-22 23:58:26 -06:00
Cameron Gutman 526d815930 Don't fall back to the generic hwaccel for DRM_PRIME formats 2025-12-22 15:06:20 -06:00
Cameron Gutman dbcc6a9089 Improve initialization performance when using Vulkan Video decoding 2025-12-07 17:57:22 -06:00
Cameron Gutman 8ed7144751 Disable bitrate reporting until FEC accuracy issues are resolved 2025-11-15 12:22:51 -06:00
Andy Grundman 66b96e75af Convert all time-based stats to be microsecond-based, improving accuracy of very fast events. Add bitrate average/peak. 2025-11-15 12:17:59 -06:00
Cameron Gutman c5ca672865 Don't set pix_fmt for hwaccel decoders
This works around a bug in the AV1 Vulkan decoding code in FFmpeg
that causes it to incorrectly skip hwaccel init.

Fixes #1511
2025-10-19 16:16:06 -05:00
Cameron Gutman 4c5bcee8dc Give up immediately if the backend fails to initialize 2025-02-18 19:46:29 -06:00
Cameron Gutman fd70865026 Avoid retrying renderer init if we know the error was not transient 2025-02-18 19:02:12 -06:00
Cameron Gutman 9936085aee Fix incorrect selection if pix_fmt is overridden before ffGetFormat()
The DRM renderer does this for the out-of-tree v4l2m2m patches to ensure
we get NV12 buffers, but it ends up clobbering our own preference for
DRM_PRIME frames in the process.
2024-10-03 20:28:51 -05:00
Cameron Gutman 13880353d8 Use new avcodec_get_supported_config() API in FFmpeg 7.1 2024-09-29 22:23:37 -05:00
Cameron Gutman df814fef4a Implement support for HDR with software decoding on macOS 2024-08-22 00:05:26 -05:00
Cameron Gutman 1bb16be183 Allow DrmRenderer to act as a non-DRM hwaccel backend
This case basically works like a degenerate case of a DRM hwaccel
without DRM master where we just provide EGL export functionality
except that we don't even need a DRM FD in this case.

There are patches floating around the FFmpeg list for this:
https://patchwork.ffmpeg.org/project/ffmpeg/list/?series=12604
2024-08-17 17:04:30 -05:00
Cameron Gutman dd9569913b Remove hardcoded block for YUV444 on non-Vulkan renderers 2024-07-26 01:20:48 -05:00
ns6089 da0244c538 Support YUV 4:4:4 formats 2024-07-24 20:54:13 -05:00
Cameron Gutman 52583f5c71 Consolidate decoder checks to reduce code duplication 2024-07-12 19:02:20 -05:00
Cameron Gutman 952ebcd0d2 Prefer zero-copy formats for non-hwaccel hardware decoders
SpacemiT K1's BSP has a version of FFmpeg that contains both
v4l2m2m and their own *_stcodec decoders. Not only is their
V4L2 driver for their mvx decoder seemingly totally broken
(output buffers are all zeros), but it doesn't have any of
the DRM_PRIME support work that is maintained out of tree.

The result is we use a broken copyback decoder instead of
a (mostly) working zero-copy decoder because we didn't
include any logic to rank non-hwaccel decoders by pixfmt
like we have with device type for hwaccel decoders.
2024-07-12 18:45:46 -05:00
Cameron Gutman b5b2731d5f Add support for rendering software decoded frames with Vulkan 2024-07-06 16:49:35 -05:00
Cameron Gutman 34fa7167b1 Force AV_CODEC_CAP_HARDWARE set for OMX decoders
There are at least 2 out-of-tree OMX decoder implementations
that both lack AV_CODEC_CAP_HARDWARE, so they trick us into
thinking that neither of them is hardware accelerated.

Fixes false decoder warnings when linked against the patched
FFmpeg builds shipping on VisionFive 2 and LicheePi 4A SBCs.
2024-07-05 23:04:10 -05:00
Cameron Gutman 27b173b76b Add a GenericHwAccelRenderer for unknown hwaccels
This will get us limited hardware acceleration even for hwaccels
that we don't know about yet.
2024-07-05 22:49:52 -05:00
Cameron Gutman e76780e105 Add a new prepareToRender() callback for renders to perform their initial window clears
This consolidates all the clearing that was strewn across the codebase.
2024-06-25 23:12:18 -05:00
Cameron Gutman 76d0eb6b63 Avoid trying VDPAU when Vulkan is preferred
The VDPAU renderer causes interoperability issues with Vulkan.
2024-04-18 00:41:24 -05:00
Cameron Gutman f2535f1e6e Avoid D3D9 fallback on lack of codec support unless a D3D11 FL11.0 GPU wasn't found
We'd rather not waste time (and risk crashes) loading the D3D9 driver if the GPU doesn't have the physical decoding hardware at all.
2024-03-26 23:59:18 -05:00
Cameron Gutman cefa567f95 Demote DXVA2 renderer to second pass of hwaccels 2024-03-26 23:04:54 -05:00
Cameron Gutman a093a0ae59 Restore AVSampleDisplayLayer renderer for dGPU/eGPU systems
These sometimes have issues importing decoded frames for Metal rendering.
2024-03-24 17:47:29 -05:00
Cameron Gutman 2a05b890d8 Enable transparent resizing and display changes for supported renderers 2023-12-17 21:15:40 -06:00
Cameron Gutman d4050f3a4f Add HDR metadata to each AVFrame 2023-12-16 17:02:53 -06:00
Cameron Gutman 333d97160e Add opt-in for Vulkan rendering for SDR content with PREFER_VULKAN=1 2023-12-13 01:03:27 -06:00
Cameron Gutman aac5ad3fd0 Add a libplacebo-based Vulkan renderer for HDR and Vulkan video decoding support
Vulkan H.264/HEVC video decoding isn't supported with Fedora's Mesa binaries due to
patent issues, so only the VAAPI/DRM-PRIME import path was tested locally with ANV.

HDR video is getting tonemapped to my SDR monitor reasonably, so HDR output probably
works with GameScope but I haven't confirmed yet.

See #1117
2023-12-12 23:54:23 -06:00
Cameron Gutman 9cba449092 Add config option to allow EGL usage when built with MMAL 2023-10-15 13:03:47 -05:00
Cameron Gutman 2127e1d90b Allow h264_v4l2m2m to be used in RPi builds if manually specified 2023-10-05 18:37:14 -05:00
Cameron Gutman 9d73aa6b4a Fix DrmRenderer not falling back to swframes if DRM PRIME is available 2023-10-05 18:13:52 -05:00
Cameron Gutman dc556d3c9b Try to fix Windows build 2023-09-23 13:33:21 -04:00