Commit 47ce03d7 authored by wez's avatar wez Committed by Commit bot

Add 8 pixels of padding around each rectangle under VP9.

This is required to avoid encoding artefacts.

BUG=448265

Review URL: https://codereview.chromium.org/851483005

Cr-Commit-Position: refs/heads/master@{#311583}
parent 3f4694f4
...@@ -373,18 +373,20 @@ void VideoEncoderVpx::PrepareImage(const webrtc::DesktopFrame& frame, ...@@ -373,18 +373,20 @@ void VideoEncoderVpx::PrepareImage(const webrtc::DesktopFrame& frame,
} }
// Align the region to macroblocks, to avoid encoding artefacts. // Align the region to macroblocks, to avoid encoding artefacts.
// If VP9 is in use then we also pad the rectangles before aligning them, to
// avoid edge artefacts.
// This also ensures that all rectangles have even-aligned top-left, which // This also ensures that all rectangles have even-aligned top-left, which
// is required for ConvertRGBToYUVWithRect() to work. // is required for ConvertRGBToYUVWithRect() to work.
std::vector<webrtc::DesktopRect> aligned_rects; updated_region->Clear();
int padding = use_vp9_ ? 8 : 0;
for (webrtc::DesktopRegion::Iterator r(frame.updated_region()); for (webrtc::DesktopRegion::Iterator r(frame.updated_region());
!r.IsAtEnd(); r.Advance()) { !r.IsAtEnd(); r.Advance()) {
const webrtc::DesktopRect& rect = r.rect(); const webrtc::DesktopRect& rect = r.rect();
aligned_rects.push_back(AlignRect(webrtc::DesktopRect::MakeLTRB( updated_region->AddRect(AlignRect(webrtc::DesktopRect::MakeLTRB(
rect.left(), rect.top(), rect.right(), rect.bottom()))); rect.left() - padding, rect.top() - padding, rect.right() + padding,
rect.bottom() + padding)));
} }
DCHECK(!aligned_rects.empty()); DCHECK(!updated_region->is_empty());
updated_region->Clear();
updated_region->AddRects(&aligned_rects[0], aligned_rects.size());
// Clip back to the screen dimensions, in case they're not macroblock aligned. // Clip back to the screen dimensions, in case they're not macroblock aligned.
// The conversion routines don't require even width & height, so this is safe // The conversion routines don't require even width & height, so this is safe
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment