-
Notifications
You must be signed in to change notification settings - Fork 118
Enable H265 encoding & decoding on Nvidia GPU #776
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds H265/HEVC hardware encoding and decoding support to the NVIDIA encoder/decoder factory using NVENC/NVDEC. The implementation mirrors the existing H264 codec support.
Key changes:
- New H265 encoder and decoder implementations with full initialization, encoding/decoding, and rate control logic
- Updated factory classes to support both "H265" and "HEVC" codec names
- Added logging for codec initialization
- Build system updated to compile new H265 source files
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| webrtc-sys/src/nvidia/nvidia_encoder_factory.cpp | Added H265/HEVC format registration and codec-specific encoder instantiation |
| webrtc-sys/src/nvidia/nvidia_decoder_factory.cpp | Added H265/HEVC format registration and codec-specific decoder instantiation with corrected comment |
| webrtc-sys/src/nvidia/h265_encoder_impl.h | New header defining NvidiaH265EncoderImpl class with encoding interfaces |
| webrtc-sys/src/nvidia/h265_encoder_impl.cpp | Full H265 encoder implementation including initialization, encoding, and rate control |
| webrtc-sys/src/nvidia/h265_decoder_impl.h | New header defining NvidiaH265DecoderImpl class with decoding interfaces |
| webrtc-sys/src/nvidia/h265_decoder_impl.cpp | Full H265 decoder implementation including configuration, decoding, and format conversion |
| webrtc-sys/src/nvidia/h264_encoder_impl.cpp | Added initialization logging for consistency |
| webrtc-sys/build.rs | Added H265 source files to build configuration |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } | ||
|
|
||
| if (format.name == "H265" || format.name == "HEVC") { | ||
| RTC_LOG(LS_INFO) << "Using NVIDIA HW encoder (NVENC) for H265/HEVC"; | ||
| return std::make_unique<NvidiaH265EncoderImpl>( | ||
| env, cu_context_->GetContext(), CU_MEMORYTYPE_DEVICE, | ||
| NV_ENC_BUFFER_FORMAT_IYUV, format); | ||
| } | ||
| } |
Copilot
AI
Nov 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing fallback logic after codec-specific checks. If a supported format is matched but is neither H264 nor H265/HEVC, the function will fall through and return nullptr without logging. Add an else clause with error logging or move the return nullptr outside the loop to make the control flow explicit.
| } | |
| if (format.name == "H265" || format.name == "HEVC") { | |
| RTC_LOG(LS_INFO) << "Using NVIDIA HW encoder (NVENC) for H265/HEVC"; | |
| return std::make_unique<NvidiaH265EncoderImpl>( | |
| env, cu_context_->GetContext(), CU_MEMORYTYPE_DEVICE, | |
| NV_ENC_BUFFER_FORMAT_IYUV, format); | |
| } | |
| } | |
| } else if (format.name == "H265" || format.name == "HEVC") { | |
| RTC_LOG(LS_INFO) << "Using NVIDIA HW encoder (NVENC) for H265/HEVC"; | |
| return std::make_unique<NvidiaH265EncoderImpl>( | |
| env, cu_context_->GetContext(), CU_MEMORYTYPE_DEVICE, | |
| NV_ENC_BUFFER_FORMAT_IYUV, format); | |
| } else { | |
| RTC_LOG(LS_ERROR) << "Matched supported format '" << format.name | |
| << "' but no encoder implementation is available for this codec."; | |
| return nullptr; | |
| } |
| } | ||
| if (format.name == "H265" || format.name == "HEVC") { | ||
| RTC_LOG(LS_INFO) << "Using NVIDIA HW decoder (NVDEC) for H265/HEVC"; | ||
| return std::make_unique<NvidiaH265DecoderImpl>(cu_context_->GetContext()); |
Copilot
AI
Nov 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing fallback logic after codec-specific checks. If a supported format is matched but is neither H264 nor H265/HEVC, the function will fall through and return nullptr without logging. Add an else clause with error logging or move the return nullptr outside the loop to make the control flow explicit.
| } | |
| if (format.name == "H265" || format.name == "HEVC") { | |
| RTC_LOG(LS_INFO) << "Using NVIDIA HW decoder (NVDEC) for H265/HEVC"; | |
| return std::make_unique<NvidiaH265DecoderImpl>(cu_context_->GetContext()); | |
| } else if (format.name == "H265" || format.name == "HEVC") { | |
| RTC_LOG(LS_INFO) << "Using NVIDIA HW decoder (NVDEC) for H265/HEVC"; | |
| return std::make_unique<NvidiaH265DecoderImpl>(cu_context_->GetContext()); | |
| } else { | |
| RTC_LOG(LS_ERROR) << "Supported format '" << format.name << "' is not handled by NvidiaVideoDecoderFactory."; | |
| return nullptr; |
|
|
||
|
|
Copilot
AI
Nov 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove extra blank line at end of file (line 93).
|
|
||
|
|
Copilot
AI
Nov 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove extra blank line at end of file (line 380).
|
|
||
|
|
Copilot
AI
Nov 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove extra blank line at end of file (line 46).
|
|
||
|
|
Copilot
AI
Nov 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove extra blank line at end of file (line 161).
cloudwebrtc
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm!
No description provided.