Skip to content

Commit

Permalink
fix: Prefer Dolby Vision p5 over Dolby Vision p8 (#7745)
Browse files Browse the repository at this point in the history
  • Loading branch information
avelad authored Dec 11, 2024
1 parent eff0aef commit 60429e9
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 5 deletions.
3 changes: 3 additions & 0 deletions lib/util/mime_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,9 @@ shaka.util.MimeUtils = class {
return 'vvc'; // H266
case base === 'dvh1':
case base === 'dvhe':
if (profile && profile.startsWith('05')) {
return 'dovi-p5'; // Dolby Vision profile 5
}
return 'dovi-hevc'; // Dolby Vision based in HEVC
case base === 'dvav':
case base === 'dva1':
Expand Down
7 changes: 4 additions & 3 deletions lib/util/stream_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,10 @@ shaka.util.StreamUtils = class {
'vp09': 0.9,
'hevc': 0.85,
'dovi-hevc': 0.8,
'av01': 0.75,
'dovi-av1': 0.7,
'vvc': 0.65,
'dovi-p5': 0.75,
'av01': 0.7,
'dovi-av1': 0.65,
'vvc': 0.6,
};

const videoStreams = Array.from(videoStreamsSet)
Expand Down
7 changes: 5 additions & 2 deletions test/util/mime_utils_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,11 @@ describe('MimeUtils', () => {
expect(getNormalizedCodec('vvc1')).toBe('vvc');
expect(getNormalizedCodec('vvi1')).toBe('vvc');

expect(getNormalizedCodec('dvh1.05')).toBe('dovi-hevc');
expect(getNormalizedCodec('dvhe.05')).toBe('dovi-hevc');
expect(getNormalizedCodec('dvh1.05')).toBe('dovi-p5');
expect(getNormalizedCodec('dvhe.05')).toBe('dovi-p5');

expect(getNormalizedCodec('dvh1.08')).toBe('dovi-hevc');
expect(getNormalizedCodec('dvhe.08')).toBe('dovi-hevc');

expect(getNormalizedCodec('dva1.05')).toBe('dovi-avc');
expect(getNormalizedCodec('dvav.05')).toBe('dovi-avc');
Expand Down
39 changes: 39 additions & 0 deletions test/util/stream_utils_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -1084,6 +1084,45 @@ describe('StreamUtils', () => {
expect(manifest.variants[0].video.codecs).toBe('dav1.10.01');
});

it('prefer Dolby Vision p5 over Dolby Vision p8', async () => {
// Dolby Vision profile 5 has a proprietary color space that produces a
// better image than Dolby Vision profile 8 which must be backward
// compatible with HEVC.
manifest = shaka.test.ManifestGenerator.generate((manifest) => {
manifest.addVariant(1, (variant) => {
variant.addVideo(2, (stream) => {
stream.bandwidth = 4000000;
stream.size(1920, 1080);
stream.mime('video/mp4', 'dvh1.08.06');
});
});
manifest.addVariant(2, (variant) => {
variant.addVideo(3, (stream) => {
stream.bandwidth = 4000000;
stream.size(1920, 1080);
stream.mime('video/mp4', 'dvh1.05.06');
});
});
});
navigator.mediaCapabilities.decodingInfo =
shaka.test.Util.spyFunc(decodingInfoSpy);
decodingInfoSpy.and.callFake((config) => {
return Promise.resolve({supported: true, smooth: true});
});

await StreamUtils.getDecodingInfosForVariants(manifest.variants,
/* usePersistentLicenses= */false, /* srcEquals= */ false,
/* preferredKeySystems= */ []);

shaka.util.StreamUtils.chooseCodecsAndFilterManifest(manifest,
/* preferredVideoCodecs= */[],
/* preferredAudioCodecs= */[],
/* preferredDecodingAttributes= */[],
/* preferredTextFormats= */ []);
expect(manifest.variants.length).toBe(1);
expect(manifest.variants[0].video.codecs).toBe('dvh1.05.06');
});

it('chooses variants by decoding attributes', async () => {
manifest = shaka.test.ManifestGenerator.generate((manifest) => {
manifest.addVariant(0, (variant) => {
Expand Down

0 comments on commit 60429e9

Please sign in to comment.