From 183886f7d3ed4c92bcc12811f58e8f13f34613a1 Mon Sep 17 00:00:00 2001 From: cconcolato Date: Thu, 17 May 2018 09:22:56 -0700 Subject: [PATCH] improve vpcC parsing --- src/box.js | 2 +- src/parsing/vpcC.js | 37 ++++++++++++++++++++++++++----------- 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/src/box.js b/src/box.js index 882f1949..e64fef44 100644 --- a/src/box.js +++ b/src/box.js @@ -9,7 +9,7 @@ var BoxParser = { // Boxes to be created with default parsing BASIC_BOXES: [ "mdat", "idat", "free", "skip", "meco", "strk" ], - FULL_BOXES: [ "hmhd", "nmhd", "iods", "xml ", "bxml", "ipro", "mere", "vpcC" ], + FULL_BOXES: [ "hmhd", "nmhd", "iods", "xml ", "bxml", "ipro", "mere" ], CONTAINER_BOXES: [ [ "moov", [ "trak", "pssh" ] ], [ "trak" ], diff --git a/src/parsing/vpcC.js b/src/parsing/vpcC.js index 22bfbfa9..ba9c5085 100644 --- a/src/parsing/vpcC.js +++ b/src/parsing/vpcC.js @@ -1,13 +1,28 @@ BoxParser.createFullBoxCtor("vpcC", function (stream) { - this.profile = stream.readUint8(); - this.level = stream.readUint8(); - var tmp = stream.readUint8(); - this.bitDepth = (tmp >> 4) & 0xF; - this.colorSpace = tmp & 0xF; - tmp = stream.readUint8(); - this.chromaSubsampling = (tmp >> 4) & 0xF; - this.transferFunction = (tmp >> 1) & 0x7; - this.videoFullRangeFlag = tmp & 0x1; - var codecIntializationDataSize = stream.readUint16(); - this.codecIntializationData = stream.readUint8Array(codecIntializationDataSize); + var tmp; + if (this.version === 1) { + this.profile = stream.readUint8(); + this.level = stream.readUint8(); + tmp = stream.readUint8(); + this.bitDepth = tmp >> 4; + this.chromaSubsampling = (tmp >> 1) & 0x7; + this.videoFullRangeFlag = tmp & 0x1; + this.colourPrimaries = stream.readUint8(); + this.transferCharacteristics = stream.readUint8(); + this.matrixCoefficients = stream.readUint8(); + this.codecIntializationDataSize = stream.readUint16(); + this.codecIntializationData = stream.readUint8Array(this.codecIntializationDataSize); + } else { + this.profile = stream.readUint8(); + this.level = stream.readUint8(); + tmp = stream.readUint8(); + this.bitDepth = (tmp >> 4) & 0xF; + this.colorSpace = tmp & 0xF; + tmp = stream.readUint8(); + this.chromaSubsampling = (tmp >> 4) & 0xF; + this.transferFunction = (tmp >> 1) & 0x7; + this.videoFullRangeFlag = tmp & 0x1; + this.codecIntializationDataSize = stream.readUint16(); + this.codecIntializationData = stream.readUint8Array(this.codecIntializationDataSize); + } }); \ No newline at end of file