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

Side by Side Diff: media/capture/video/video_capture_device_client.cc

Issue 2508803002: Rotate frames correctly for back camera (Closed)
Patch Set: calculate rotation in video_capture_device_linux Created 4 years, 1 month 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "media/capture/video/video_capture_device_client.h" 5 #include "media/capture/video/video_capture_device_client.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 const int new_unrotated_width = frame_format.frame_size.width() & ~1; 126 const int new_unrotated_width = frame_format.frame_size.width() & ~1;
127 const int new_unrotated_height = frame_format.frame_size.height() & ~1; 127 const int new_unrotated_height = frame_format.frame_size.height() & ~1;
128 128
129 int destination_width = new_unrotated_width; 129 int destination_width = new_unrotated_width;
130 int destination_height = new_unrotated_height; 130 int destination_height = new_unrotated_height;
131 if (rotation == 90 || rotation == 270) 131 if (rotation == 90 || rotation == 270)
132 std::swap(destination_width, destination_height); 132 std::swap(destination_width, destination_height);
133 133
134 DCHECK_EQ(0, rotation % 90) << " Rotation must be a multiple of 90, now: " 134 DCHECK_EQ(0, rotation % 90) << " Rotation must be a multiple of 90, now: "
135 << rotation; 135 << rotation;
136
wuchengli 2016/11/17 09:26:04 revert this
shenghao 2016/11/17 10:15:55 Done.
136 libyuv::RotationMode rotation_mode = libyuv::kRotate0; 137 libyuv::RotationMode rotation_mode = libyuv::kRotate0;
137 if (rotation == 90) 138 if (rotation == 90)
138 rotation_mode = libyuv::kRotate90; 139 rotation_mode = libyuv::kRotate90;
139 else if (rotation == 180) 140 else if (rotation == 180)
140 rotation_mode = libyuv::kRotate180; 141 rotation_mode = libyuv::kRotate180;
141 else if (rotation == 270) 142 else if (rotation == 270)
142 rotation_mode = libyuv::kRotate270; 143 rotation_mode = libyuv::kRotate270;
143 144
144 const gfx::Size dimensions(destination_width, destination_height); 145 const gfx::Size dimensions(destination_width, destination_height);
145 uint8_t *y_plane_data, *u_plane_data, *v_plane_data; 146 uint8_t *y_plane_data, *u_plane_data, *v_plane_data;
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 return; 406 return;
406 memcpy(buffer->data(), data, length); 407 memcpy(buffer->data(), data, length);
407 const VideoCaptureFormat output_format = 408 const VideoCaptureFormat output_format =
408 VideoCaptureFormat(frame_format.frame_size, frame_format.frame_rate, 409 VideoCaptureFormat(frame_format.frame_size, frame_format.frame_rate,
409 media::PIXEL_FORMAT_Y16, media::PIXEL_STORAGE_CPU); 410 media::PIXEL_FORMAT_Y16, media::PIXEL_STORAGE_CPU);
410 OnIncomingCapturedBuffer(std::move(buffer), output_format, reference_time, 411 OnIncomingCapturedBuffer(std::move(buffer), output_format, reference_time,
411 timestamp); 412 timestamp);
412 } 413 }
413 414
414 } // namespace media 415 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698