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 78d73969c8fa8..386aa2f5d6550 100644 --- a/media/gpu/windows/media_foundation_video_encode_accelerator_win.cc +++ b/media/gpu/windows/media_foundation_video_encode_accelerator_win.cc @@ -2069,11 +2069,11 @@ HRESULT MediaFoundationVideoEncodeAccelerator::PopulateInputSampleBuffer( : input_stream_info.cbAlignment - 1, &input_buffer); RETURN_ON_HR_FAILURE(hr, "Failed to create memory buffer", hr); + // Only AllocationSize(NV12, input_visible_size_) bytes are written below by + // ConvertAndScale(); advertise that, not cbSize, so the MFT is not handed + // an uninitialised [AllocationSize, cbSize) tail as valid data. hr = input_buffer->SetCurrentLength( - input_stream_info.cbSize - ? input_stream_info.cbSize - : VideoFrame::AllocationSize(kTargetPixelFormat, - input_visible_size_)); + VideoFrame::AllocationSize(kTargetPixelFormat, input_visible_size_)); RETURN_ON_HR_FAILURE(hr, "Failed to set length on buffer", hr); hr = input_sample->AddBuffer(input_buffer.Get()); RETURN_ON_HR_FAILURE(hr, "Failed to add buffer to sample", hr);