Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 std::vector<webrtc::DesktopRect> aligned_rects; |
| 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 aligned_rects.push_back(AlignRect(webrtc::DesktopRect::MakeLTRB( |
|
Sergey Ulanov
2015/01/13 19:19:42
nit: you can just call updated_region->AddRect() h
Wez
2015/01/13 19:29:05
The idea was to allow AddRects() to do whatever sm
| |
| 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(!aligned_rects.empty()); |
| 386 updated_region->Clear(); | 390 updated_region->Clear(); |
| 387 updated_region->AddRects(&aligned_rects[0], aligned_rects.size()); | 391 updated_region->AddRects(&aligned_rects[0], aligned_rects.size()); |
| 388 | 392 |
| 389 // Clip back to the screen dimensions, in case they're not macroblock aligned. | 393 // 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 | 394 // The conversion routines don't require even width & height, so this is safe |
| 391 // even if the source dimensions are not even. | 395 // even if the source dimensions are not even. |
| 392 updated_region->IntersectWith( | 396 updated_region->IntersectWith( |
| 393 webrtc::DesktopRect::MakeWH(image_->w, image_->h)); | 397 webrtc::DesktopRect::MakeWH(image_->w, image_->h)); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 457 uint8* map = active_map_.get() + top * active_map_width_; | 461 uint8* map = active_map_.get() + top * active_map_width_; |
| 458 for (int y = top; y <= bottom; ++y) { | 462 for (int y = top; y <= bottom; ++y) { |
| 459 for (int x = left; x <= right; ++x) | 463 for (int x = left; x <= right; ++x) |
| 460 map[x] = 1; | 464 map[x] = 1; |
| 461 map += active_map_width_; | 465 map += active_map_width_; |
| 462 } | 466 } |
| 463 } | 467 } |
| 464 } | 468 } |
| 465 | 469 |
| 466 } // namespace remoting | 470 } // namespace remoting |
| OLD | NEW |