@monogrid/gainmap-js 1.1.0 → 2.0.0

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.
Files changed (51) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/README.md +21 -8
  3. package/dist/QuadRenderer-IDZuHqZM.js +178 -0
  4. package/dist/{_commonjsHelpers-1789f0cf.js → _commonjsHelpers-G_2thcKl.js} +1 -1
  5. package/dist/{compress-a4b59cab.js → compress-Cw5IwRTb.js} +1 -1
  6. package/dist/{loaders → core}/LoaderBase.d.ts +3 -3
  7. package/dist/{utils → core}/QuadRenderer.d.ts +6 -0
  8. package/dist/core/types.d.ts +64 -0
  9. package/dist/decode/decode.d.ts +56 -0
  10. package/dist/decode/extract.d.ts +10 -0
  11. package/dist/decode/index.d.ts +8 -0
  12. package/dist/{loaders → decode/loaders}/GainMapLoader.d.ts +4 -4
  13. package/dist/{loaders → decode/loaders}/JPEGRLoader.d.ts +5 -5
  14. package/dist/{materials → decode/materials}/GainMapDecoderMaterial.d.ts +3 -2
  15. package/dist/decode/types.d.ts +38 -0
  16. package/dist/decode/utils/MPFExtractor.d.ts +22 -0
  17. package/dist/decode/utils/extract-metadata-from-jpeg.d.ts +7 -0
  18. package/dist/decode.d.ts +1 -56
  19. package/dist/decode.js +737 -0
  20. package/dist/decode.umd.js +917 -0
  21. package/dist/{encode-utils → encode}/compress.d.ts +1 -1
  22. package/dist/encode/encode-and-compress.d.ts +61 -0
  23. package/dist/encode/encode.d.ts +58 -0
  24. package/dist/{encode-utils → encode}/get-gainmap.d.ts +3 -3
  25. package/dist/{encode-utils → encode}/get-sdr-rendition.d.ts +4 -5
  26. package/dist/encode/index.d.ts +10 -0
  27. package/dist/encode/types.d.ts +172 -0
  28. package/dist/encode.d.ts +1 -117
  29. package/dist/{index.js → encode.js} +42 -230
  30. package/dist/encode.umd.js +972 -0
  31. package/dist/libultrahdr/decode-jpeg-metadata.d.ts +31 -0
  32. package/dist/libultrahdr/encode-jpeg-metadata.d.ts +84 -0
  33. package/dist/libultrahdr/library.d.ts +9 -0
  34. package/dist/libultrahdr.d.ts +3 -123
  35. package/dist/libultrahdr.js +92 -167
  36. package/dist/libultrahdr.umd.js +91 -530
  37. package/dist/worker-interface.js +2 -2
  38. package/dist/worker-interface.umd.js +1 -3
  39. package/dist/worker-types.d.ts +2 -2
  40. package/dist/worker.js +3 -3
  41. package/dist/worker.umd.js +1 -1
  42. package/package.json +36 -29
  43. package/dist/LoaderBase-aa4842c4.js +0 -373
  44. package/dist/index.d.ts +0 -11
  45. package/dist/index.umd.js +0 -1360
  46. package/dist/materials/index.d.ts +0 -3
  47. package/dist/types.d.ts +0 -262
  48. /package/dist/{utils → core}/get-data-texture.d.ts +0 -0
  49. /package/dist/{encode-utils → encode}/find-texture-min-max.d.ts +0 -0
  50. /package/dist/{materials → encode/materials}/GainMapEncoderMaterial.d.ts +0 -0
  51. /package/dist/{materials → encode/materials}/SDRMaterial.d.ts +0 -0
@@ -1,9 +1,9 @@
1
1
  /**
2
- * @monogrid/gainmap-js v1.0.2
2
+ * @monogrid/gainmap-js v1.1.1
3
3
  * With ❤️, by MONOGRID <hello@mono-grid.com>
4
4
  */
5
5
 
6
- import { c as commonjsGlobal, g as getDefaultExportFromCjs } from './_commonjsHelpers-1789f0cf.js';
6
+ import { c as commonjsGlobal, g as getDefaultExportFromCjs } from './_commonjsHelpers-G_2thcKl.js';
7
7
 
8
8
  var lib$1;
9
9
  var hasRequiredLib$1;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @monogrid/gainmap-js v1.0.2
2
+ * @monogrid/gainmap-js v1.1.1
3
3
  * With ❤️, by MONOGRID <hello@mono-grid.com>
4
4
  */
5
5
 
@@ -511,6 +511,4 @@
511
511
  exports.getPromiseWorker = getPromiseWorker;
512
512
  exports.getWorkerInterface = getWorkerInterface;
513
513
 
514
- Object.defineProperty(exports, '__esModule', { value: true });
515
-
516
514
  }));
@@ -1,4 +1,4 @@
1
- import { CompressedImage, type CompressParameters } from './types';
1
+ import { CompressedImage, type CompressParameters } from './encode/types';
2
2
  export type WorkerInterface = {
3
3
  compress: {
4
4
  request: {
@@ -18,7 +18,7 @@ export type WorkerInterfaceImplementation = {
18
18
  [k in keyof WorkerInterface]: (payload: WorkerInterface[k]['request']['payload']) => Promise<WorkerInterface[k]['result']>;
19
19
  };
20
20
  export type WorkerRequest = WorkerInterface[keyof WorkerInterface]['request'];
21
- export type WithTranferListFunction = <T>(payload: T, transferList: Transferable[]) => T;
21
+ export type WithTransferListFunction = <T>(payload: T, transferList: Transferable[]) => T;
22
22
  export type PromiseWorkerType = {
23
23
  postMessage: (message: any, transferables?: Transferable[]) => Promise<any>;
24
24
  };
package/dist/worker.js CHANGED
@@ -1,10 +1,10 @@
1
1
  /**
2
- * @monogrid/gainmap-js v1.0.2
2
+ * @monogrid/gainmap-js v1.1.1
3
3
  * With ❤️, by MONOGRID <hello@mono-grid.com>
4
4
  */
5
5
 
6
- import { g as getDefaultExportFromCjs } from './_commonjsHelpers-1789f0cf.js';
7
- import { c as compress } from './compress-a4b59cab.js';
6
+ import { g as getDefaultExportFromCjs } from './_commonjsHelpers-G_2thcKl.js';
7
+ import { c as compress } from './compress-Cw5IwRTb.js';
8
8
 
9
9
  var isPromise$2 = {exports: {}};
10
10
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @monogrid/gainmap-js v1.0.2
2
+ * @monogrid/gainmap-js v1.1.1
3
3
  * With ❤️, by MONOGRID <hello@mono-grid.com>
4
4
  */
5
5
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@monogrid/gainmap-js",
3
- "version": "1.1.0",
3
+ "version": "2.0.0",
4
4
  "description": "A Javascript (TypeScript) Port of Adobe Gainmap Technology for storing HDR Images using an SDR Image + a gain map",
5
5
  "homepage": "https://github.com/MONOGRID/gainmap-js#readme",
6
6
  "repository": {
@@ -28,15 +28,19 @@
28
28
  "path": "./node_modules/cz-conventional-changelog"
29
29
  }
30
30
  },
31
- "main": "dist/index.umd.js",
32
- "module": "dist/index.js",
33
- "types": "dist/index.d.ts",
31
+ "main": "dist/decode.umd.js",
32
+ "module": "dist/decode.js",
33
+ "types": "dist/decode.d.ts",
34
34
  "sideEffects": false,
35
35
  "type": "module",
36
36
  "exports": {
37
37
  ".": {
38
- "import": "./dist/index.js",
39
- "types": "./dist/index.d.ts"
38
+ "import": "./dist/decode.js",
39
+ "types": "./dist/decode.d.ts"
40
+ },
41
+ "./encode": {
42
+ "import": "./dist/encode.js",
43
+ "types": "./dist/encode.d.ts"
40
44
  },
41
45
  "./libultrahdr": {
42
46
  "import": "./dist/libultrahdr.js",
@@ -54,7 +58,10 @@
54
58
  "typesVersions": {
55
59
  "*": {
56
60
  ".": [
57
- "./dist/index.d.ts"
61
+ "./dist/decode.d.ts"
62
+ ],
63
+ "encode": [
64
+ "./dist/encode.d.ts"
58
65
  ],
59
66
  "libultrahdr": [
60
67
  "./dist/libultrahdr.d.ts"
@@ -89,55 +96,55 @@
89
96
  "ci:check:eslint-tests": "eslint --format json --output-file reports/eslint-tests.json \"tests/**/*.ts\""
90
97
  },
91
98
  "peerDependencies": {
92
- "three": "^0.157.0"
99
+ "three": ">= 0.157.0 < 0.159.0"
93
100
  },
94
101
  "dependencies": {
95
102
  "promise-worker-transferable": "^1.0.4"
96
103
  },
97
104
  "devDependencies": {
98
- "@babel/core": "^7.23.2",
99
- "@rollup/plugin-commonjs": "^25.0.5",
105
+ "@rollup/plugin-commonjs": "^25.0.7",
100
106
  "@rollup/plugin-json": "^6.0.1",
101
107
  "@rollup/plugin-node-resolve": "^15.2.3",
102
108
  "@rollup/plugin-terser": "^0.4.4",
103
109
  "@rollup/plugin-typescript": "^11.1.5",
104
110
  "@semantic-release/changelog": "^6.0.3",
105
- "@semantic-release/commit-analyzer": "^11.0.0",
111
+ "@semantic-release/commit-analyzer": "^11.1.0",
106
112
  "@semantic-release/git": "github:semantic-release/git",
107
- "@semantic-release/github": "^9.2.1",
108
- "@semantic-release/npm": "^11.0.0",
109
- "@semantic-release/release-notes-generator": "^12.0.0",
110
- "@types/jest": "^29.5.5",
111
- "@types/node": "^20.8.4",
112
- "@types/three": "^0.157.0",
113
- "@typescript-eslint/eslint-plugin": "^6.7.5",
114
- "@typescript-eslint/parser": "^6.7.5",
113
+ "@semantic-release/github": "^9.2.3",
114
+ "@semantic-release/npm": "^11.0.1",
115
+ "@semantic-release/release-notes-generator": "^12.1.0",
116
+ "@types/jest": "^29.5.8",
117
+ "@types/node": "^20.9.0",
118
+ "@types/three": "^0.158.2",
119
+ "@typescript-eslint/eslint-plugin": "^6.10.0",
120
+ "@typescript-eslint/parser": "^6.10.0",
115
121
  "babel-jest": "^29.7.0",
116
122
  "concurrently": "^8.2.2",
117
123
  "conventional-changelog-conventionalcommits": "^7.0.2",
118
124
  "cz-conventional-changelog": "^3.3.0",
119
- "eslint": "^8.51.0",
125
+ "eslint": "^8.53.0",
120
126
  "eslint-config-standard": "^17.0.0",
121
- "eslint-plugin-import": "^2.19.1",
127
+ "eslint-plugin-import": "^2.29.0",
122
128
  "eslint-plugin-jest-extended": "^2.0.0",
123
- "eslint-plugin-n": "^16.0.0",
129
+ "eslint-plugin-n": "^16.3.1",
124
130
  "eslint-plugin-promise": "^6.0.0",
125
131
  "eslint-plugin-quasar": "^1.1.0",
126
132
  "eslint-plugin-simple-import-sort": "^10.0.0",
127
133
  "eslint-plugin-unused-imports": "^3.0.0",
128
134
  "jest": "^29.7.0",
135
+ "jest-environment-jsdom": "^29.7.0",
129
136
  "jest-extended": "^4.0.2",
130
137
  "jest-junit": "^16.0.0",
131
- "puppeteer": "^21.3.8",
132
- "rollup": "^2.79.1",
138
+ "puppeteer": "^21.5.1",
139
+ "rollup": "^4.3.0",
133
140
  "rollup-plugin-copy": "^3.5.0",
134
- "rollup-plugin-license": "^3.1.0",
135
- "semantic-release": "^22.0.5",
136
- "three": "^0.157.0",
141
+ "rollup-plugin-license": "^3.2.0",
142
+ "semantic-release": "^22.0.7",
143
+ "three": "^0.158.0",
137
144
  "ts-jest": "^29.1.1",
138
- "typedoc": "^0.25.2",
145
+ "typedoc": "^0.25.3",
139
146
  "typedoc-github-wiki-theme": "^1.1.0",
140
- "typedoc-plugin-markdown": "^3.16.0",
147
+ "typedoc-plugin-markdown": "^3.17.1",
141
148
  "typescript": "^5.2.2"
142
149
  }
143
150
  }
@@ -1,373 +0,0 @@
1
- /**
2
- * @monogrid/gainmap-js v1.0.2
3
- * With ❤️, by MONOGRID <hello@mono-grid.com>
4
- */
5
-
6
- import { ShaderMaterial, Vector3, NoBlending, Scene, OrthographicCamera, Mesh, PlaneGeometry, WebGLRenderTarget, RGBAFormat, LinearFilter, LinearMipMapLinearFilter, RepeatWrapping, WebGLRenderer, FloatType, IntType, ShortType, ByteType, UnsignedIntType, HalfFloatType, UnsignedByteType, DataTexture, UVMapping, NoColorSpace, Loader, Texture, ClampToEdgeWrapping, SRGBColorSpace } from 'three';
7
-
8
- const vertexShader = /* glsl */ `
9
- varying vec2 vUv;
10
-
11
- void main() {
12
- vUv = uv;
13
- gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
14
- }
15
- `;
16
- const fragmentShader = /* glsl */ `
17
- uniform sampler2D sdr;
18
- uniform sampler2D gainMap;
19
- uniform vec3 gamma;
20
- uniform vec3 offsetHdr;
21
- uniform vec3 offsetSdr;
22
- uniform vec3 gainMapMin;
23
- uniform vec3 gainMapMax;
24
- uniform float weightFactor;
25
-
26
- varying vec2 vUv;
27
-
28
- void main() {
29
- vec3 rgb = texture2D(sdr, vUv).rgb;
30
- vec3 recovery = texture2D(gainMap, vUv).rgb;
31
- vec3 logRecovery = pow(recovery, gamma);
32
- vec3 logBoost = gainMapMin * (1.0 - logRecovery) + gainMapMax * logRecovery;
33
- vec3 hdrColor = (rgb + offsetSdr) * exp2(logBoost * weightFactor) - offsetHdr;
34
- gl_FragColor = vec4(hdrColor, 1.0);
35
- }
36
- `;
37
- /**
38
- * A Material which is able to decode the Gainmap into a full HDR Representation
39
- *
40
- * @category Materials
41
- * @group Materials
42
- */
43
- class GainMapDecoderMaterial extends ShaderMaterial {
44
- /**
45
- *
46
- * @param params
47
- */
48
- constructor({ gamma, offsetHdr, offsetSdr, gainMapMin, gainMapMax, maxDisplayBoost, hdrCapacityMin, hdrCapacityMax, sdr, gainMap }) {
49
- super({
50
- name: 'GainMapDecoderMaterial',
51
- vertexShader,
52
- fragmentShader,
53
- uniforms: {
54
- sdr: { value: sdr },
55
- gainMap: { value: gainMap },
56
- gamma: { value: new Vector3(1.0 / gamma[0], 1.0 / gamma[1], 1.0 / gamma[2]) },
57
- offsetHdr: { value: new Vector3().fromArray(offsetHdr) },
58
- offsetSdr: { value: new Vector3().fromArray(offsetSdr) },
59
- gainMapMin: { value: new Vector3().fromArray(gainMapMin) },
60
- gainMapMax: { value: new Vector3().fromArray(gainMapMax) },
61
- weightFactor: {
62
- value: (Math.log2(maxDisplayBoost) - hdrCapacityMin) / (hdrCapacityMax - hdrCapacityMin)
63
- }
64
- },
65
- blending: NoBlending,
66
- depthTest: false,
67
- depthWrite: false
68
- });
69
- this._maxDisplayBoost = maxDisplayBoost;
70
- this._hdrCapacityMin = hdrCapacityMin;
71
- this._hdrCapacityMax = hdrCapacityMax;
72
- this.needsUpdate = true;
73
- this.uniformsNeedUpdate = true;
74
- }
75
- get sdr() { return this.uniforms.sdr.value; }
76
- set sdr(value) { this.uniforms.sdr.value = value; }
77
- get gainMap() { return this.uniforms.gainMap.value; }
78
- set gainMap(value) { this.uniforms.gainMap.value = value; }
79
- /**
80
- * @see {@link GainMapMetadata.offsetHdr}
81
- */
82
- get offsetHdr() { return this.uniforms.offsetHdr.value.toArray(); }
83
- set offsetHdr(value) { this.uniforms.offsetHdr.value.fromArray(value); }
84
- /**
85
- * @see {@link GainMapMetadata.offsetSdr}
86
- */
87
- get offsetSdr() { return this.uniforms.offsetSdr.value.toArray(); }
88
- set offsetSdr(value) { this.uniforms.offsetSdr.value.fromArray(value); }
89
- /**
90
- * @see {@link GainMapMetadata.gainMapMin}
91
- */
92
- get gainMapMin() { return this.uniforms.gainMapMin.value.toArray(); }
93
- set gainMapMin(value) { this.uniforms.gainMapMin.value.fromArray(value); }
94
- /**
95
- * @see {@link GainMapMetadata.gainMapMax}
96
- */
97
- get gainMapMax() { return this.uniforms.gainMapMax.value.toArray(); }
98
- set gainMapMax(value) { this.uniforms.gainMapMax.value.fromArray(value); }
99
- /**
100
- * @see {@link GainmapEncodingParameters.gamma}
101
- */
102
- get gamma() {
103
- const g = this.uniforms.gamma.value;
104
- return [1 / g.x, 1 / g.y, 1 / g.z];
105
- }
106
- set gamma(value) {
107
- const g = this.uniforms.gamma.value;
108
- g.x = 1.0 / value[0];
109
- g.y = 1.0 / value[1];
110
- g.z = 1.0 / value[2];
111
- }
112
- /**
113
- * @see {@link GainMapMetadata.hdrCapacityMin}
114
- * @remarks Logarithmic space
115
- */
116
- get hdrCapacityMin() { return this._hdrCapacityMin; }
117
- set hdrCapacityMin(value) {
118
- this._hdrCapacityMin = value;
119
- this.calculateWeight();
120
- }
121
- /**
122
- * @see {@link GainMapMetadata.hdrCapacityMin}
123
- * @remarks Logarithmic space
124
- */
125
- get hdrCapacityMax() { return this._hdrCapacityMax; }
126
- set hdrCapacityMax(value) {
127
- this._hdrCapacityMax = value;
128
- this.calculateWeight();
129
- }
130
- /**
131
- * @see {@link GainmapDecodingParameters.maxDisplayBoost}
132
- * @remarks Non Logarithmic space
133
- */
134
- get maxDisplayBoost() { return this._maxDisplayBoost; }
135
- set maxDisplayBoost(value) {
136
- this._maxDisplayBoost = value;
137
- this.calculateWeight();
138
- }
139
- calculateWeight() {
140
- this.uniforms.weightFactor.value = (Math.log2(this._maxDisplayBoost) - this._hdrCapacityMin) / (this._hdrCapacityMax - this._hdrCapacityMin);
141
- }
142
- }
143
-
144
- /**
145
- * Utility structure used for rendering a texture with a material
146
- *
147
- * @category General
148
- * @group General
149
- */
150
- class QuadRenderer {
151
- /**
152
- *
153
- * @param sourceTexture
154
- * @param renderer
155
- */
156
- constructor(width, height, type, colorSpace, material, renderer) {
157
- this._rendererIsDisposable = false;
158
- /**
159
- * Renders the input texture using the specified material
160
- */
161
- this.render = () => {
162
- this._renderer.setRenderTarget(this._renderTarget);
163
- try {
164
- this._renderer.render(this._scene, this._camera);
165
- }
166
- catch (e) {
167
- this._renderer.setRenderTarget(null);
168
- throw e;
169
- }
170
- this._renderer.setRenderTarget(null);
171
- };
172
- this._width = width;
173
- this._height = height;
174
- this._type = type;
175
- this._material = material;
176
- if (renderer) {
177
- this._renderer = renderer;
178
- }
179
- else {
180
- this._renderer = QuadRenderer.instantiateRenderer();
181
- this._rendererIsDisposable = true;
182
- }
183
- this._scene = new Scene();
184
- this._camera = new OrthographicCamera();
185
- this._camera.position.set(0, 0, 10);
186
- this._camera.left = -0.5;
187
- this._camera.right = 0.5;
188
- this._camera.top = 0.5;
189
- this._camera.bottom = -0.5;
190
- this._camera.updateProjectionMatrix();
191
- this._quad = new Mesh(new PlaneGeometry(), this._material);
192
- this._quad.geometry.computeBoundingBox();
193
- this._scene.add(this._quad);
194
- this._renderTarget = new WebGLRenderTarget(width, height, {
195
- type,
196
- colorSpace,
197
- format: RGBAFormat,
198
- magFilter: LinearFilter,
199
- minFilter: LinearMipMapLinearFilter,
200
- wrapS: RepeatWrapping,
201
- wrapT: RepeatWrapping,
202
- depthBuffer: false,
203
- stencilBuffer: false,
204
- generateMipmaps: true
205
- });
206
- }
207
- /**
208
- * Instantiates a temporary renderer
209
- *
210
- * @returns
211
- */
212
- static instantiateRenderer() {
213
- const renderer = new WebGLRenderer();
214
- renderer.setSize(128, 128);
215
- // renderer.outputColorSpace = SRGBColorSpace
216
- // renderer.toneMapping = LinearToneMapping
217
- // renderer.debug.checkShaderErrors = false
218
- // this._rendererIsDisposable = true
219
- return renderer;
220
- }
221
- /**
222
- * Obtains a Buffer containing the rendered texture.
223
- *
224
- * @returns
225
- */
226
- toArray() {
227
- let out;
228
- switch (this._type) {
229
- case UnsignedByteType:
230
- out = new Uint8ClampedArray(this._width * this._height * 4);
231
- break;
232
- case HalfFloatType:
233
- out = new Uint16Array(this._width * this._height * 4);
234
- break;
235
- case UnsignedIntType:
236
- out = new Uint32Array(this._width * this._height * 4);
237
- break;
238
- case ByteType:
239
- out = new Int8Array(this._width * this._height * 4);
240
- break;
241
- case ShortType:
242
- out = new Int16Array(this._width * this._height * 4);
243
- break;
244
- case IntType:
245
- out = new Int32Array(this._width * this._height * 4);
246
- break;
247
- case FloatType:
248
- out = new Float32Array(this._width * this._height * 4);
249
- break;
250
- default:
251
- throw new Error('Unsupported data type');
252
- }
253
- this._renderer.readRenderTargetPixels(this._renderTarget, 0, 0, this._width, this._height, out);
254
- return out;
255
- }
256
- toDataTexture() {
257
- return new DataTexture(this.toArray(), this.width, this.height, RGBAFormat, HalfFloatType, UVMapping, RepeatWrapping, RepeatWrapping, LinearFilter, LinearMipMapLinearFilter, 1, NoColorSpace);
258
- }
259
- /**
260
- * If using a disposable renderer, it will dispose it.
261
- */
262
- dispose() {
263
- this._renderer.setRenderTarget(null);
264
- if (this._rendererIsDisposable) {
265
- this._renderer.dispose();
266
- this._renderer.forceContextLoss();
267
- }
268
- }
269
- /**
270
- * Width of the texture
271
- */
272
- get width() { return this._width; }
273
- set width(value) {
274
- this._width = value;
275
- this._renderTarget.setSize(this._width, this._height);
276
- }
277
- /**
278
- * Height of the texture
279
- */
280
- get height() { return this._height; }
281
- set height(value) {
282
- this._height = value;
283
- this._renderTarget.setSize(this._width, this._height);
284
- }
285
- /**
286
- * The renderer used
287
- */
288
- get renderer() { return this._renderer; }
289
- /**
290
- * The `WebGLRenderTarget` used.
291
- */
292
- get renderTarget() { return this._renderTarget; }
293
- set renderTarget(value) {
294
- this._renderTarget = value;
295
- this._width = value.width;
296
- this._height = value.height;
297
- // this._type = value.texture.type
298
- }
299
- /**
300
- * The `Material` used.
301
- */
302
- get material() { return this._material; }
303
- }
304
-
305
- class LoaderBase extends Loader {
306
- /**
307
- *
308
- * @param renderer
309
- * @param manager
310
- */
311
- constructor(renderer, manager) {
312
- super(manager);
313
- this.renderer = renderer;
314
- }
315
- /**
316
- * @private
317
- * @returns
318
- */
319
- prepareQuadRenderer() {
320
- // temporary values
321
- const material = new GainMapDecoderMaterial({
322
- gainMapMax: [1, 1, 1],
323
- gainMapMin: [0, 0, 0],
324
- gamma: [1, 1, 1],
325
- offsetHdr: [1, 1, 1],
326
- offsetSdr: [1, 1, 1],
327
- hdrCapacityMax: 1,
328
- hdrCapacityMin: 0,
329
- maxDisplayBoost: 1,
330
- gainMap: new Texture(),
331
- sdr: new Texture()
332
- });
333
- return new QuadRenderer(16, 16, HalfFloatType, NoColorSpace, material, this.renderer);
334
- }
335
- /**
336
- *
337
- * @private
338
- * @param quadRenderer
339
- * @param gainMapBuffer
340
- * @param sdrBuffer
341
- * @param metadata
342
- */
343
- async render(quadRenderer, gainMapBuffer, sdrBuffer, metadata) {
344
- const gainMapBlob = new Blob([gainMapBuffer], { type: 'image/jpeg' });
345
- // TODO: figure out why result.sdr is not usable here, problem is in the libultrahdr-wasm repo
346
- // we use the original image buffer instead
347
- const sdrBlob = new Blob([sdrBuffer], { type: 'image/jpeg' });
348
- const [gainMapImageBitmap, sdrImageBitmap] = await Promise.all([
349
- createImageBitmap(gainMapBlob, { imageOrientation: 'flipY' }),
350
- createImageBitmap(sdrBlob, { imageOrientation: 'flipY' })
351
- ]);
352
- const gainMap = new Texture(gainMapImageBitmap, UVMapping, ClampToEdgeWrapping, ClampToEdgeWrapping, LinearFilter, LinearMipMapLinearFilter, RGBAFormat, UnsignedByteType, 1, NoColorSpace);
353
- gainMap.needsUpdate = true;
354
- const sdr = new Texture(sdrImageBitmap, UVMapping, ClampToEdgeWrapping, ClampToEdgeWrapping, LinearFilter, LinearMipMapLinearFilter, RGBAFormat, UnsignedByteType, 1, SRGBColorSpace);
355
- sdr.needsUpdate = true;
356
- quadRenderer.width = sdrImageBitmap.width;
357
- quadRenderer.height = sdrImageBitmap.height;
358
- quadRenderer.material.gainMap = gainMap;
359
- quadRenderer.material.sdr = sdr;
360
- quadRenderer.material.gainMapMin = metadata.gainMapMin;
361
- quadRenderer.material.gainMapMax = metadata.gainMapMax;
362
- quadRenderer.material.offsetHdr = metadata.offsetHdr;
363
- quadRenderer.material.offsetSdr = metadata.offsetSdr;
364
- quadRenderer.material.gamma = metadata.gamma;
365
- quadRenderer.material.hdrCapacityMin = metadata.hdrCapacityMin;
366
- quadRenderer.material.hdrCapacityMax = metadata.hdrCapacityMax;
367
- quadRenderer.material.maxDisplayBoost = Math.pow(2, metadata.hdrCapacityMax);
368
- quadRenderer.material.needsUpdate = true;
369
- quadRenderer.render();
370
- }
371
- }
372
-
373
- export { GainMapDecoderMaterial as G, LoaderBase as L, QuadRenderer as Q };
package/dist/index.d.ts DELETED
@@ -1,11 +0,0 @@
1
- export * from './decode';
2
- export * from './encode';
3
- export * from './encode-utils/compress';
4
- export * from './encode-utils/find-texture-min-max';
5
- export * from './encode-utils/get-gainmap';
6
- export * from './encode-utils/get-sdr-rendition';
7
- export * from './loaders/GainMapLoader';
8
- export * from './materials/index';
9
- export * from './types';
10
- export * from './utils/get-data-texture';
11
- export * from './utils/QuadRenderer';