Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix compiler issue in Mp4BoxParsers #6312

Merged
merged 1 commit into from
Feb 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
37 changes: 24 additions & 13 deletions lib/util/mp4_box_parsers.js
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ shaka.util.Mp4BoxParsers = class {
}
}
if (oti) {
codec += '.' + this.toHex_(oti);
codec += '.' + shaka.util.Mp4BoxParsers.toHex_(oti);
if (tag == 0x05 && reader.hasMoreData()) {
const firstData = reader.readUint8();
let audioObjectType = (firstData & 0xF8) >> 3;
Expand All @@ -351,9 +351,12 @@ shaka.util.Mp4BoxParsers = class {
* @return {!shaka.util.ParsedAVCCBox}
*/
static parseAVCC(codecBase, reader, boxName) {
const Mp4BoxParsers = shaka.util.Mp4BoxParsers;
reader.skip(1); // Skip "configurationVersion"
const codec = codecBase + '.' + this.toHex_(reader.readUint8()) +
this.toHex_(reader.readUint8()) + this.toHex_(reader.readUint8());
const codec = codecBase + '.' +
Mp4BoxParsers.toHex_(reader.readUint8()) +
Mp4BoxParsers.toHex_(reader.readUint8()) +
Mp4BoxParsers.toHex_(reader.readUint8());
return {codec};
}

Expand All @@ -365,6 +368,7 @@ shaka.util.Mp4BoxParsers = class {
* @return {!shaka.util.ParsedHVCCBox}
*/
static parseHVCC(codecBase, reader, boxName) {
const Mp4BoxParsers = shaka.util.Mp4BoxParsers;
reader.skip(1); // Skip "configurationVersion"
const profileByte = reader.readUint8();
const profileSpace = ['', 'A', 'B', 'C'][profileByte >> 6];
Expand All @@ -382,8 +386,9 @@ shaka.util.Mp4BoxParsers = class {
const levelIDC = reader.readUint8();
let codec = codecBase;
codec += '.' + profileSpace + generalProfileIdc;
codec += '.' + this.toHex_(
this.reverseBits_(profileCompat), /* removeInitialZero= */ true);
codec += '.' + Mp4BoxParsers.toHex_(
Mp4BoxParsers.reverseBits_(profileCompat),
/* removeInitialZero= */ true);
codec += '.' + tierFlag + levelIDC;
let constraintString = '';
for (let i = constraintIndicator.length; i--; ) {
Expand All @@ -406,13 +411,15 @@ shaka.util.Mp4BoxParsers = class {
* @return {!shaka.util.ParsedDVCCBox}
*/
static parseDVCC(codecBase, reader, boxName) {
const Mp4BoxParsers = shaka.util.Mp4BoxParsers;
reader.skip(2); // Skip "dv_version_major" and "dv_version_minor"
const thirdByte = reader.readUint8();
const fourthByte = reader.readUint8();
const profile = (thirdByte >> 1) & 0x7f;
const level = ((thirdByte << 5) & 0x20) | ((fourthByte >> 3) & 0x1f);
const codec = codecBase + '.' +
this.addLeadingZero_(profile) + '.' + this.addLeadingZero_(level);
Mp4BoxParsers.addLeadingZero_(profile) + '.' +
Mp4BoxParsers.addLeadingZero_(level);

return {codec};
}
Expand All @@ -425,11 +432,14 @@ shaka.util.Mp4BoxParsers = class {
* @return {!shaka.util.ParsedVPCCBox}
*/
static parseVPCC(codecBase, reader, boxName) {
const Mp4BoxParsers = shaka.util.Mp4BoxParsers;
const profile = reader.readUint8();
const level = reader.readUint8();
const bitDepth = (reader.readUint8() >> 4) & 0x0f;
const codec = codecBase + '.' + this.addLeadingZero_(profile) +
'.' + this.addLeadingZero_(level) + '.' + this.addLeadingZero_(bitDepth);
const codec = codecBase + '.' +
Mp4BoxParsers.addLeadingZero_(profile) + '.' +
Mp4BoxParsers.addLeadingZero_(level) + '.' +
Mp4BoxParsers.addLeadingZero_(bitDepth);

return {codec};
}
Expand All @@ -442,6 +452,7 @@ shaka.util.Mp4BoxParsers = class {
* @return {!shaka.util.ParsedAV1CBox}
*/
static parseAV1C(codecBase, reader, boxName) {
const Mp4BoxParsers = shaka.util.Mp4BoxParsers;
// More info https://aomediacodec.github.io/av1-isobmff/#av1codecconfigurationbox-syntax
reader.skip(1); // Skip "marker" and "version"
const secondByte = reader.readUint8();
Expand All @@ -464,13 +475,13 @@ shaka.util.Mp4BoxParsers = class {
const matrixCoefficients = 1;
const videoFullRangeFlag = 0;
const codec = codecBase + '.' + profile +
'.' + this.addLeadingZero_(level) + tierFlag +
'.' + this.addLeadingZero_(bitDepth) +
'.' + Mp4BoxParsers.addLeadingZero_(level) + tierFlag +
'.' + Mp4BoxParsers.addLeadingZero_(bitDepth) +
'.' + monochrome +
'.' + chromaSubsamplingX + chromaSubsamplingY + chromaSamplePosition +
'.' + this.addLeadingZero_(colorPrimaries) +
'.' + this.addLeadingZero_(transferCharacteristics) +
'.' + this.addLeadingZero_(matrixCoefficients) +
'.' + Mp4BoxParsers.addLeadingZero_(colorPrimaries) +
'.' + Mp4BoxParsers.addLeadingZero_(transferCharacteristics) +
'.' + Mp4BoxParsers.addLeadingZero_(matrixCoefficients) +
'.' + videoFullRangeFlag;

return {codec};
Expand Down