Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(135)

Side by Side Diff: remoting/codec/video_encoder_vpx.cc

Issue 851483005: Add 8 pixels of padding around each rectangle under VP9. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@clientShape
Patch Set: Stop using AddRects() Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "remoting/codec/video_encoder_vpx.h" 5 #include "remoting/codec/video_encoder_vpx.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/sys_info.h" 10 #include "base/sys_info.h"
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 } 366 }
367 367
368 void VideoEncoderVpx::PrepareImage(const webrtc::DesktopFrame& frame, 368 void VideoEncoderVpx::PrepareImage(const webrtc::DesktopFrame& frame,
369 webrtc::DesktopRegion* updated_region) { 369 webrtc::DesktopRegion* updated_region) {
370 if (frame.updated_region().is_empty()) { 370 if (frame.updated_region().is_empty()) {
371 updated_region->Clear(); 371 updated_region->Clear();
372 return; 372 return;
373 } 373 }
374 374
375 // Align the region to macroblocks, to avoid encoding artefacts. 375 // Align the region to macroblocks, to avoid encoding artefacts.
376 // If VP9 is in use then we also pad the rectangles before aligning them, to
377 // avoid edge artefacts.
376 // This also ensures that all rectangles have even-aligned top-left, which 378 // This also ensures that all rectangles have even-aligned top-left, which
377 // is required for ConvertRGBToYUVWithRect() to work. 379 // is required for ConvertRGBToYUVWithRect() to work.
378 std::vector<webrtc::DesktopRect> aligned_rects; 380 updated_region->Clear();
381 int padding = use_vp9_ ? 8 : 0;
379 for (webrtc::DesktopRegion::Iterator r(frame.updated_region()); 382 for (webrtc::DesktopRegion::Iterator r(frame.updated_region());
380 !r.IsAtEnd(); r.Advance()) { 383 !r.IsAtEnd(); r.Advance()) {
381 const webrtc::DesktopRect& rect = r.rect(); 384 const webrtc::DesktopRect& rect = r.rect();
382 aligned_rects.push_back(AlignRect(webrtc::DesktopRect::MakeLTRB( 385 updated_region->AddRect(AlignRect(webrtc::DesktopRect::MakeLTRB(
383 rect.left(), rect.top(), rect.right(), rect.bottom()))); 386 rect.left() - padding, rect.top() - padding, rect.right() + padding,
387 rect.bottom() + padding)));
384 } 388 }
385 DCHECK(!aligned_rects.empty()); 389 DCHECK(!updated_region->is_empty());
386 updated_region->Clear();
387 updated_region->AddRects(&aligned_rects[0], aligned_rects.size());
388 390
389 // Clip back to the screen dimensions, in case they're not macroblock aligned. 391 // Clip back to the screen dimensions, in case they're not macroblock aligned.
390 // The conversion routines don't require even width & height, so this is safe 392 // The conversion routines don't require even width & height, so this is safe
391 // even if the source dimensions are not even. 393 // even if the source dimensions are not even.
392 updated_region->IntersectWith( 394 updated_region->IntersectWith(
393 webrtc::DesktopRect::MakeWH(image_->w, image_->h)); 395 webrtc::DesktopRect::MakeWH(image_->w, image_->h));
394 396
395 // Convert the updated region to YUV ready for encoding. 397 // Convert the updated region to YUV ready for encoding.
396 const uint8* rgb_data = frame.data(); 398 const uint8* rgb_data = frame.data();
397 const int rgb_stride = frame.stride(); 399 const int rgb_stride = frame.stride();
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 uint8* map = active_map_.get() + top * active_map_width_; 459 uint8* map = active_map_.get() + top * active_map_width_;
458 for (int y = top; y <= bottom; ++y) { 460 for (int y = top; y <= bottom; ++y) {
459 for (int x = left; x <= right; ++x) 461 for (int x = left; x <= right; ++x)
460 map[x] = 1; 462 map[x] = 1;
461 map += active_map_width_; 463 map += active_map_width_;
462 } 464 }
463 } 465 }
464 } 466 }
465 467
466 } // namespace remoting 468 } // namespace remoting
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698