Commit 818f45b6 authored by Henrik Boström's avatar Henrik Boström Committed by Commit Bot

[macOS Capture] On cameras with broken MJPEG, prefer NV12 instead.

We have avoided capturing MJPEG due to a known issue with a specific
camera model.
In the event of MJPEG being picked (e.g. doing 4K on this camera), we
fall back on UYVY (2vuy) instead, which used to be our default pixel
format.

Thanks to [1] we no longer avoid MJPEG unless the camera model is the
problematic one. This leads to better performance.

However in the event that we are on the problematic model and do want
to avoid MJPEG, requesting UYVY makes less sense than requesting NV12.
In either case macOS has to do a conversion for us, because neither
format is natively supported in the requested resolution. If we're
going to request a non-supported format, we might as well request a
format that we want to be using: NV12, which is the new default
format.

In the future when we can encode NV12, this will avoid an additional
conversion from UYVY to NV12, since macOS did the correct conversion
for us.

[1] https://chromium-review.googlesource.com/c/chromium/src/+/2412732

Bug: 1116241, 1124884, 1035077
Change-Id: Ibce938f99194057778ce760ff9b3c4ec68c9b430
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2416289Reviewed-by: default avatarMarkus Handell <handellm@google.com>
Commit-Queue: Markus Handell <handellm@google.com>
Cr-Commit-Position: refs/heads/master@{#808681}
parent 244361b2
...@@ -278,15 +278,13 @@ AVCaptureDeviceFormat* FindBestCaptureFormat( ...@@ -278,15 +278,13 @@ AVCaptureDeviceFormat* FindBestCaptureFormat(
} }
if (best_fourcc == kCMVideoCodecType_JPEG_OpenDML) { if (best_fourcc == kCMVideoCodecType_JPEG_OpenDML) {
// Capturing MJPEG for some cameras directly doesn't work (they don't // Capturing MJPEG for the following camera does not work (frames not
// forward frames to our sample callback), but for some reason macOS is able // forwarded). macOS can convert to the default pixel format for us instead.
// to pull it off without extreme latency introduced if we specify UYVY
// output format.
// TODO(crbugs.com/1124884): figure out if there's another workaround. // TODO(crbugs.com/1124884): figure out if there's another workaround.
if ([[_captureDevice modelID] isEqualToString:kModelIdLogitech4KPro]) { if ([[_captureDevice modelID] isEqualToString:kModelIdLogitech4KPro]) {
LOG(WARNING) << "Activating MJPEG workaround for camera " LOG(WARNING) << "Activating MJPEG workaround for camera "
<< base::SysNSStringToUTF8(kModelIdLogitech4KPro); << base::SysNSStringToUTF8(kModelIdLogitech4KPro);
best_fourcc = kCMPixelFormat_422YpCbCr8; best_fourcc = kDefaultFourCCPixelFormat;
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment