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

Unified Diff: media/video/capture/mac/video_capture_device_avfoundation_mac.mm

Issue 860333003: Mac Video Capture: Add support for pixel format NV12 for AVFoundation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
« media/base/mac/coremedia_glue.h ('K') | « media/base/mac/coremedia_glue.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/video/capture/mac/video_capture_device_avfoundation_mac.mm
diff --git a/media/video/capture/mac/video_capture_device_avfoundation_mac.mm b/media/video/capture/mac/video_capture_device_avfoundation_mac.mm
index 2b75cfb8f15282cbd80a6a199cf50fe590c7c8f3..8102df61e2039e45824dc02e7fd9a0d5f141f7b4 100644
--- a/media/video/capture/mac/video_capture_device_avfoundation_mac.mm
+++ b/media/video/capture/mac/video_capture_device_avfoundation_mac.mm
@@ -25,6 +25,9 @@ media::VideoPixelFormat FourCCToChromiumPixelFormat(FourCharCode code) {
return media::PIXEL_FORMAT_YUY2;
case CoreMediaGlue::kCMVideoCodecType_JPEG_OpenDML:
return media::PIXEL_FORMAT_MJPEG;
+ case CoreMediaGlue::kCMPixelFormat_420YpCbCr8BiPlanarVideoRange:
+ case CoreMediaGlue::kCMPixelFormat_420YpCbCr8BiPlanarFullRange:
mcasas 2015/01/28 20:17:01 Correct naming as per earlier comments.
magjed_chromium 2015/01/29 13:42:17 Done.
+ return media::PIXEL_FORMAT_NV12;
default:
return media::PIXEL_FORMAT_UNKNOWN;
}
@@ -312,9 +315,31 @@ media::VideoPixelFormat FourCCToChromiumPixelFormat(FourCharCode code) {
// Lock the frame and calculate frame size.
if (CVPixelBufferLockBaseAddress(videoFrame, kCVPixelBufferLock_ReadOnly) ==
kCVReturnSuccess) {
- baseAddress = static_cast<char*>(CVPixelBufferGetBaseAddress(videoFrame));
- frameSize = CVPixelBufferGetHeight(videoFrame) *
- CVPixelBufferGetBytesPerRow(videoFrame);
+ baseAddress = static_cast<char*>(
+ CVPixelBufferGetPlaneCount(videoFrame) == 0
+ ? CVPixelBufferGetBaseAddress(videoFrame)
+ : CVPixelBufferGetBaseAddressOfPlane(videoFrame, 0));
+ // Chromium expects the data to be tightly packed, i.e. no row padding
+ // and the planes should follow consecutively.
+ switch (captureFormat.pixel_format) {
+ case media::PIXEL_FORMAT_YUY2:
+ case media::PIXEL_FORMAT_UYVY:
+ CHECK_EQ(CVPixelBufferGetBytesPerRow(videoFrame),
+ static_cast<UInt>(2 * captureFormat.frame_size.width()));
+ frameSize = captureFormat.frame_size.GetArea() * 16 / 8; // 16bpp.
+ break;
+ case media::PIXEL_FORMAT_NV12:
+ CHECK_EQ(CVPixelBufferGetBytesPerRowOfPlane(videoFrame, 0),
+ static_cast<UInt>(captureFormat.frame_size.width()));
mcasas 2015/01/28 20:17:01 |UInt| looks funny. What about |uint32| or even be
magjed_chromium 2015/01/29 13:42:17 Done.
+ CHECK_EQ(CVPixelBufferGetBytesPerRowOfPlane(videoFrame, 1),
+ static_cast<UInt>(captureFormat.frame_size.width()));
+ CHECK_EQ(CVPixelBufferGetBaseAddressOfPlane(videoFrame, 1),
+ baseAddress + captureFormat.frame_size.GetArea());
+ frameSize = captureFormat.frame_size.GetArea() * 12 / 8; // 12bpp.
+ break;
+ default:
+ NOTREACHED();
+ }
} else {
videoFrame = nil;
}
« media/base/mac/coremedia_glue.h ('K') | « media/base/mac/coremedia_glue.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698