| 1477 | const AV1_DEFAULT_SUFFIX = '.0.110.01.01.01.0'; |
| 1478 | |
| 1479 | export const generateAv1CodecString = (codecInfo: Av1CodecInfo) => { |
| 1480 | // https://aomediacodec.github.io/av1-isobmff/#codecsparam |
| 1481 | const profile = codecInfo.profile; // Single digit |
| 1482 | const level = codecInfo.level.toString().padStart(2, '0'); |
| 1483 | const tier = codecInfo.tier ? 'H' : 'M'; |
| 1484 | const bitDepth = codecInfo.bitDepth.toString().padStart(2, '0'); |
| 1485 | const monochrome = codecInfo.monochrome ? '1' : '0'; |
| 1486 | const chromaSubsampling = 100 * codecInfo.chromaSubsamplingX |
| 1487 | + 10 * codecInfo.chromaSubsamplingY |
| 1488 | + 1 * ( |
| 1489 | codecInfo.chromaSubsamplingX && codecInfo.chromaSubsamplingY |
| 1490 | ? codecInfo.chromaSamplePosition |
| 1491 | : 0 |
| 1492 | ); |
| 1493 | |
| 1494 | // The defaults are 1 (ITU-R BT.709) |
| 1495 | const colorPrimaries = 1; |
| 1496 | const transferCharacteristics = 1; |
| 1497 | const matrixCoefficients = 1; |
| 1498 | |
| 1499 | const videoFullRangeFlag = 0; |
| 1500 | |
| 1501 | let string = `av01.${profile}.${level}${tier}.${bitDepth}`; |
| 1502 | string += `.${monochrome}.${chromaSubsampling.toString().padStart(3, '0')}`; |
| 1503 | string += `.${colorPrimaries.toString().padStart(2, '0')}`; |
| 1504 | string += `.${transferCharacteristics.toString().padStart(2, '0')}`; |
| 1505 | string += `.${matrixCoefficients.toString().padStart(2, '0')}`; |
| 1506 | string += `.${videoFullRangeFlag}`; |
| 1507 | |
| 1508 | if (string.endsWith(AV1_DEFAULT_SUFFIX)) { |
| 1509 | string = string.slice(0, -AV1_DEFAULT_SUFFIX.length); |
| 1510 | } |
| 1511 | |
| 1512 | return string; |
| 1513 | }; |
| 1514 | |
| 1515 | export type AacAudioSpecificConfig = { |
| 1516 | objectType: number; |