open-ultrahdr-wasm 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/pkg/README.md +17 -0
- package/pkg/open_ultrahdr.d.ts +591 -0
- package/pkg/open_ultrahdr.js +1336 -0
- package/pkg/open_ultrahdr_bg.wasm +0 -0
- package/pkg/open_ultrahdr_bg.wasm.d.ts +98 -0
- package/pkg/package.json +31 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "open-ultrahdr-wasm",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "UltraHDR (ISO 21496-1) gain map WASM implementation",
|
|
5
5
|
"author": "Adam Silverstein",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"homepage": "https://github.com/adamsilverstein/lib-open-ultrahdr",
|
|
16
16
|
"repository": {
|
|
17
17
|
"type": "git",
|
|
18
|
-
"url": "https://github.com/adamsilverstein/lib-open-ultrahdr.git",
|
|
18
|
+
"url": "git+https://github.com/adamsilverstein/lib-open-ultrahdr.git",
|
|
19
19
|
"directory": "wasm"
|
|
20
20
|
},
|
|
21
21
|
"bugs": {
|
package/pkg/README.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Open UltraHDR WASM
|
|
2
|
+
|
|
3
|
+
WebAssembly module for UltraHDR (ISO 21496-1) gain map implementation.
|
|
4
|
+
|
|
5
|
+
This is the low-level WASM package. For most use cases, use the `open-ultrahdr` package instead, which provides a higher-level TypeScript API.
|
|
6
|
+
|
|
7
|
+
## Building
|
|
8
|
+
|
|
9
|
+
Requires Rust and wasm-pack:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm run build
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## License
|
|
16
|
+
|
|
17
|
+
GPL-2.0-or-later
|
|
@@ -0,0 +1,591 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Color gamut enumeration for HDR images.
|
|
6
|
+
*/
|
|
7
|
+
export enum ColorGamut {
|
|
8
|
+
/**
|
|
9
|
+
* Standard sRGB color space (BT.709 primaries)
|
|
10
|
+
*/
|
|
11
|
+
Srgb = 0,
|
|
12
|
+
/**
|
|
13
|
+
* Display P3 wide color gamut
|
|
14
|
+
*/
|
|
15
|
+
DisplayP3 = 1,
|
|
16
|
+
/**
|
|
17
|
+
* BT.2100/BT.2020 wide color gamut (HDR)
|
|
18
|
+
*/
|
|
19
|
+
Bt2100 = 2,
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* ISO 21496-1 Gain Map Metadata.
|
|
24
|
+
*
|
|
25
|
+
* This structure contains all the metadata required to interpret and apply
|
|
26
|
+
* a gain map according to the ISO 21496-1 specification.
|
|
27
|
+
*/
|
|
28
|
+
export class GainMapMetadata {
|
|
29
|
+
free(): void;
|
|
30
|
+
[Symbol.dispose](): void;
|
|
31
|
+
/**
|
|
32
|
+
* Creates metadata suitable for a typical SDR base with HDR gain map.
|
|
33
|
+
*/
|
|
34
|
+
static forSdrBase(hdr_capacity_max: number): GainMapMetadata;
|
|
35
|
+
/**
|
|
36
|
+
* Creates a new GainMapMetadata with default values.
|
|
37
|
+
*/
|
|
38
|
+
constructor();
|
|
39
|
+
/**
|
|
40
|
+
* Whether the base rendition is HDR (false = SDR base, true = HDR base)
|
|
41
|
+
*/
|
|
42
|
+
baseRenditionIsHdr: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Maximum gain value per channel (RGB), in log2 scale
|
|
45
|
+
*/
|
|
46
|
+
gainMapMax: Float32Array;
|
|
47
|
+
/**
|
|
48
|
+
* Minimum gain value per channel (RGB), in log2 scale
|
|
49
|
+
*/
|
|
50
|
+
gainMapMin: Float32Array;
|
|
51
|
+
/**
|
|
52
|
+
* Gamma correction per channel (RGB)
|
|
53
|
+
*/
|
|
54
|
+
gamma: Float32Array;
|
|
55
|
+
/**
|
|
56
|
+
* Maximum HDR capacity (log2 scale) for full HDR output
|
|
57
|
+
*/
|
|
58
|
+
hdrCapacityMax: number;
|
|
59
|
+
/**
|
|
60
|
+
* Minimum HDR capacity (log2 scale) where gain map starts to apply
|
|
61
|
+
*/
|
|
62
|
+
hdrCapacityMin: number;
|
|
63
|
+
/**
|
|
64
|
+
* HDR offset per channel (RGB), used for black point adjustment
|
|
65
|
+
*/
|
|
66
|
+
offsetHdr: Float32Array;
|
|
67
|
+
/**
|
|
68
|
+
* SDR offset per channel (RGB), used for black point adjustment
|
|
69
|
+
*/
|
|
70
|
+
offsetSdr: Float32Array;
|
|
71
|
+
/**
|
|
72
|
+
* Specification version (e.g., "1.0")
|
|
73
|
+
*/
|
|
74
|
+
version: string;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Transfer function for encoding luminance.
|
|
79
|
+
*/
|
|
80
|
+
export enum TransferFunction {
|
|
81
|
+
/**
|
|
82
|
+
* sRGB transfer function (gamma ~2.2)
|
|
83
|
+
*/
|
|
84
|
+
Srgb = 0,
|
|
85
|
+
/**
|
|
86
|
+
* Linear (no gamma)
|
|
87
|
+
*/
|
|
88
|
+
Linear = 1,
|
|
89
|
+
/**
|
|
90
|
+
* Perceptual Quantizer (PQ) - SMPTE ST 2084
|
|
91
|
+
*/
|
|
92
|
+
Pq = 2,
|
|
93
|
+
/**
|
|
94
|
+
* Hybrid Log-Gamma (HLG) - BT.2100
|
|
95
|
+
*/
|
|
96
|
+
Hlg = 3,
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Result of decoding an UltraHDR image.
|
|
101
|
+
*/
|
|
102
|
+
export class UltraHdrDecodeResult {
|
|
103
|
+
free(): void;
|
|
104
|
+
[Symbol.dispose](): void;
|
|
105
|
+
/**
|
|
106
|
+
* Creates a new decode result.
|
|
107
|
+
*/
|
|
108
|
+
constructor(sdr_image: Uint8Array, gain_map: Uint8Array, metadata: GainMapMetadata, width: number, height: number, gain_map_width: number, gain_map_height: number);
|
|
109
|
+
/**
|
|
110
|
+
* Gain map height in pixels (may differ from image height)
|
|
111
|
+
*/
|
|
112
|
+
gainMapHeight: number;
|
|
113
|
+
/**
|
|
114
|
+
* Gain map width in pixels (may differ from image width)
|
|
115
|
+
*/
|
|
116
|
+
gainMapWidth: number;
|
|
117
|
+
/**
|
|
118
|
+
* The gain map as grayscale JPEG bytes
|
|
119
|
+
*/
|
|
120
|
+
gainMap: Uint8Array;
|
|
121
|
+
/**
|
|
122
|
+
* Image height in pixels
|
|
123
|
+
*/
|
|
124
|
+
height: number;
|
|
125
|
+
/**
|
|
126
|
+
* Gain map metadata
|
|
127
|
+
*/
|
|
128
|
+
metadata: GainMapMetadata;
|
|
129
|
+
/**
|
|
130
|
+
* The SDR base image as JPEG bytes
|
|
131
|
+
*/
|
|
132
|
+
sdrImage: Uint8Array;
|
|
133
|
+
/**
|
|
134
|
+
* Image width in pixels
|
|
135
|
+
*/
|
|
136
|
+
width: number;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Options for encoding UltraHDR images.
|
|
141
|
+
*/
|
|
142
|
+
export class UltraHdrEncodeOptions {
|
|
143
|
+
free(): void;
|
|
144
|
+
[Symbol.dispose](): void;
|
|
145
|
+
/**
|
|
146
|
+
* Creates options optimized for high quality output.
|
|
147
|
+
*/
|
|
148
|
+
static highQuality(): UltraHdrEncodeOptions;
|
|
149
|
+
/**
|
|
150
|
+
* Creates encoding options with default values.
|
|
151
|
+
*/
|
|
152
|
+
constructor();
|
|
153
|
+
/**
|
|
154
|
+
* Creates options optimized for smaller file size.
|
|
155
|
+
*/
|
|
156
|
+
static smallSize(): UltraHdrEncodeOptions;
|
|
157
|
+
/**
|
|
158
|
+
* JPEG quality for the base image (1-100)
|
|
159
|
+
*/
|
|
160
|
+
baseQuality: number;
|
|
161
|
+
/**
|
|
162
|
+
* JPEG quality for the gain map (1-100)
|
|
163
|
+
*/
|
|
164
|
+
gainMapQuality: number;
|
|
165
|
+
/**
|
|
166
|
+
* Downscale factor for the gain map (1 = same size, 2 = half, 4 = quarter)
|
|
167
|
+
*/
|
|
168
|
+
gainMapScale: number;
|
|
169
|
+
/**
|
|
170
|
+
* Whether to include ISO 21496-1 metadata
|
|
171
|
+
*/
|
|
172
|
+
includeIsoMetadata: boolean;
|
|
173
|
+
/**
|
|
174
|
+
* Whether to include UltraHDR v1 metadata for Android compatibility
|
|
175
|
+
*/
|
|
176
|
+
includeUltrahdrV1: boolean;
|
|
177
|
+
/**
|
|
178
|
+
* Target HDR capacity (typically 2.0-4.0)
|
|
179
|
+
*/
|
|
180
|
+
targetHdrCapacity: number;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Result of probing an image to check if it's UltraHDR.
|
|
185
|
+
*
|
|
186
|
+
* This provides detailed information about what components were found
|
|
187
|
+
* without fully decoding the image. Useful for batch processing and filtering.
|
|
188
|
+
*/
|
|
189
|
+
export class UltraHdrProbeResult {
|
|
190
|
+
free(): void;
|
|
191
|
+
[Symbol.dispose](): void;
|
|
192
|
+
/**
|
|
193
|
+
* Creates a new probe result with default (invalid) values.
|
|
194
|
+
*/
|
|
195
|
+
constructor();
|
|
196
|
+
/**
|
|
197
|
+
* Gain map height in pixels (0 if not found)
|
|
198
|
+
*/
|
|
199
|
+
gainMapHeight: number;
|
|
200
|
+
/**
|
|
201
|
+
* Gain map width in pixels (0 if not found)
|
|
202
|
+
*/
|
|
203
|
+
gainMapWidth: number;
|
|
204
|
+
/**
|
|
205
|
+
* Whether a gain map image was found
|
|
206
|
+
*/
|
|
207
|
+
hasGainMap: boolean;
|
|
208
|
+
/**
|
|
209
|
+
* Whether gain map metadata (XMP) was found
|
|
210
|
+
*/
|
|
211
|
+
hasMetadata: boolean;
|
|
212
|
+
/**
|
|
213
|
+
* Whether a primary JPEG image was found
|
|
214
|
+
*/
|
|
215
|
+
hasPrimaryImage: boolean;
|
|
216
|
+
/**
|
|
217
|
+
* HDR capacity (max additional stops of dynamic range), 0 if not found
|
|
218
|
+
*/
|
|
219
|
+
hdrCapacity: number;
|
|
220
|
+
/**
|
|
221
|
+
* Primary image height in pixels (0 if not found)
|
|
222
|
+
*/
|
|
223
|
+
height: number;
|
|
224
|
+
/**
|
|
225
|
+
* Whether the image is a valid UltraHDR image (has all required components)
|
|
226
|
+
*/
|
|
227
|
+
isValid: boolean;
|
|
228
|
+
/**
|
|
229
|
+
* Metadata version string (empty if not found)
|
|
230
|
+
*/
|
|
231
|
+
metadataVersion: string;
|
|
232
|
+
/**
|
|
233
|
+
* Primary image width in pixels (0 if not found)
|
|
234
|
+
*/
|
|
235
|
+
width: number;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Creates default gain map metadata.
|
|
240
|
+
*
|
|
241
|
+
* Useful for testing or when creating metadata programmatically.
|
|
242
|
+
*/
|
|
243
|
+
export function createDefaultMetadata(): GainMapMetadata;
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Creates default encoding options.
|
|
247
|
+
*
|
|
248
|
+
* # Returns
|
|
249
|
+
* `UltraHdrEncodeOptions` with sensible defaults:
|
|
250
|
+
* - baseQuality: 85
|
|
251
|
+
* - gainMapQuality: 75
|
|
252
|
+
* - targetHdrCapacity: 3.0
|
|
253
|
+
* - includeIsoMetadata: true
|
|
254
|
+
* - includeUltrahdrV1: true
|
|
255
|
+
* - gainMapScale: 1
|
|
256
|
+
*/
|
|
257
|
+
export function createDefaultOptions(): UltraHdrEncodeOptions;
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Creates high quality encoding options.
|
|
261
|
+
*
|
|
262
|
+
* # Returns
|
|
263
|
+
* `UltraHdrEncodeOptions` optimized for quality:
|
|
264
|
+
* - baseQuality: 95
|
|
265
|
+
* - gainMapQuality: 85
|
|
266
|
+
* - targetHdrCapacity: 4.0
|
|
267
|
+
*/
|
|
268
|
+
export function createHighQualityOptions(): UltraHdrEncodeOptions;
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* Creates small size encoding options.
|
|
272
|
+
*
|
|
273
|
+
* # Returns
|
|
274
|
+
* `UltraHdrEncodeOptions` optimized for file size:
|
|
275
|
+
* - baseQuality: 75
|
|
276
|
+
* - gainMapQuality: 65
|
|
277
|
+
* - targetHdrCapacity: 3.0
|
|
278
|
+
* - gainMapScale: 2 (half-size gain map)
|
|
279
|
+
*/
|
|
280
|
+
export function createSmallSizeOptions(): UltraHdrEncodeOptions;
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Decodes an UltraHDR JPEG, extracting SDR base, gain map, and metadata.
|
|
284
|
+
*
|
|
285
|
+
* # Arguments
|
|
286
|
+
* * `buffer` - UltraHDR JPEG file contents as bytes
|
|
287
|
+
*
|
|
288
|
+
* # Returns
|
|
289
|
+
* A `UltraHdrDecodeResult` containing:
|
|
290
|
+
* - `sdrImage`: The SDR base image as JPEG bytes
|
|
291
|
+
* - `gainMap`: The gain map as JPEG bytes
|
|
292
|
+
* - `metadata`: Gain map metadata (version, gains, gamma, offsets, etc.)
|
|
293
|
+
* - `width`, `height`: Image dimensions
|
|
294
|
+
* - `gainMapWidth`, `gainMapHeight`: Gain map dimensions
|
|
295
|
+
*
|
|
296
|
+
* # Errors
|
|
297
|
+
* Returns an error if the buffer is not a valid UltraHDR JPEG.
|
|
298
|
+
*/
|
|
299
|
+
export function decodeUltraHdr(buffer: Uint8Array): UltraHdrDecodeResult;
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* Encodes an UltraHDR JPEG from SDR and HDR inputs.
|
|
303
|
+
*
|
|
304
|
+
* # Arguments
|
|
305
|
+
* * `sdr_buffer` - SDR JPEG image bytes
|
|
306
|
+
* * `hdr_buffer` - HDR image as linear RGB float32 array (3 values per pixel, normalized to [0,1])
|
|
307
|
+
* * `options` - Encoding options (quality, HDR capacity, etc.)
|
|
308
|
+
*
|
|
309
|
+
* # Returns
|
|
310
|
+
* The encoded UltraHDR JPEG as bytes.
|
|
311
|
+
*
|
|
312
|
+
* # Errors
|
|
313
|
+
* Returns an error if:
|
|
314
|
+
* - The SDR buffer is not a valid JPEG
|
|
315
|
+
* - The HDR buffer size doesn't match the SDR dimensions
|
|
316
|
+
* - The dimensions are invalid (e.g., odd width/height)
|
|
317
|
+
*
|
|
318
|
+
* # Example (JavaScript)
|
|
319
|
+
* ```js
|
|
320
|
+
* const options = new UltraHdrEncodeOptions();
|
|
321
|
+
* options.baseQuality = 90;
|
|
322
|
+
* options.targetHdrCapacity = 3.0;
|
|
323
|
+
*
|
|
324
|
+
* const sdrBuffer = await sdrFile.arrayBuffer();
|
|
325
|
+
* const hdrBuffer = await getHdrLinearData(); // Float32Array
|
|
326
|
+
*
|
|
327
|
+
* const ultraHdr = encodeUltraHdr(
|
|
328
|
+
* new Uint8Array(sdrBuffer),
|
|
329
|
+
* new Float32Array(hdrBuffer),
|
|
330
|
+
* options
|
|
331
|
+
* );
|
|
332
|
+
* ```
|
|
333
|
+
*/
|
|
334
|
+
export function encodeUltraHdr(sdr_buffer: Uint8Array, hdr_buffer: Float32Array, options: UltraHdrEncodeOptions): Uint8Array;
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* Estimates the HDR headroom from metadata.
|
|
338
|
+
*
|
|
339
|
+
* # Arguments
|
|
340
|
+
* * `metadata` - The gain map metadata
|
|
341
|
+
*
|
|
342
|
+
* # Returns
|
|
343
|
+
* The maximum additional stops of dynamic range above SDR.
|
|
344
|
+
*/
|
|
345
|
+
export function estimateHdrHeadroom(metadata: GainMapMetadata): number;
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* Extracts just the SDR base image from an UltraHDR JPEG.
|
|
349
|
+
*
|
|
350
|
+
* This produces a standard JPEG that can be displayed on any device,
|
|
351
|
+
* without the gain map metadata. Useful for backwards compatibility.
|
|
352
|
+
*
|
|
353
|
+
* # Arguments
|
|
354
|
+
* * `buffer` - UltraHDR JPEG file contents as bytes
|
|
355
|
+
*
|
|
356
|
+
* # Returns
|
|
357
|
+
* A standard JPEG without gain map metadata.
|
|
358
|
+
*
|
|
359
|
+
* # Errors
|
|
360
|
+
* Returns an error if the buffer is not a valid JPEG.
|
|
361
|
+
*/
|
|
362
|
+
export function extractSdrBase(buffer: Uint8Array): Uint8Array;
|
|
363
|
+
|
|
364
|
+
/**
|
|
365
|
+
* Gets gain map metadata from an UltraHDR JPEG without full decode.
|
|
366
|
+
*
|
|
367
|
+
* This is faster than `decodeUltraHdr` when you only need the metadata.
|
|
368
|
+
*
|
|
369
|
+
* # Arguments
|
|
370
|
+
* * `buffer` - UltraHDR JPEG file contents as bytes
|
|
371
|
+
*
|
|
372
|
+
* # Returns
|
|
373
|
+
* The gain map metadata.
|
|
374
|
+
*
|
|
375
|
+
* # Errors
|
|
376
|
+
* Returns an error if the buffer doesn't contain gain map metadata.
|
|
377
|
+
*/
|
|
378
|
+
export function getMetadata(buffer: Uint8Array): GainMapMetadata;
|
|
379
|
+
|
|
380
|
+
/**
|
|
381
|
+
* Initializes the WASM module.
|
|
382
|
+
*
|
|
383
|
+
* This should be called before using any other functions.
|
|
384
|
+
*/
|
|
385
|
+
export function init(): void;
|
|
386
|
+
|
|
387
|
+
/**
|
|
388
|
+
* Checks if metadata indicates a meaningful HDR image.
|
|
389
|
+
*
|
|
390
|
+
* # Arguments
|
|
391
|
+
* * `metadata` - The gain map metadata
|
|
392
|
+
*
|
|
393
|
+
* # Returns
|
|
394
|
+
* `true` if the gain map provides significant dynamic range extension
|
|
395
|
+
* (more than half a stop).
|
|
396
|
+
*/
|
|
397
|
+
export function isMeaningfulHdr(metadata: GainMapMetadata): boolean;
|
|
398
|
+
|
|
399
|
+
/**
|
|
400
|
+
* Checks if a JPEG buffer contains UltraHDR/gain map data.
|
|
401
|
+
*
|
|
402
|
+
* This is a fast check that looks for gain map metadata in the XMP
|
|
403
|
+
* or MPF segments without fully decoding the image.
|
|
404
|
+
*
|
|
405
|
+
* # Arguments
|
|
406
|
+
* * `buffer` - JPEG file contents as bytes
|
|
407
|
+
*
|
|
408
|
+
* # Returns
|
|
409
|
+
* `true` if the image contains gain map metadata, `false` otherwise
|
|
410
|
+
*
|
|
411
|
+
* # Example (JavaScript)
|
|
412
|
+
* ```js
|
|
413
|
+
* const buffer = await file.arrayBuffer();
|
|
414
|
+
* const isHdr = isUltraHdr(new Uint8Array(buffer));
|
|
415
|
+
* ```
|
|
416
|
+
*/
|
|
417
|
+
export function isUltraHdr(buffer: Uint8Array): boolean;
|
|
418
|
+
|
|
419
|
+
/**
|
|
420
|
+
* Probes an image to check if it's UltraHDR and extracts component information.
|
|
421
|
+
*
|
|
422
|
+
* This function efficiently validates if an image is UltraHDR by checking for
|
|
423
|
+
* required components (primary image, gain map, metadata) without full decoding.
|
|
424
|
+
* Returns structured results useful for batch processing and filtering.
|
|
425
|
+
*
|
|
426
|
+
* Unlike `isUltraHdr`, this function provides detailed information about what
|
|
427
|
+
* was found, making it useful for diagnostics and filtering workflows.
|
|
428
|
+
*
|
|
429
|
+
* # Arguments
|
|
430
|
+
* * `buffer` - Image file contents as bytes
|
|
431
|
+
*
|
|
432
|
+
* # Returns
|
|
433
|
+
* `UltraHdrProbeResult` containing:
|
|
434
|
+
* - `isValid`: Whether the image is a valid UltraHDR image
|
|
435
|
+
* - `hasPrimaryImage`: Whether a primary JPEG was found
|
|
436
|
+
* - `hasGainMap`: Whether a gain map image was found
|
|
437
|
+
* - `hasMetadata`: Whether XMP metadata was found
|
|
438
|
+
* - `width`, `height`: Primary image dimensions (0 if not found)
|
|
439
|
+
* - `gainMapWidth`, `gainMapHeight`: Gain map dimensions (0 if not found)
|
|
440
|
+
* - `hdrCapacity`: HDR capacity in stops (0 if not found)
|
|
441
|
+
* - `metadataVersion`: Metadata version string (empty if not found)
|
|
442
|
+
*
|
|
443
|
+
* # Example (JavaScript)
|
|
444
|
+
* ```js
|
|
445
|
+
* const buffer = await file.arrayBuffer();
|
|
446
|
+
* const result = probeUltraHdr(new Uint8Array(buffer));
|
|
447
|
+
* if (result.isValid) {
|
|
448
|
+
* console.log('UltraHDR image:', result.width, 'x', result.height);
|
|
449
|
+
* console.log('HDR capacity:', result.hdrCapacity, 'stops');
|
|
450
|
+
* } else {
|
|
451
|
+
* if (!result.hasPrimaryImage) console.log('Not a JPEG');
|
|
452
|
+
* if (!result.hasGainMap) console.log('No gain map found');
|
|
453
|
+
* if (!result.hasMetadata) console.log('No HDR metadata');
|
|
454
|
+
* }
|
|
455
|
+
* ```
|
|
456
|
+
*/
|
|
457
|
+
export function probeUltraHdr(buffer: Uint8Array): UltraHdrProbeResult;
|
|
458
|
+
|
|
459
|
+
/**
|
|
460
|
+
* Validates gain map metadata.
|
|
461
|
+
*
|
|
462
|
+
* # Arguments
|
|
463
|
+
* * `metadata` - The metadata to validate
|
|
464
|
+
*
|
|
465
|
+
* # Returns
|
|
466
|
+
* `true` if the metadata is valid, `false` otherwise
|
|
467
|
+
*/
|
|
468
|
+
export function validateMetadata(metadata: GainMapMetadata): boolean;
|
|
469
|
+
|
|
470
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
471
|
+
|
|
472
|
+
export interface InitOutput {
|
|
473
|
+
readonly memory: WebAssembly.Memory;
|
|
474
|
+
readonly __wbg_gainmapmetadata_free: (a: number, b: number) => void;
|
|
475
|
+
readonly __wbg_get_gainmapmetadata_baseRenditionIsHdr: (a: number) => number;
|
|
476
|
+
readonly __wbg_get_gainmapmetadata_gainMapMax: (a: number) => [number, number];
|
|
477
|
+
readonly __wbg_get_gainmapmetadata_gainMapMin: (a: number) => [number, number];
|
|
478
|
+
readonly __wbg_get_gainmapmetadata_gamma: (a: number) => [number, number];
|
|
479
|
+
readonly __wbg_get_gainmapmetadata_hdrCapacityMax: (a: number) => number;
|
|
480
|
+
readonly __wbg_get_gainmapmetadata_hdrCapacityMin: (a: number) => number;
|
|
481
|
+
readonly __wbg_get_gainmapmetadata_offsetHdr: (a: number) => [number, number];
|
|
482
|
+
readonly __wbg_get_gainmapmetadata_offsetSdr: (a: number) => [number, number];
|
|
483
|
+
readonly __wbg_get_gainmapmetadata_version: (a: number) => [number, number];
|
|
484
|
+
readonly __wbg_get_ultrahdrdecoderesult_gainMap: (a: number) => [number, number];
|
|
485
|
+
readonly __wbg_get_ultrahdrdecoderesult_gainMapHeight: (a: number) => number;
|
|
486
|
+
readonly __wbg_get_ultrahdrdecoderesult_gainMapWidth: (a: number) => number;
|
|
487
|
+
readonly __wbg_get_ultrahdrdecoderesult_height: (a: number) => number;
|
|
488
|
+
readonly __wbg_get_ultrahdrdecoderesult_metadata: (a: number) => number;
|
|
489
|
+
readonly __wbg_get_ultrahdrdecoderesult_sdrImage: (a: number) => [number, number];
|
|
490
|
+
readonly __wbg_get_ultrahdrdecoderesult_width: (a: number) => number;
|
|
491
|
+
readonly __wbg_get_ultrahdrencodeoptions_baseQuality: (a: number) => number;
|
|
492
|
+
readonly __wbg_get_ultrahdrencodeoptions_gainMapQuality: (a: number) => number;
|
|
493
|
+
readonly __wbg_get_ultrahdrencodeoptions_gainMapScale: (a: number) => number;
|
|
494
|
+
readonly __wbg_get_ultrahdrencodeoptions_includeIsoMetadata: (a: number) => number;
|
|
495
|
+
readonly __wbg_get_ultrahdrencodeoptions_includeUltrahdrV1: (a: number) => number;
|
|
496
|
+
readonly __wbg_get_ultrahdrencodeoptions_targetHdrCapacity: (a: number) => number;
|
|
497
|
+
readonly __wbg_get_ultrahdrproberesult_gainMapHeight: (a: number) => number;
|
|
498
|
+
readonly __wbg_get_ultrahdrproberesult_gainMapWidth: (a: number) => number;
|
|
499
|
+
readonly __wbg_get_ultrahdrproberesult_hasGainMap: (a: number) => number;
|
|
500
|
+
readonly __wbg_get_ultrahdrproberesult_hasMetadata: (a: number) => number;
|
|
501
|
+
readonly __wbg_get_ultrahdrproberesult_hasPrimaryImage: (a: number) => number;
|
|
502
|
+
readonly __wbg_get_ultrahdrproberesult_hdrCapacity: (a: number) => number;
|
|
503
|
+
readonly __wbg_get_ultrahdrproberesult_height: (a: number) => number;
|
|
504
|
+
readonly __wbg_get_ultrahdrproberesult_isValid: (a: number) => number;
|
|
505
|
+
readonly __wbg_get_ultrahdrproberesult_width: (a: number) => number;
|
|
506
|
+
readonly __wbg_set_gainmapmetadata_baseRenditionIsHdr: (a: number, b: number) => void;
|
|
507
|
+
readonly __wbg_set_gainmapmetadata_gainMapMax: (a: number, b: number, c: number) => void;
|
|
508
|
+
readonly __wbg_set_gainmapmetadata_gainMapMin: (a: number, b: number, c: number) => void;
|
|
509
|
+
readonly __wbg_set_gainmapmetadata_gamma: (a: number, b: number, c: number) => void;
|
|
510
|
+
readonly __wbg_set_gainmapmetadata_hdrCapacityMax: (a: number, b: number) => void;
|
|
511
|
+
readonly __wbg_set_gainmapmetadata_hdrCapacityMin: (a: number, b: number) => void;
|
|
512
|
+
readonly __wbg_set_gainmapmetadata_offsetHdr: (a: number, b: number, c: number) => void;
|
|
513
|
+
readonly __wbg_set_gainmapmetadata_offsetSdr: (a: number, b: number, c: number) => void;
|
|
514
|
+
readonly __wbg_set_gainmapmetadata_version: (a: number, b: number, c: number) => void;
|
|
515
|
+
readonly __wbg_set_ultrahdrdecoderesult_gainMap: (a: number, b: number, c: number) => void;
|
|
516
|
+
readonly __wbg_set_ultrahdrdecoderesult_gainMapHeight: (a: number, b: number) => void;
|
|
517
|
+
readonly __wbg_set_ultrahdrdecoderesult_gainMapWidth: (a: number, b: number) => void;
|
|
518
|
+
readonly __wbg_set_ultrahdrdecoderesult_height: (a: number, b: number) => void;
|
|
519
|
+
readonly __wbg_set_ultrahdrdecoderesult_metadata: (a: number, b: number) => void;
|
|
520
|
+
readonly __wbg_set_ultrahdrdecoderesult_width: (a: number, b: number) => void;
|
|
521
|
+
readonly __wbg_set_ultrahdrencodeoptions_baseQuality: (a: number, b: number) => void;
|
|
522
|
+
readonly __wbg_set_ultrahdrencodeoptions_gainMapQuality: (a: number, b: number) => void;
|
|
523
|
+
readonly __wbg_set_ultrahdrencodeoptions_gainMapScale: (a: number, b: number) => void;
|
|
524
|
+
readonly __wbg_set_ultrahdrencodeoptions_includeIsoMetadata: (a: number, b: number) => void;
|
|
525
|
+
readonly __wbg_set_ultrahdrencodeoptions_includeUltrahdrV1: (a: number, b: number) => void;
|
|
526
|
+
readonly __wbg_set_ultrahdrencodeoptions_targetHdrCapacity: (a: number, b: number) => void;
|
|
527
|
+
readonly __wbg_set_ultrahdrproberesult_gainMapHeight: (a: number, b: number) => void;
|
|
528
|
+
readonly __wbg_set_ultrahdrproberesult_gainMapWidth: (a: number, b: number) => void;
|
|
529
|
+
readonly __wbg_set_ultrahdrproberesult_hasGainMap: (a: number, b: number) => void;
|
|
530
|
+
readonly __wbg_set_ultrahdrproberesult_hasMetadata: (a: number, b: number) => void;
|
|
531
|
+
readonly __wbg_set_ultrahdrproberesult_hasPrimaryImage: (a: number, b: number) => void;
|
|
532
|
+
readonly __wbg_set_ultrahdrproberesult_hdrCapacity: (a: number, b: number) => void;
|
|
533
|
+
readonly __wbg_set_ultrahdrproberesult_height: (a: number, b: number) => void;
|
|
534
|
+
readonly __wbg_set_ultrahdrproberesult_isValid: (a: number, b: number) => void;
|
|
535
|
+
readonly __wbg_set_ultrahdrproberesult_width: (a: number, b: number) => void;
|
|
536
|
+
readonly __wbg_ultrahdrdecoderesult_free: (a: number, b: number) => void;
|
|
537
|
+
readonly __wbg_ultrahdrencodeoptions_free: (a: number, b: number) => void;
|
|
538
|
+
readonly __wbg_ultrahdrproberesult_free: (a: number, b: number) => void;
|
|
539
|
+
readonly gainmapmetadata_forSdrBase: (a: number) => number;
|
|
540
|
+
readonly gainmapmetadata_new: () => number;
|
|
541
|
+
readonly ultrahdrdecoderesult_new: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => number;
|
|
542
|
+
readonly ultrahdrencodeoptions_highQuality: () => number;
|
|
543
|
+
readonly ultrahdrencodeoptions_new: () => number;
|
|
544
|
+
readonly ultrahdrencodeoptions_smallSize: () => number;
|
|
545
|
+
readonly ultrahdrproberesult_new: () => number;
|
|
546
|
+
readonly __wbg_get_ultrahdrproberesult_metadataVersion: (a: number) => [number, number];
|
|
547
|
+
readonly __wbg_set_ultrahdrdecoderesult_sdrImage: (a: number, b: number, c: number) => void;
|
|
548
|
+
readonly __wbg_set_ultrahdrproberesult_metadataVersion: (a: number, b: number, c: number) => void;
|
|
549
|
+
readonly createDefaultMetadata: () => number;
|
|
550
|
+
readonly createDefaultOptions: () => number;
|
|
551
|
+
readonly createHighQualityOptions: () => number;
|
|
552
|
+
readonly createSmallSizeOptions: () => number;
|
|
553
|
+
readonly decodeUltraHdr: (a: number, b: number) => [number, number, number];
|
|
554
|
+
readonly encodeUltraHdr: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
|
|
555
|
+
readonly estimateHdrHeadroom: (a: number) => number;
|
|
556
|
+
readonly extractSdrBase: (a: number, b: number) => [number, number, number, number];
|
|
557
|
+
readonly getMetadata: (a: number, b: number) => [number, number, number];
|
|
558
|
+
readonly init: () => void;
|
|
559
|
+
readonly isMeaningfulHdr: (a: number) => number;
|
|
560
|
+
readonly isUltraHdr: (a: number, b: number) => number;
|
|
561
|
+
readonly probeUltraHdr: (a: number, b: number) => number;
|
|
562
|
+
readonly validateMetadata: (a: number) => number;
|
|
563
|
+
readonly __wbindgen_externrefs: WebAssembly.Table;
|
|
564
|
+
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
565
|
+
readonly __externref_table_dealloc: (a: number) => void;
|
|
566
|
+
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
567
|
+
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
568
|
+
readonly __wbindgen_start: () => void;
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
572
|
+
|
|
573
|
+
/**
|
|
574
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
575
|
+
* a precompiled `WebAssembly.Module`.
|
|
576
|
+
*
|
|
577
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
578
|
+
*
|
|
579
|
+
* @returns {InitOutput}
|
|
580
|
+
*/
|
|
581
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
582
|
+
|
|
583
|
+
/**
|
|
584
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
585
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
586
|
+
*
|
|
587
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
588
|
+
*
|
|
589
|
+
* @returns {Promise<InitOutput>}
|
|
590
|
+
*/
|
|
591
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|