Skip to content

Commit

Permalink
improve vpcC parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
cconcolato committed May 17, 2018
1 parent 159bdce commit 183886f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/box.js
Original file line number Diff line number Diff line change
Expand Up @@ -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" ],
Expand Down
37 changes: 26 additions & 11 deletions src/parsing/vpcC.js
Original file line number Diff line number Diff line change
@@ -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);
}
});

0 comments on commit 183886f

Please sign in to comment.