Skip to content

Commit

Permalink
fix: Fix support for Dolby Vision based in VVC (#7212)
Browse files Browse the repository at this point in the history
  • Loading branch information
avelad authored Aug 26, 2024
1 parent 2d2bddd commit cdbbe23
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 7 deletions.
15 changes: 10 additions & 5 deletions lib/cea/mp4_cea_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,16 @@ shaka.cea.Mp4CeaParser = class {
// These are the various boxes that signal a codec.
.box('avc1', codecBoxParser)
.box('avc3', codecBoxParser)
.box('hev1', codecBoxParser)
.box('hvc1', codecBoxParser)
.box('dvav', codecBoxParser)
.box('dva1', codecBoxParser)
.box('hev1', codecBoxParser)
.box('hvc1', codecBoxParser)
.box('dvh1', codecBoxParser)
.box('dvhe', codecBoxParser)
.box('vvc1', codecBoxParser)
.box('vvi1', codecBoxParser)
.box('dvc1', codecBoxParser)
.box('dvi1', codecBoxParser)

// This signals an encrypted sample, which we can go inside of to find
// the codec used.
Expand Down Expand Up @@ -406,18 +408,21 @@ shaka.cea.Mp4CeaParser.CodecBitstreamMap_ = {
// AVC
'avc1': shaka.cea.Mp4CeaParser.BitstreamFormat.H264,
'avc3': shaka.cea.Mp4CeaParser.BitstreamFormat.H264,
// HEVC
'hev1': shaka.cea.Mp4CeaParser.BitstreamFormat.H265,
'hvc1': shaka.cea.Mp4CeaParser.BitstreamFormat.H265,
// Dolby Vision based in AVC
'dvav': shaka.cea.Mp4CeaParser.BitstreamFormat.H264,
'dva1': shaka.cea.Mp4CeaParser.BitstreamFormat.H264,
// HEVC
'hev1': shaka.cea.Mp4CeaParser.BitstreamFormat.H265,
'hvc1': shaka.cea.Mp4CeaParser.BitstreamFormat.H265,
// Dolby Vision based in HEVC
'dvh1': shaka.cea.Mp4CeaParser.BitstreamFormat.H265,
'dvhe': shaka.cea.Mp4CeaParser.BitstreamFormat.H265,
// VVC
'vvc1': shaka.cea.Mp4CeaParser.BitstreamFormat.H266,
'vvi1': shaka.cea.Mp4CeaParser.BitstreamFormat.H266,
// Dolby Vision based in VVC
'dvc1': shaka.cea.Mp4CeaParser.BitstreamFormat.H266,
'dvi1': shaka.cea.Mp4CeaParser.BitstreamFormat.H266,
};

/**
Expand Down
12 changes: 12 additions & 0 deletions lib/media/content_workarounds.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,18 @@ shaka.media.ContentWorkarounds = class {
newType: ContentWorkarounds.BOX_TYPE_ENCV_,
});
})
.fullBox('dvc1', (box) => {
boxesToModify.push({
box,
newType: ContentWorkarounds.BOX_TYPE_ENCV_,
});
})
.fullBox('dvi1', (box) => {
boxesToModify.push({
box,
newType: ContentWorkarounds.BOX_TYPE_ENCV_,
});
})
.fullBox('hev1', (box) => {
boxesToModify.push({
box,
Expand Down
8 changes: 6 additions & 2 deletions lib/media/segment_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -498,9 +498,13 @@ shaka.media.SegmentUtils = class {
return codecs;
}
const dolbyVision = codecs.find((codec) => {
return codec.startsWith('dvh1.') ||
return codec.startsWith('dvav.') ||
codec.startsWith('dva1.') ||
codec.startsWith('dvh1.') ||
codec.startsWith('dvhe.') ||
codec.startsWith('dav1.');
codec.startsWith('dav1.') ||
codec.startsWith('dvc1.') ||
codec.startsWith('dvi1.');
});
if (!dolbyVision) {
return codecs;
Expand Down
2 changes: 2 additions & 0 deletions lib/media/streaming_engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -2029,6 +2029,8 @@ shaka.media.StreamingEngine = class {
.box('dva1', Mp4Parser.visualSampleEntry)
.box('dvh1', Mp4Parser.visualSampleEntry)
.box('dvhe', Mp4Parser.visualSampleEntry)
.box('dvc1', Mp4Parser.visualSampleEntry)
.box('dvi1', Mp4Parser.visualSampleEntry)
.box('vexu', Mp4Parser.children)
.box('proj', Mp4Parser.children)
.fullBox('prji', (box) => {
Expand Down
3 changes: 3 additions & 0 deletions lib/util/mime_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,9 @@ shaka.util.MimeUtils = class {
return 'dovi-avc'; // Dolby Vision based in AVC
case base === 'dav1':
return 'dovi-av1'; // Dolby Vision based in AV1
case base === 'dvc1':
case base === 'dvi1':
return 'dovi-vvc'; // Dolby Vision based in VVC
}
return base;
}
Expand Down
2 changes: 2 additions & 0 deletions lib/util/stream_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,8 @@ shaka.util.StreamUtils = class {
'dva1': 'avc1',
'dvhe': 'hev1',
'dvh1': 'hvc1',
'dvc1': 'vvc1',
'dvi1': 'vvi1',
};
/** @type {!Set<!shaka.extern.Stream>} */
const streams = new Set();
Expand Down
3 changes: 3 additions & 0 deletions test/util/mime_utils_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ describe('MimeUtils', () => {
expect(getNormalizedCodec('dvav.05')).toBe('dovi-avc');

expect(getNormalizedCodec('dav1.05')).toBe('dovi-av1');

expect(getNormalizedCodec('dvc1.05')).toBe('dovi-vvc');
expect(getNormalizedCodec('dvi1.05')).toBe('dovi-vvc');
});

it('isHlsType', () => {
Expand Down

0 comments on commit cdbbe23

Please sign in to comment.