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

Unified Diff: webrtc/sdk/objc/Framework/Classes/avfoundationvideocapturer.mm

Issue 2611113003: AVFoundationVideoCapturer: Fix apply_rotation() logic (Closed)
Patch Set: Created 3 years, 11 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: webrtc/sdk/objc/Framework/Classes/avfoundationvideocapturer.mm
diff --git a/webrtc/sdk/objc/Framework/Classes/avfoundationvideocapturer.mm b/webrtc/sdk/objc/Framework/Classes/avfoundationvideocapturer.mm
index 28ae3f2bd4102ac119778141a1cca2a0ed660052..cecb13cdb952052c0e9d9f0cdc88de6195f2c180 100644
--- a/webrtc/sdk/objc/Framework/Classes/avfoundationvideocapturer.mm
+++ b/webrtc/sdk/objc/Framework/Classes/avfoundationvideocapturer.mm
@@ -131,8 +131,8 @@ void AVFoundationVideoCapturer::CaptureSampleBuffer(
return;
}
- const int captured_width = CVPixelBufferGetWidth(image_buffer);
- const int captured_height = CVPixelBufferGetHeight(image_buffer);
+ int captured_width = CVPixelBufferGetWidth(image_buffer);
+ int captured_height = CVPixelBufferGetHeight(image_buffer);
int adapted_width;
int adapted_height;
@@ -161,10 +161,14 @@ void AVFoundationVideoCapturer::CaptureSampleBuffer(
// not critical here.
if (apply_rotation() && rotation != kVideoRotation_0) {
buffer = buffer->NativeToI420Buffer();
- rtc::scoped_refptr<I420Buffer> rotated_buffer =
- (rotation == kVideoRotation_180)
- ? I420Buffer::Create(adapted_width, adapted_height)
- : I420Buffer::Create(adapted_height, adapted_width);
+ rtc::scoped_refptr<I420Buffer> rotated_buffer;
+ if (rotation == kVideoRotation_0 || rotation == kVideoRotation_180) {
kthelgason 2017/01/09 08:18:28 The first case can never happen due to the outer c
magjed_webrtc 2017/01/09 09:31:14 Right, and the previous code just did (rotation ==
+ rotated_buffer = I420Buffer::Create(adapted_width, adapted_height);
+ } else {
+ // Swap width and height.
+ rotated_buffer = I420Buffer::Create(adapted_height, adapted_width);
+ std::swap(captured_width, captured_height);
+ }
libyuv::I420Rotate(
buffer->DataY(), buffer->StrideY(),
buffer->DataU(), buffer->StrideU(),
@@ -175,6 +179,7 @@ void AVFoundationVideoCapturer::CaptureSampleBuffer(
buffer->width(), buffer->height(),
static_cast<libyuv::RotationMode>(rotation));
buffer = rotated_buffer;
+ rotation = kVideoRotation_0;
}
OnFrame(webrtc::VideoFrame(buffer, rotation, translated_camera_time_us),
« 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