diff --git a/media/gpu/windows/media_foundation_video_encode_accelerator_win.cc b/media/gpu/windows/media_foundation_video_encode_accelerator_win.cc index 0000000000..1111111111 100644 --- a/media/gpu/windows/media_foundation_video_encode_accelerator_win.cc +++ b/media/gpu/windows/media_foundation_video_encode_accelerator_win.cc @@ -3111,6 +3111,18 @@ HRESULT MediaFoundationVideoEncodeAccelerator::PerformD3DCopy( D3D11_TEXTURE2D_DESC input_desc; input_texture->GetDesc(&input_desc); + // The destination texture (`copied_d3d11_texture_`) is hardcoded to + // DXGI_FORMAT_NV12 in InitializeD3DCopying(). CopySubresourceRegion + // requires source and destination formats to be in the same type group; + // if they are not, the D3D11 runtime silently drops the copy, leaving + // the destination filled with uninitialized GPU memory which would then + // be encoded and returned to the caller. + if (input_desc.Format != DXGI_FORMAT_NV12) { + LOG(ERROR) << "Source texture format " << input_desc.Format + << " is incompatible with NV12 destination"; + return E_INVALIDARG; + } + if (visible_rect.x() < 0 || visible_rect.y() < 0 || visible_rect.right() > static_cast(input_desc.Width) || visible_rect.bottom() > static_cast(input_desc.Height)) {