Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix priority being ignored in some Format filters #2456

Merged
merged 7 commits into from
Jan 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions package/src/devices/getCameraFormat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,32 +218,34 @@ export function getCameraFormat(device: CameraDevice, filters: FormatFilter[]):

// Find video stabilization mode
if (filter.videoStabilizationMode != null) {
if (bestFormat.videoStabilizationModes.includes(filter.videoStabilizationMode.target)) leftPoints++
if (format.videoStabilizationModes.includes(filter.videoStabilizationMode.target)) rightPoints++
if (bestFormat.videoStabilizationModes.includes(filter.videoStabilizationMode.target))
leftPoints += filter.videoStabilizationMode.priority
if (format.videoStabilizationModes.includes(filter.videoStabilizationMode.target))
rightPoints += filter.videoStabilizationMode.priority
}

// Find pixel format
if (filter.pixelFormat != null) {
if (bestFormat.pixelFormats.includes(filter.pixelFormat.target)) leftPoints++
if (format.pixelFormats.includes(filter.pixelFormat.target)) rightPoints++
if (bestFormat.pixelFormats.includes(filter.pixelFormat.target)) leftPoints += filter.pixelFormat.priority
if (format.pixelFormats.includes(filter.pixelFormat.target)) rightPoints += filter.pixelFormat.priority
}

// Find Photo HDR formats
if (filter.photoHdr != null) {
if (bestFormat.supportsPhotoHdr === filter.photoHdr.target) leftPoints++
if (format.supportsPhotoHdr === filter.photoHdr.target) rightPoints++
if (bestFormat.supportsPhotoHdr === filter.photoHdr.target) leftPoints += filter.photoHdr.priority
if (format.supportsPhotoHdr === filter.photoHdr.target) rightPoints += filter.photoHdr.priority
}

// Find Video HDR formats
if (filter.videoHdr != null) {
if (bestFormat.supportsVideoHdr === filter.videoHdr.target) leftPoints++
if (format.supportsVideoHdr === filter.videoHdr.target) rightPoints++
if (bestFormat.supportsVideoHdr === filter.videoHdr.target) leftPoints += filter.videoHdr.priority
if (format.supportsVideoHdr === filter.videoHdr.target) rightPoints += filter.videoHdr.priority
}

// phase-detection is generally the best AF system
// Find matching AF system
if (filter.autoFocusSystem != null) {
if (bestFormat.autoFocusSystem === filter.autoFocusSystem.target) leftPoints++
if (format.autoFocusSystem === filter.autoFocusSystem.target) rightPoints++
if (bestFormat.autoFocusSystem === filter.autoFocusSystem.target) leftPoints += filter.autoFocusSystem.priority
if (format.autoFocusSystem === filter.autoFocusSystem.target) rightPoints += filter.autoFocusSystem.priority
}

if (rightPoints > leftPoints) bestFormat = format
Expand Down
Loading