This adds support for MFVideoFormat_P010 and MFVideoFormat_A2R10G10B10
in a number of places (both WMF and DVXA2 code paths with ffmpeg).
This advertises that we support HDR to JavaScript so video players can
detect our support if the window is on an HDR display at the time.
This adds comments for several poorly documented parts of the code that
I had to figure out. It changes fallback logic for selecting a WMF
video subtype to do what the code was clearly meant to do (e.g. fall
back from P010 to NV12 or YV12 depending on hw vs sw decode).
Zero copy decode is not supported by this patch, but can be
implemented in a follow-up bug.
HDR videos are now automatically flagged as promoted surfaces more
aggressively than for video in general, because WebRender does not
currently have the ability to do regular CSS/SVG compositing of HDR
video, so we definitely do want it to be a compositor surface if
possible - this is still subject to the MAX_COMPOSITOR_SURFACES limit in
WebRender, so a document with more than 2 or 3 HDR videos will have a
bad time, that is worth fixing in a follow-up bug, and we still don't
have HDR CSS rendering in WebRender as mentioned so any clipmasks will
usually prevent surface promotion for HDR videos, the same goes for
any CSS filter effects or SVG filter primitives applied to a video.
IsHDRTransferFunction() was added to check if a gfx::TransferFunction is
one of the HDR ones (PQ or HLG), but currently TextureHost does not have
any easy way to get the gfx::TransferFunction to DCLayerTree to make a
decision to display it as HDR, so DCLayerTree code is assuming that any
video with BT2020 colorspace is HDR (this is the same assumption we made
on macOS, it has proven surprisingly robust) - it would be good to clean
that up by properly plumbing TransferFunction through TextureHost, which
could be useful for future code paths like HDR canvas and images.
Tests are not added by this patch because properly testing HDR video
would rely heavily on features not currently implemented in WebRender
and ImageLib for reftests to work with high dynamic range colors, we
have already been shipping HDR video on macOS for a while without tests,
so this is not meaningfully different. A proper test suite is planned
in 2026 as a major project that depends on those other moving parts.