fix: Use compressed buffer format as default format as well (#1884)

* fix: Use compressed buffer format as default format as well

* chore: Format Swift
This commit is contained in:
Marc Rousavy 2023-09-29 15:27:17 +02:00 committed by GitHub
parent 902dc634a4
commit 9d02f5141d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -140,7 +140,20 @@ extension CameraView {
*/ */
private func getPixelFormat(videoOutput: AVCaptureVideoDataOutput) -> OSType { private func getPixelFormat(videoOutput: AVCaptureVideoDataOutput) -> OSType {
// as per documentation, the first value is always the most efficient format // as per documentation, the first value is always the most efficient format
let defaultFormat = videoOutput.availableVideoPixelFormatTypes.first! var defaultFormat = videoOutput.availableVideoPixelFormatTypes.first!
if enableBufferCompression {
// use compressed format instead if we enabled buffer compression
if defaultFormat == kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange &&
videoOutput.availableVideoPixelFormatTypes.contains(kCVPixelFormatType_Lossless_420YpCbCr8BiPlanarVideoRange) {
// YUV 4:2:0 8-bit (limited video colors; compressed)
defaultFormat = kCVPixelFormatType_Lossless_420YpCbCr8BiPlanarVideoRange
}
if defaultFormat == kCVPixelFormatType_420YpCbCr8BiPlanarFullRange &&
videoOutput.availableVideoPixelFormatTypes.contains(kCVPixelFormatType_Lossless_420YpCbCr8BiPlanarFullRange) {
// YUV 4:2:0 8-bit (full video colors; compressed)
defaultFormat = kCVPixelFormatType_Lossless_420YpCbCr8BiPlanarFullRange
}
}
// If the user enabled HDR, we can only use the YUV 4:2:0 10-bit pixel format. // If the user enabled HDR, we can only use the YUV 4:2:0 10-bit pixel format.
if hdr == true { if hdr == true {