diff --git a/codecs/wp2/dec/wp2_dec.wasm b/codecs/wp2/dec/wp2_dec.wasm old mode 100644 new mode 100755 index 63aaf797..48cba110 Binary files a/codecs/wp2/dec/wp2_dec.wasm and b/codecs/wp2/dec/wp2_dec.wasm differ diff --git a/codecs/wp2/dec/wp2_node_dec.wasm b/codecs/wp2/dec/wp2_node_dec.wasm index 7d54abcc..48cba110 100755 Binary files a/codecs/wp2/dec/wp2_node_dec.wasm and b/codecs/wp2/dec/wp2_node_dec.wasm differ diff --git a/codecs/wp2/enc/wp2_enc.cpp b/codecs/wp2/enc/wp2_enc.cpp index 91989d4c..a85b38f1 100644 --- a/codecs/wp2/enc/wp2_enc.cpp +++ b/codecs/wp2/enc/wp2_enc.cpp @@ -18,6 +18,7 @@ struct WP2Options { int csp_type; int error_diffusion; bool use_random_matrix; + int tile_shape; }; val encode(std::string image_in, int image_width, int image_height, WP2Options options) { @@ -32,6 +33,7 @@ val encode(std::string image_in, int image_width, int image_height, WP2Options o config.sns = options.sns; config.error_diffusion = options.error_diffusion; config.use_random_matrix = options.use_random_matrix; + config.tile_shape = static_cast(options.tile_shape); uint8_t* image_buffer = (uint8_t*)image_in.c_str(); WP2::ArgbBuffer src = WP2::ArgbBuffer(); diff --git a/codecs/wp2/enc/wp2_enc.d.ts b/codecs/wp2/enc/wp2_enc.d.ts index 00ee4e63..9b85a4b1 100644 --- a/codecs/wp2/enc/wp2_enc.d.ts +++ b/codecs/wp2/enc/wp2_enc.d.ts @@ -8,6 +8,7 @@ export interface EncodeOptions { csp_type: Csp; error_diffusion: number; use_random_matrix: boolean; + tile_shape: TileShape; } export const enum UVMode { @@ -24,6 +25,14 @@ export const enum Csp { kYIQ, } +export const enum TileShape { + Square128, + Square256, + Square512, + Wide, + Auto, +} + export interface WP2Module extends EmscriptenWasm.Module { encode( data: BufferSource, diff --git a/codecs/wp2/enc/wp2_enc.wasm b/codecs/wp2/enc/wp2_enc.wasm old mode 100644 new mode 100755 index 80871e03..b7015720 Binary files a/codecs/wp2/enc/wp2_enc.wasm and b/codecs/wp2/enc/wp2_enc.wasm differ diff --git a/codecs/wp2/enc/wp2_enc_mt.wasm b/codecs/wp2/enc/wp2_enc_mt.wasm old mode 100644 new mode 100755 index 5e4285d7..dc743078 Binary files a/codecs/wp2/enc/wp2_enc_mt.wasm and b/codecs/wp2/enc/wp2_enc_mt.wasm differ diff --git a/codecs/wp2/enc/wp2_enc_mt_simd.wasm b/codecs/wp2/enc/wp2_enc_mt_simd.wasm old mode 100644 new mode 100755 index d71e33de..2fff957c Binary files a/codecs/wp2/enc/wp2_enc_mt_simd.wasm and b/codecs/wp2/enc/wp2_enc_mt_simd.wasm differ diff --git a/codecs/wp2/enc/wp2_node_enc.wasm b/codecs/wp2/enc/wp2_node_enc.wasm index cba2e782..b7015720 100755 Binary files a/codecs/wp2/enc/wp2_node_enc.wasm and b/codecs/wp2/enc/wp2_node_enc.wasm differ diff --git a/src/features/encoders/wp2/client/index.tsx b/src/features/encoders/wp2/client/index.tsx index a7c4953e..4e9f64c9 100644 --- a/src/features/encoders/wp2/client/index.tsx +++ b/src/features/encoders/wp2/client/index.tsx @@ -10,6 +10,7 @@ import Checkbox from 'client/lazy-app/Compress/Options/Checkbox'; import Expander from 'client/lazy-app/Compress/Options/Expander'; import linkState from 'linkstate'; import Revealer from 'client/lazy-app/Compress/Options/Revealer'; +import { TileShape } from 'codecs/wp2/enc/wp2_enc'; export const encode = ( signal: AbortSignal, @@ -38,6 +39,7 @@ interface State { useRandomMatrix: boolean; showAdvanced: boolean; separateAlpha: boolean; + tileShape: number; } export class Options extends Component { @@ -62,6 +64,7 @@ export class Options extends Component { errorDiffusion: options.error_diffusion, useRandomMatrix: options.use_random_matrix, separateAlpha: options.quality !== options.alpha_quality, + tileShape: options.tile_shape, }; // If quality is > 95, it's lossless with slight loss @@ -121,6 +124,7 @@ export class Options extends Component { csp_type: optionState.colorSpace, error_diffusion: optionState.errorDiffusion, use_random_matrix: optionState.useRandomMatrix, + tile_shape: optionState.tileShape, }; // Updating options, so we don't recalculate in getDerivedStateFromProps. @@ -151,6 +155,7 @@ export class Options extends Component { useRandomMatrix, separateAlpha, showAdvanced, + tileShape, }: State, ) { return ( @@ -213,17 +218,23 @@ export class Options extends Component { )} - + + )} + + + + {showAdvanced && ( +
- {showAdvanced && ( + {!lossless && (
-
+ {/*
{ > Passes: -
+
*/}
{ Spatial noise shaping:
-
- - Error diffusion: - -
- */} +
+ + Error diffusion: + +
)}
+
)}
diff --git a/src/features/encoders/wp2/shared/meta.ts b/src/features/encoders/wp2/shared/meta.ts index d986fb34..2500b71d 100644 --- a/src/features/encoders/wp2/shared/meta.ts +++ b/src/features/encoders/wp2/shared/meta.ts @@ -11,7 +11,7 @@ * limitations under the License. */ import type { EncodeOptions } from 'codecs/wp2/enc/wp2_enc'; -import { UVMode, Csp } from 'codecs/wp2/enc/wp2_enc'; +import { UVMode, Csp, TileShape } from 'codecs/wp2/enc/wp2_enc'; export { EncodeOptions, UVMode, Csp }; @@ -28,4 +28,5 @@ export const defaultOptions: EncodeOptions = { csp_type: Csp.kYCoCg, error_diffusion: 0, use_random_matrix: false, + tile_shape: TileShape.Auto, };