( colorSpaces: Array<VideoColorSpace | null>, )
| 118 | * contains HDR content and what the dominant transfer function is. |
| 119 | */ |
| 120 | export function analyzeCompositionHdr( |
| 121 | colorSpaces: Array<VideoColorSpace | null>, |
| 122 | ): CompositionHdrInfo { |
| 123 | let hasPq = false; |
| 124 | let hasHdr = false; |
| 125 | |
| 126 | for (const cs of colorSpaces) { |
| 127 | if (!isHdrColorSpace(cs)) continue; |
| 128 | hasHdr = true; |
| 129 | if (cs?.colorTransfer === "smpte2084") hasPq = true; |
| 130 | } |
| 131 | |
| 132 | if (!hasHdr) return { hasHdr: false, dominantTransfer: null }; |
| 133 | |
| 134 | // PQ takes priority — it's the more common HDR10 format |
| 135 | const dominantTransfer: HdrTransfer = hasPq ? "pq" : "hlg"; |
| 136 | return { hasHdr: true, dominantTransfer }; |
| 137 | } |
no test coverage detected