Skip to content

Commit 347b218

Browse files
committed
add HDR Vivid
1 parent a80d367 commit 347b218

File tree

8 files changed

+2527
-2458
lines changed

8 files changed

+2527
-2458
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ supports
1414
* AVS3 video and audio
1515
* AVS2 audio
1616
* LCEVC - refer to ISO/IEC 14496-15:2022 Amd.1
17+
* HDR Vivid - refer to T/UWA 005-2.1
1718

1819
## Installation
1920

package-lock.json

Lines changed: 2447 additions & 2457 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "codec-string",
3-
"version": "0.1.3",
3+
"version": "0.1.4",
44
"description": "decode the codecs= string in a media mime type",
55
"type": "module",
66
"engines": {

src/decode-uwa.js

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/**
2+
* @copyright: Copyright (c) 2024
3+
* @author: Paul Higgs
4+
* @file: decode-uwa.js
5+
*
6+
* Redistribution and use in source and binary forms, with or without
7+
* modification, are permitted provided that the following conditions are met:
8+
*
9+
* 1. Redistributions of source code must retain the above copyright notice,
10+
* this list of conditions and the following disclaimer.
11+
* 2. Redistributions in binary form must reproduce the above copyright
12+
* notice, this list of conditions and the following disclaimer in the
13+
* documentation and/or other materials provided with the distribution.
14+
*
15+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
25+
* THE POSSIBILITY OF SUCH DAMAGE.
26+
*
27+
*/
28+
29+
// see clause 9.2 of T/UWA 005-2.1
30+
31+
const DEBUGGING = false;
32+
33+
import { warning, error, normal } from './decode.js';
34+
import { DVBclassification } from './dvb-mapping.js';
35+
import { simpleHTML } from './formatters.js';
36+
import { expressions } from './regular_expressions.js';
37+
38+
export function decodeUWA(val) {
39+
40+
if (!expressions.CUVV.regex.test(val))
41+
return [error('Regex mismatch!'), error(`${val.substring(0,4)}.${expressions.CUVV.format_suffix}`), error(expressions.CUVV.description)];
42+
43+
const parts = val.split('.');
44+
45+
// the following tests should not fail as the format is checked with the regular expression
46+
if (parts.length != 2) return [error('invalid format')];
47+
48+
const coding_params = { type: 'video', codec: parts[0] }, res = [];
49+
50+
for (let i=0; i<parts[1].length; i++) {
51+
if (parts[1][i] == '1') {
52+
res.push(normal(`HDR Vivid version ${parts[1].length-i} is present`));
53+
}
54+
}
55+
if (res.length == 0)
56+
res.push(warning('No HDR Vivid versions present'));
57+
58+
const dvb = DVBclassification(coding_params);
59+
if (dvb.length != 0) res.push({ dvb_term: dvb });
60+
61+
return res;
62+
}
63+
64+
const outputHTML = (label, messages) => simpleHTML(label, messages, DEBUGGING);
65+
66+
export function registerUWA(addHandler) {
67+
addHandler('cuvv', 'HDR Vivid', decodeUWA, outputHTML);
68+
}

src/handler.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { registerMisc } from './decode-misc.js';
1010
import { registerMPEG } from './decode-mpeg.js';
1111
import { registerMPEGH } from './decode-mpegH.js';
1212
import { registerText } from './decode-text.js';
13+
import { registerUWA } from './decode-uwa.js';
1314
import { registerVC1 } from './decode-vc1.js';
1415
import { registerVP9 } from './decode-vp9.js';
1516
import { registerVVC } from './decode-vvc.js';
@@ -51,6 +52,7 @@ const registerFactories = [
5152
registerMPEG,
5253
registerMPEGH,
5354
registerText,
55+
registerUWA,
5456
registerVC1,
5557
registerVP9,
5658
registerVVC,

src/index.cjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const { decodeLCEVC } = require('./decode-lcevc.js');
99
const { decodeMPEG2video, decodeMPEG2audio, decodeMPEG1video, decodeMPEG1audio, decodeMPEG4video, decodeMPEG4audio } = require('./decode-mpeg.js');
1010
const { decodeMPEGH } = require('./decode-mpegH.js');
1111
const { decodeSTPP } = require('./decode-text.js');
12+
const { decodeUWA } = require('./decode-uwa.js');
1213
const { decodeVP9 } = require('./decode-vp9.js');
1314
const { decodeVVC } = require('./decode-vvc.js');
1415
const { decode } = require('./decode.js');
@@ -35,6 +36,7 @@ module.exports = {
3536
decodeMPEG4audio,
3637
decodeMPEGH,
3738
decodeSTPP,
39+
decodeUWA,
3840
decodeVP9,
3941
decodeVVC,
4042
decode,

src/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export { decodeLCEVC } from './decode-lcevc.js';
99
export { decodeMPEG2video, decodeMPEG2audio, decodeMPEG1video, decodeMPEG1audio, decodeMPEG4video, decodeMPEG4audio } from './decode-mpeg.js';
1010
export { decodeMPEGH } from './decode-mpegH.js';
1111
export { decodeSTPP } from './decode-text.js';
12+
export { decodeUWA } from './decode-uwa.js';
1213
export { decodeVP9 } from './decode-vp9.js';
1314
export { decodeVVC } from './decode-vvc.js';
1415
export { decode } from './decode.js';

src/regular_expressions.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,5 +67,10 @@ export const expressions = {
6767
regex: /mhm(1|2)\.0x[a-fA-F\d]{2}/,
6868
format: '(mhm1 or mhm2).0xLL',
6969
description: 'LL is 2 hexadecimal digits'
70+
},
71+
CUVV: {
72+
regex: /cuvv.[01]+/,
73+
format: 'cuvv.<verison_bits>',
74+
description: '<version_bits> indicates the versions of HDR Vivid in the bitstream'
7075
}
7176
};

0 commit comments

Comments
 (0)