You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add H.265 (HEVC) hardware-accelerated encoding and decoding support on Windows
using the Media Foundation Transform (MFT) pipeline. This enables H.265 codec
negotiation and media processing through the OS-provided HEVC MFTs, which
delegate to GPU vendor hardware (NVENC/NVDEC, Intel QSV, AMD AMF) transparently.
Motivation
WebRTC M137 includes H.265 SDP/RTP infrastructure (rtc_use_h265=true) but
ships no encoder/decoder implementations. This PR fills that gap on Windows
without introducing any third-party codec dependencies.
Changes
New files (src/win/)
wmf_h265_encoder.h/.cc — VideoEncoder implementation using HEVC encoder MFT
wmf_h265_decoder.h/.cc — VideoDecoder implementation using HEVC decoder MFT
wmf_h265_factory.h/.cc — Decorator factories that add H.265 to the builtin codec list
COM safety: CoInitializeEx is called in IsSupported() and InitMediaFoundation() so the code works regardless of whether the calling thread has COM initialized
Dynamic resolution change: Decoder handles MF_E_TRANSFORM_STREAM_CHANGE and updates cached dimensions from the new output media type
SDP parameters: Advertises Main profile (profile-id=1), Main tier (tier-flag=0), Level 4.0 (level-id=120)
Hardware acceleration: Both GetEncoderInfo() and GetDecoderInfo() report is_hardware_accelerated = true
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
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.
Summary
Add H.265 (HEVC) hardware-accelerated encoding and decoding support on Windows
using the Media Foundation Transform (MFT) pipeline. This enables H.265 codec
negotiation and media processing through the OS-provided HEVC MFTs, which
delegate to GPU vendor hardware (NVENC/NVDEC, Intel QSV, AMD AMF) transparently.
Motivation
WebRTC M137 includes H.265 SDP/RTP infrastructure (
rtc_use_h265=true) butships no encoder/decoder implementations. This PR fills that gap on Windows
without introducing any third-party codec dependencies.
Changes
New files (
src/win/)wmf_h265_encoder.h/.cc—VideoEncoderimplementation using HEVC encoder MFTwmf_h265_decoder.h/.cc—VideoDecoderimplementation using HEVC decoder MFTwmf_h265_factory.h/.cc— Decorator factories that add H.265 to the builtin codec listModified files
BUILD.gn— Conditionally compile WMF sources whenis_win && !libwebrtc_intel_media_sdk && rtc_use_h265src/rtc_peerconnection_factory_impl.cc— Wire WMF factories intoCreatePeerConnectionFactoryImplementation details
MFTEnumExwithMFT_ENUM_FLAG_HARDWARE | MFT_ENUM_FLAG_SORTANDFILTERto prefer HW-accelerated MFTsCODECAPI_AVEncCommonRateControlMode; dynamic bitrate updates viaCODECAPI_AVEncCommonMeanBitRateCODECAPI_AVEncVideoForceKeyFrameMF_LOW_LATENCYattribute set on both encoder and decoder MFTsH265BitstreamParserextracts per-frame QP intoEncodedImage::qp_requested_resolution_alignment = 2(NV12 requirement)CoInitializeExis called inIsSupported()andInitMediaFoundation()so the code works regardless of whether the calling thread has COM initializedMF_E_TRANSFORM_STREAM_CHANGEand updates cached dimensions from the new output media typeprofile-id=1), Main tier (tier-flag=0), Level 4.0 (level-id=120)GetEncoderInfo()andGetDecoderInfo()reportis_hardware_accelerated = trueBuild flags
rtc_use_h265=trueproprietary_codecs=trueffmpeg_branding="Chrome"No additional flags required. The WMF path activates automatically on Windows when
libwebrtc_intel_media_sdkis not set (default).Requirements