Repository navigation
fix: advertise HEVC only when the GPU can decode it - #232
Merged
swellweb merged 2 commits intoNov 12, 2026
Merged
Conversation
tb_dec_supports_hevc_hwdecode() only checked that FFmpeg has a VideoToolbox hwaccel config and that a hwdevice context can be created. Both succeed on Macs without an HEVC decode block, where VideoToolbox silently falls back to its software decoder. The receiver then advertised supportsHEVCDecode=1 and the sender's automatic codec choice picked HEVC, which a 2014 iMac 5K can only decode on the CPU (VTDecoderXPCService at ~120% CPU, laggy pointer). Ask VideoToolbox directly with VTIsHardwareDecodeSupported (macOS 10.13+). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…size With the receiver now advertising HEVC only when it has a hardware decoder, an automatic 5K session to e.g. a Haswell iMac would find no codec at all: Apple Silicon has no hardware H.264 encoder at 5120x2880, and HEVC is no longer marked available. Fall back to HEVC (software-decoded on the receiver) so such sessions keep working exactly as before, while sizes H.264 can encode now get hardware-decoded H.264. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Nov 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
tb_dec_supports_hevc_hwdecode()decides whether the receiver advertisessupportsHEVCDecode(Bonjour TXT record and display-profile JSON). It only checks that FFmpeg has a VideoToolbox hwaccel config for HEVC and thatav_hwdevice_ctx_create()succeeds. Both are true on every Mac, including ones whose GPU has no HEVC decode block. On those Macs VideoToolbox silently falls back to its software HEVC decoder (insideVTDecoderXPCService).The receiver therefore claims HEVC support, the sender's automatic codec choice picks HEVC, and the iMac decodes every frame on the CPU.
Observed on an iMac15,1 (Late 2014 5K, i5-4690 Haswell, R9 M290X), 5K extended session with automatic codec selection:
VTCompressionSession ... codec hvc1VTDecoderXPCServicesits at 118–132 % CPU, whileTargetBridgeReceiveritself is at ~20 %Fix
decoder.c): on Apple platforms, also requireVTIsHardwareDecodeSupported(kCMVideoCodecType_HEVC). It has been available since macOS 10.13, so it fits the receiver's 11.0 deployment target. Linux and Windows paths are unchanged.chooseCodec): fixing (1) alone would turn a lagging 5K session into no session. Apple Silicon has no hardware H.264 encoder at 5120×2880, HEVC is no longer marked available, sochooseCodecreturnsnil→ "codec unavailable". I added a last-resort branch: if neither path is available but the sender can hardware-encode HEVC, use HEVC (usedFallback: true), software-decoded on the receiver. For these receivers 5K behaves exactly as before. Sizes that H.264 can encode (≤ 4K) now get H.264, which the receiver decodes in hardware.Verification
I built a tiny harness that links
decoder.cand printstb_dec_supports_hevc_hwdecode(), once againstmaint-3.6and once against this branch:A direct VideoToolbox probe on the same iMac (decode sessions created with
kVTVideoDecoderSpecification_RequireHardwareAcceleratedVideoDecoder) confirms the hardware limits:So on this class of Mac, a codec choice that respects the corrected flag lands on hardware decode at up to 4096×2304. 5K stays CPU-bound either way, but it is no longer forced onto the CPU by a false capability flag.
Tests:
makebuilds cleanly with no new warnings;make testpasses.xcodebuild testpasses forTBSenderAutomationParsingTests(55 tests). The new testtestCodecSelectionUsesSoftwareDecodedHEVCWhenH264CannotEncodeTheSizefails without thechooseCodecchange and passes with it. The existingtestCodecSelectionFailsCleanlyWhenNoHardwarePathExists(no HEVC encoder either) still returnsnil.Caveat on the test setup: the official x86_64 receiver package does not launch on Big Sur (#167), so the iMac numbers come from a receiver built locally against FFmpeg 8.1.2 targeting macOS 11. I could not test an OCLP macOS 14 install.
VTIsHardwareDecodeSupportedreports the GPU's capability, so the same result is expected there, but that has not been verified.FYI, while investigating this I also built a separate experiment for these iMacs that avoids video codecs entirely: BC7 texture tiles, decoded by the receiver GPU. It gives native 5K with ~0 % receiver CPU. Code and measurements: https://github.com/faithpricejp-source/imac-bcdisplay. Happy to discuss in an issue if a transport like that is of interest for TargetBridge.
🤖 Generated with Claude Code