-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Adds code for encoders and decoders * Cleans up some obsolete QOI-related code
- Loading branch information
1 parent
71f3419
commit 003d5d1
Showing
13 changed files
with
90 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export interface QOIModule extends EmscriptenWasm.Module { | ||
decode(data: BufferSource): ImageData | null; | ||
} | ||
|
||
declare var moduleFactory: EmscriptenWasm.ModuleFactory<QOIModule>; | ||
|
||
export default moduleFactory; |
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import type { QOIModule } from 'codecs/qoi/dec/qoi_dec'; | ||
import { initEmscriptenModule, blobToArrayBuffer } from 'features/worker-utils'; | ||
|
||
let emscriptenModule: Promise<QOIModule>; | ||
|
||
export default async function decode(blob: Blob): Promise<ImageData> { | ||
if (!emscriptenModule) { | ||
const decoder = await import('codecs/qoi/dec/qoi_dec'); | ||
emscriptenModule = initEmscriptenModule(decoder.default); | ||
} | ||
|
||
const [module, data] = await Promise.all([ | ||
emscriptenModule, | ||
blobToArrayBuffer(blob), | ||
]); | ||
|
||
const result = module.decode(data); | ||
if (!result) throw new Error('Decoding error'); | ||
return result; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters