feat: Split videoHdr
and photoHdr
into two settings (#2161)
* feat: Split `videoHdr` and `photoHdr` into two settings * fix: Rename all `hdr` * fix: Fix HDR on Android * Update CameraDeviceDetails.kt * Update CameraDeviceDetails.kt * fix: Correctly configure `pixelFormat` AFTER `format` * Update CameraSession+Configuration.swift * fix: Also after format changed
This commit is contained in:
@@ -142,8 +142,8 @@ export class Camera extends React.PureComponent<CameraProps> {
|
||||
result = (result / 30) * fps
|
||||
// H.265 (HEVC) codec is 20% more efficient
|
||||
if (codec === 'h265') result = result * 0.8
|
||||
// HDR (10-bit) instead of SDR (8-bit) takes up 20% more pixels
|
||||
if (this.props.hdr) result = result * 1.2
|
||||
// 10-Bit Video HDR takes up 20% more pixels than standard range (8-bit SDR)
|
||||
if (this.props.videoHdr) result = result * 1.2
|
||||
// Return overall result
|
||||
return result * factor
|
||||
}
|
||||
|
@@ -91,11 +91,11 @@ export interface CameraDeviceFormat {
|
||||
/**
|
||||
* Specifies whether this format supports HDR mode for video capture
|
||||
*/
|
||||
supportsVideoHDR: boolean
|
||||
supportsVideoHdr: boolean
|
||||
/**
|
||||
* Specifies whether this format supports HDR mode for photo capture
|
||||
*/
|
||||
supportsPhotoHDR: boolean
|
||||
supportsPhotoHdr: boolean
|
||||
/**
|
||||
* Specifies whether this format supports delivering depth data for photo or video capture.
|
||||
*/
|
||||
|
@@ -15,7 +15,7 @@ export type DeviceError =
|
||||
| 'device/camera-not-available-on-simulator'
|
||||
export type FormatError =
|
||||
| 'format/invalid-fps'
|
||||
| 'format/invalid-hdr'
|
||||
| 'format/invalid-video-hdr'
|
||||
| 'format/incompatible-pixel-format-with-hdr-setting'
|
||||
| 'format/invalid-format'
|
||||
export type SessionError =
|
||||
|
@@ -116,7 +116,8 @@ export interface CameraProps extends ViewProps {
|
||||
*
|
||||
* The format defines the possible values for properties like:
|
||||
* - {@linkcode fps}: `format.minFps`...`format.maxFps`
|
||||
* - {@linkcode hdr}: `format.supportsVideoHDR`
|
||||
* - {@linkcode videoHdr}: `format.supportsVideoHdr`
|
||||
* - {@linkcode photoHdr}: `format.supportsPhotoHdr`
|
||||
* - {@linkcode pixelFormat}: `format.pixelFormats``
|
||||
* - {@linkcode enableDepthData}: `format.supportsDepthCapture``
|
||||
* - {@linkcode videoStabilizationMode}: `format.videoStabilizationModes``
|
||||
@@ -139,11 +140,17 @@ export interface CameraProps extends ViewProps {
|
||||
*/
|
||||
fps?: number
|
||||
/**
|
||||
* Enables or disables HDR streaming.
|
||||
* Enables or disables HDR Video Streaming for Preview, Video and Frame Processor via a 10-bit wide-color pixel format.
|
||||
*
|
||||
* Make sure the given {@linkcode format} supports HDR (see {@linkcode CameraDeviceFormat.supportsVideoHDR format.supportsVideoHDR}).
|
||||
* Make sure the given {@linkcode format} supports HDR (see {@linkcode CameraDeviceFormat.supportsVideoHdr format.supportsVideoHdr}).
|
||||
*/
|
||||
hdr?: boolean
|
||||
videoHdr?: boolean
|
||||
/**
|
||||
* Enables or disables HDR Photo Capture via a double capture routine that combines low- and high exposure photos.
|
||||
*
|
||||
* Make sure the given {@linkcode format} supports HDR (see {@linkcode CameraDeviceFormat.supportsPhotoHdr format.supportsPhotoHdr}).
|
||||
*/
|
||||
photoHdr?: boolean
|
||||
/**
|
||||
* Enables or disables lossless buffer compression for the video stream.
|
||||
* If you only use {@linkcode video} or a {@linkcode frameProcessor}, this
|
||||
|
@@ -63,11 +63,11 @@ export interface FormatFilter {
|
||||
/**
|
||||
* Whether you want to find a format that supports Photo HDR.
|
||||
*/
|
||||
photoHDR?: boolean
|
||||
photoHdr?: boolean
|
||||
/**
|
||||
* Whether you want to find a format that supports Photo HDR.
|
||||
*/
|
||||
videoHDR?: boolean
|
||||
videoHdr?: boolean
|
||||
}
|
||||
|
||||
type FilterWithPriority<T> = {
|
||||
@@ -198,15 +198,15 @@ export function getCameraFormat(device: CameraDevice, filters: FormatFilter[]):
|
||||
}
|
||||
|
||||
// Find Photo HDR formats
|
||||
if (filter.photoHDR != null) {
|
||||
if (bestFormat.supportsPhotoHDR === filter.photoHDR.target) leftPoints++
|
||||
if (format.supportsPhotoHDR === filter.photoHDR.target) rightPoints++
|
||||
if (filter.photoHdr != null) {
|
||||
if (bestFormat.supportsPhotoHdr === filter.photoHdr.target) leftPoints++
|
||||
if (format.supportsPhotoHdr === filter.photoHdr.target) rightPoints++
|
||||
}
|
||||
|
||||
// Find Video HDR formats
|
||||
if (filter.videoHDR != null) {
|
||||
if (bestFormat.supportsVideoHDR === filter.videoHDR.target) leftPoints++
|
||||
if (format.supportsVideoHDR === filter.videoHDR.target) rightPoints++
|
||||
if (filter.videoHdr != null) {
|
||||
if (bestFormat.supportsVideoHdr === filter.videoHdr.target) leftPoints++
|
||||
if (format.supportsVideoHdr === filter.videoHdr.target) rightPoints++
|
||||
}
|
||||
|
||||
if (rightPoints > leftPoints) bestFormat = format
|
||||
|
Reference in New Issue
Block a user