mirror of
https://github.com/arcodange-org/mediabunny.git
synced 2026-10-01 04:43:51 +02:00
Make VP9 and AV1 codec strings much more detailed
This commit is contained in:
@@ -601,18 +601,25 @@ export const vpcC = (trackData: IsobmffVideoTrackData) => {
|
||||
const level = Number(parts[2]);
|
||||
|
||||
const bitDepth = Number(parts[3]);
|
||||
const chromaSubsampling = 0;
|
||||
const thirdByte = (bitDepth << 4) + (chromaSubsampling << 1) + Number(decoderConfig.colorSpace.fullRange);
|
||||
const chromaSubsampling = parts[4] ? Number(parts[4]) : 1; // 4:2:0 colocated with luma (0,0)
|
||||
const videoFullRangeFlag = parts[8] ? Number(parts[8]) : Number(decoderConfig.colorSpace.fullRange);
|
||||
const thirdByte = (bitDepth << 4) + (chromaSubsampling << 1) + videoFullRangeFlag;
|
||||
|
||||
const colourPrimaries = decoderConfig.colorSpace.primaries
|
||||
? COLOR_PRIMARIES_MAP[decoderConfig.colorSpace.primaries]
|
||||
: 2; // Default to undetermined
|
||||
const transferCharacteristics = decoderConfig.colorSpace.transfer
|
||||
? TRANSFER_CHARACTERISTICS_MAP[decoderConfig.colorSpace.transfer]
|
||||
: 2;
|
||||
const matrixCoefficients = decoderConfig.colorSpace.matrix
|
||||
? MATRIX_COEFFICIENTS_MAP[decoderConfig.colorSpace.matrix]
|
||||
: 2;
|
||||
const colourPrimaries = parts[5]
|
||||
? Number(parts[5])
|
||||
: decoderConfig.colorSpace.primaries
|
||||
? COLOR_PRIMARIES_MAP[decoderConfig.colorSpace.primaries]
|
||||
: 2; // Default to undetermined
|
||||
const transferCharacteristics = parts[6]
|
||||
? Number(parts[6])
|
||||
: decoderConfig.colorSpace.transfer
|
||||
? TRANSFER_CHARACTERISTICS_MAP[decoderConfig.colorSpace.transfer]
|
||||
: 2;
|
||||
const matrixCoefficients = parts[7]
|
||||
? Number(parts[7])
|
||||
: decoderConfig.colorSpace.matrix
|
||||
? MATRIX_COEFFICIENTS_MAP[decoderConfig.colorSpace.matrix]
|
||||
: 2;
|
||||
|
||||
return fullBox('vpcC', 1, 0, [
|
||||
u8(profile), // Profile
|
||||
|
||||
@@ -728,11 +728,22 @@ export class IsobmffDemuxer extends Demuxer {
|
||||
const profile = this.isobmffReader.readU8();
|
||||
const level = this.isobmffReader.readU8();
|
||||
const thirdByte = this.isobmffReader.readU8();
|
||||
const bitDepth = thirdByte >> 4;
|
||||
const chromaSubsampling = (thirdByte >> 1) & 0b111;
|
||||
const videoFullRangeFlag = thirdByte & 1;
|
||||
const colourPrimaries = this.isobmffReader.readU8();
|
||||
const transferCharacteristics = this.isobmffReader.readU8();
|
||||
const matrixCoefficients = this.isobmffReader.readU8();
|
||||
|
||||
track.info.vp9CodecInfo = {
|
||||
profile: profile,
|
||||
level: level,
|
||||
bitDepth: thirdByte >> 4,
|
||||
profile,
|
||||
level,
|
||||
bitDepth,
|
||||
chromaSubsampling,
|
||||
videoFullRangeFlag,
|
||||
colourPrimaries,
|
||||
transferCharacteristics,
|
||||
matrixCoefficients,
|
||||
};
|
||||
}; break;
|
||||
|
||||
@@ -743,22 +754,30 @@ export class IsobmffDemuxer extends Demuxer {
|
||||
this.isobmffReader.pos += 1; // Marker + version
|
||||
|
||||
const secondByte = this.isobmffReader.readU8();
|
||||
const seqProfile = secondByte >> 5;
|
||||
const seqLevelIdx0 = secondByte & 0b11111;
|
||||
const profile = secondByte >> 5;
|
||||
const level = secondByte & 0b11111;
|
||||
|
||||
const thirdByte = this.isobmffReader.readU8();
|
||||
const seqTier0 = thirdByte >> 7;
|
||||
const tier = thirdByte >> 7;
|
||||
const highBitDepth = (thirdByte >> 6) & 1;
|
||||
const twelveBit = (thirdByte >> 5) & 1;
|
||||
const monochrome = (thirdByte >> 4) & 1;
|
||||
const chromaSubsamplingX = (thirdByte >> 3) & 1;
|
||||
const chromaSubsamplingY = (thirdByte >> 2) & 1;
|
||||
const chromaSamplePosition = thirdByte & 0b11;
|
||||
|
||||
// Logic from https://aomediacodec.github.io/av1-spec/av1-spec.pdf
|
||||
const bitDepth = seqProfile == 2 && highBitDepth ? (twelveBit ? 12 : 10) : (highBitDepth ? 10 : 8);
|
||||
const bitDepth = profile == 2 && highBitDepth ? (twelveBit ? 12 : 10) : (highBitDepth ? 10 : 8);
|
||||
|
||||
track.info.av1CodecInfo = {
|
||||
seqProfile,
|
||||
seqLevelIdx0,
|
||||
seqTier0,
|
||||
profile,
|
||||
level,
|
||||
tier,
|
||||
bitDepth,
|
||||
monochrome,
|
||||
chromaSubsamplingX,
|
||||
chromaSubsamplingY,
|
||||
chromaSamplePosition,
|
||||
};
|
||||
}; break;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user