Skip to content
This repository has been archived by the owner on Mar 22, 2022. It is now read-only.

Support HW encoding and decoding on HL2 #27

Open
grbury opened this issue Jul 31, 2019 · 7 comments
Open

Support HW encoding and decoding on HL2 #27

grbury opened this issue Jul 31, 2019 · 7 comments
Assignees
Labels
enhancement New feature or request

Comments

@grbury
Copy link
Contributor

grbury commented Jul 31, 2019

Do we get performance improvements on HL2 by leveraging HW encoding and decoding? Would be great to know whats possible.

@grbury grbury added the enhancement New feature or request label Jul 31, 2019
@djee-ms
Copy link
Member

djee-ms commented Jul 31, 2019

This is planned for the short term.

Note that there is already some preliminary support for selecting a preferred audio/video codec by manipulating the SDP offer packet:

if ((PreferredAudioCodec.Length > 0) || (PreferredVideoCodec.Length > 0))
{
var builder = new StringBuilder(sdp.Length);
ulong lengthInOut = (ulong)builder.Capacity;
if (NativeMethods.SdpForceCodecs(sdp, PreferredAudioCodec, PreferredVideoCodec, builder, ref lengthInOut))
{
builder.Length = (int)lengthInOut;
sdp = builder.ToString();
}
}

This is also exposed as a property in the LocalVideoSource and LocalAudioSource components of the Unity integration.

However I didn't verify yet if that guarantees hardware encoding/decoding, nor what kind of performance and thermal gain we get from this.

@djee-ms djee-ms pinned this issue Aug 14, 2019
@djee-ms djee-ms unpinned this issue Aug 14, 2019
@djee-ms djee-ms added this to the v1.0 release milestone Aug 28, 2019
@djee-ms djee-ms self-assigned this Aug 28, 2019
@djee-ms
Copy link
Member

djee-ms commented Sep 16, 2019

Update: Hardware encoding is confirmed to work on HoloLens 2 simply by using PreferredVideoCodec = "H264", without any other change.

@jahnotto
Copy link

jahnotto commented Oct 8, 2019

Update: Hardware encoding is confirmed to work on HoloLens 2 simply by using PreferredVideoCodec = "H264", without any other change.

Decoding as well?

@djee-ms
Copy link
Member

djee-ms commented Oct 8, 2019

I didn't close this issue because I am sure at 99.99% it is, but I need to run that against the Media Foundation team at some point to validate 100% this is indeed the case (I already got that validation for the encoder). But yes, the code is in place and unless there is a bug in the decoder configuration I am not aware of, the decoder is also currently configured to use hardware decoding where available.

@djee-ms djee-ms removed this from the v1.0 release milestone Dec 19, 2019
@djee-ms
Copy link
Member

djee-ms commented Dec 19, 2019

Update: hardware H.264 encoding is confirmed on UWP as stated above, but hardware decoding was never confirmed, and shall be assumed not present. We have no official visibility/plans on adding it at this time, due to resourcing, so removing any milestone reference for this feature.

@jahnotto
Copy link

jahnotto commented Feb 1, 2021

Any updates on hardware decoding of H.264 and/or H.265 on HoloLens 2? @djee-ms

@djee-ms
Copy link
Member

djee-ms commented Feb 1, 2021

Amazingly, the Media Foundation team has been unable to provide us with a reliable method to determine which decoder is used internally when using their API (hardware or fallback software). It seems their API acts as a complete blackbox, and even with ETW traces we can't tell anything about its functioning. Since I never heard about any decoding performance issue from any user, and never saw it appear in profiling myself, we have reasonable confidence that hardware decoding is indeed used, because we expect software H.264 decoding would show up in profiling. But we can't confirm it 100%, that's why we didn't close this issue.

If you have some performance issue decoding please provide us with info and we can investigate. Otherwise unfortunately there is little chance we are looking into a 100% confidence answer to this anytime soon if this doesn't prove an issue in practice for anyone.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants