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

Unified Diff: content/renderer/media/webrtc/webrtc_video_capturer_adapter.cc

Issue 2323573004: Fix crop bug in WebRtcVideoCapturerAdapter (Closed)
Patch Set: Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/media/webrtc/webrtc_video_capturer_adapter.cc
diff --git a/content/renderer/media/webrtc/webrtc_video_capturer_adapter.cc b/content/renderer/media/webrtc/webrtc_video_capturer_adapter.cc
index 2df4c6ef5a94db6187b5e6551d280487807f79e4..d3e5c01c9fbba043b7911aca966a0ab644f20403 100644
--- a/content/renderer/media/webrtc/webrtc_video_capturer_adapter.cc
+++ b/content/renderer/media/webrtc/webrtc_video_capturer_adapter.cc
@@ -136,8 +136,7 @@ void WebRtcVideoCapturerAdapter::OnFrameCaptured(
// Return |frame| directly if it is GpuMemoryBuffer backed, as we want to
// keep the frame on native buffers.
if (frame->HasTextures() ||
- frame->storage_type() ==
- media::VideoFrame::STORAGE_GPU_MEMORY_BUFFERS) {
+ frame->storage_type() == media::VideoFrame::STORAGE_GPU_MEMORY_BUFFERS) {
OnFrame(cricket::WebRtcVideoFrame(
new rtc::RefCountedObject<WebRtcVideoFrameAdapter>(frame),
webrtc::kVideoRotation_0, translated_camera_time_us),
@@ -145,17 +144,19 @@ void WebRtcVideoCapturerAdapter::OnFrameCaptured(
return;
}
- // Create a centered cropped visible rect that preservers aspect ratio for
- // cropped natural size.
- gfx::Rect visible_rect = frame->visible_rect();
- visible_rect.ClampToCenteredSize(gfx::Size(
- visible_rect.width() * adapted_width / orig_width,
- visible_rect.height() * adapted_height / orig_height));
+ // Translate crop rectangle from natural size to visible size.
+ gfx::Rect cropped_visible_rect(
+ frame->visible_rect().x() +
+ crop_x * frame->visible_rect().width() / orig_width,
+ frame->visible_rect().y() +
+ crop_y * frame->visible_rect().height() / orig_height,
+ crop_width * frame->visible_rect().width() / orig_width,
+ crop_height * frame->visible_rect().height() / orig_height);
const gfx::Size adapted_size(adapted_width, adapted_height);
scoped_refptr<media::VideoFrame> video_frame =
nisse-chromium (ooo August 14) 2016/09/09 09:06:57 It would more readable to write frame = media::
magjed_chromium 2016/09/09 10:26:32 I agree it's confusing with multiple frames, but I
media::VideoFrame::WrapVideoFrame(frame, frame->format(),
- visible_rect, adapted_size);
+ cropped_visible_rect, adapted_size);
if (!video_frame)
return;
« 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