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

Unified Diff: content/renderer/media_recorder/video_track_recorder.cc

Issue 2798863005: Use incoming frame's rotation while converting it to I420 (Closed)
Patch Set: Addressed review comments Created 3 years, 8 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_recorder/video_track_recorder.cc
diff --git a/content/renderer/media_recorder/video_track_recorder.cc b/content/renderer/media_recorder/video_track_recorder.cc
index bc6b59e5cff01e2f3eb3ba7f981c28dc0f4e3afc..48f56ceb57bb31e239d2c4812966b29d62da905c 100644
--- a/content/renderer/media_recorder/video_track_recorder.cc
+++ b/content/renderer/media_recorder/video_track_recorder.cc
@@ -52,6 +52,21 @@ namespace content {
namespace {
+libyuv::RotationMode MediaVideoRotationToRotationMode(
+ media::VideoRotation rotation) {
+ switch (rotation) {
+ case media::VIDEO_ROTATION_0:
+ return libyuv::kRotate0;
+ case media::VIDEO_ROTATION_90:
+ return libyuv::kRotate90;
+ case media::VIDEO_ROTATION_180:
+ return libyuv::kRotate180;
+ case media::VIDEO_ROTATION_270:
+ return libyuv::kRotate270;
+ }
emircan 2017/04/07 19:50:55 Add "NOTREACHED();". It makes sure that we will be
Chandan 2017/04/10 10:36:15 Done.
+ return libyuv::kRotate0;
+}
+
// HW encoders expect a nonzero bitrate, so |kVEADefaultBitratePerPixel| is used
// to estimate bits per second for ~30 fps with ~1/16 compression rate.
const int kVEADefaultBitratePerPixel = 2;
@@ -303,10 +318,24 @@ void VideoTrackRecorder::Encoder::RetrieveFrameOnMainThread(
DCHECK(video_frame->HasTextures());
DCHECK_EQ(media::PIXEL_FORMAT_ARGB, video_frame->format());
- frame = media::VideoFrame::CreateFrame(
- media::PIXEL_FORMAT_I420, video_frame->coded_size(),
- video_frame->visible_rect(), video_frame->natural_size(),
- video_frame->timestamp());
+ gfx::Size coded_size = video_frame->coded_size(),
+ natural_size = video_frame->natural_size();
+ gfx::Rect visible_rect = video_frame->visible_rect();
emircan 2017/04/07 19:50:55 You can do all these calculations based on visible
Chandan 2017/04/10 10:36:15 Done.
+ media::VideoRotation video_rotation = media::VIDEO_ROTATION_0;
+ if (video_frame->metadata()->GetRotation(
+ media::VideoFrameMetadata::ROTATION, &video_rotation)) {
emircan 2017/04/07 19:50:55 Merge two if statements with &&.
Chandan 2017/04/10 10:36:15 Done.
+ if (video_rotation == media::VIDEO_ROTATION_90 ||
+ video_rotation == media::VIDEO_ROTATION_270) {
+ coded_size.SetSize(coded_size.height(), coded_size.width());
+ natural_size.SetSize(natural_size.height(), natural_size.width());
+ visible_rect.set_width(visible_rect.height());
+ visible_rect.set_height(visible_rect.width());
Chandan 2017/04/07 13:21:55 I am not too confident of this change. Please sugg
emircan 2017/04/07 19:50:55 I can totally understand, sorry for my late respon
Chandan 2017/04/10 10:36:15 Thanks!
+ }
+ }
+
+ frame = media::VideoFrame::CreateFrame(media::PIXEL_FORMAT_I420, coded_size,
+ visible_rect, natural_size,
+ video_frame->timestamp());
const SkImageInfo info = SkImageInfo::MakeN32(
frame->visible_rect().width(), frame->visible_rect().height(),
@@ -331,9 +360,11 @@ void VideoTrackRecorder::Encoder::RetrieveFrameOnMainThread(
DLOG(ERROR) << "Error trying to map PaintSurface's pixels";
return;
}
- // TODO(mcasas): Use the incoming frame's rotation when
- // https://bugs.chromium.org/p/webrtc/issues/detail?id=6069 is closed.
- const libyuv::RotationMode source_rotation = libyuv::kRotate0;
+
+ libyuv::RotationMode source_rotation = libyuv::kRotate0;
+ if (video_rotation != media::VIDEO_ROTATION_0)
+ source_rotation = MediaVideoRotationToRotationMode(video_rotation);
+
const uint32 source_pixel_format =
(kN32_SkColorType == kRGBA_8888_SkColorType) ? libyuv::FOURCC_ABGR
: libyuv::FOURCC_ARGB;
« 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