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

Unified Diff: content/renderer/media/gpu/rtc_video_encoder.cc

Issue 2182183007: Handle scaling frames in RTCVideoEncoder (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: posciak@ comments. Created 4 years, 4 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 | « content/content_tests.gypi ('k') | content/renderer/media/gpu/rtc_video_encoder_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/media/gpu/rtc_video_encoder.cc
diff --git a/content/renderer/media/gpu/rtc_video_encoder.cc b/content/renderer/media/gpu/rtc_video_encoder.cc
index 7ec22b2f3d0a9996ed3ea0f422d9432e8c303567..da955a90f75a0f5250da7110d88d16e69c436d76 100644
--- a/content/renderer/media/gpu/rtc_video_encoder.cc
+++ b/content/renderer/media/gpu/rtc_video_encoder.cc
@@ -585,22 +585,27 @@ void RTCVideoEncoder::Impl::EncodeOneFrame() {
media::VideoEncodeAccelerator::kPlatformFailureError);
return;
}
- // Do a strided copy of the input frame to match the input requirements for
- // the encoder.
- // TODO(sheu): support zero-copy from WebRTC. http://crbug.com/269312
- if (libyuv::I420Copy(next_frame->video_frame_buffer()->DataY(),
- next_frame->video_frame_buffer()->StrideY(),
- next_frame->video_frame_buffer()->DataU(),
- next_frame->video_frame_buffer()->StrideU(),
- next_frame->video_frame_buffer()->DataV(),
- next_frame->video_frame_buffer()->StrideV(),
- frame->data(media::VideoFrame::kYPlane),
- frame->stride(media::VideoFrame::kYPlane),
- frame->data(media::VideoFrame::kUPlane),
- frame->stride(media::VideoFrame::kUPlane),
- frame->data(media::VideoFrame::kVPlane),
- frame->stride(media::VideoFrame::kVPlane),
- next_frame->width(), next_frame->height())) {
+
+ // Do a strided copy and scale (if necessary) the input frame to match
+ // the input requirements for the encoder.
+ // TODO(sheu): Support zero-copy from WebRTC. http://crbug.com/269312
+ // TODO(magjed): Downscale with kFilterBox in an image pyramid instead.
+ if (libyuv::I420Scale(next_frame->video_frame_buffer()->DataY(),
+ next_frame->video_frame_buffer()->StrideY(),
+ next_frame->video_frame_buffer()->DataU(),
+ next_frame->video_frame_buffer()->StrideU(),
+ next_frame->video_frame_buffer()->DataV(),
+ next_frame->video_frame_buffer()->StrideV(),
+ next_frame->width(), next_frame->height(),
+ frame->visible_data(media::VideoFrame::kYPlane),
+ frame->stride(media::VideoFrame::kYPlane),
+ frame->visible_data(media::VideoFrame::kUPlane),
+ frame->stride(media::VideoFrame::kUPlane),
+ frame->visible_data(media::VideoFrame::kVPlane),
+ frame->stride(media::VideoFrame::kVPlane),
+ frame->visible_rect().width(),
+ frame->visible_rect().height(),
+ libyuv::kFilterBox)) {
LogAndNotifyError(FROM_HERE, "Failed to copy buffer",
media::VideoEncodeAccelerator::kPlatformFailureError);
return;
« no previous file with comments | « content/content_tests.gypi ('k') | content/renderer/media/gpu/rtc_video_encoder_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698