From 29ffa3f3dc19e1e0c1e38ad07fcd8d6b964dde31 Mon Sep 17 00:00:00 2001 From: totaam Date: Sat, 12 Feb 2022 22:52:13 +0700 Subject: [PATCH] add avif decoding --- html5/js/Client.js | 5 ++++- html5/js/DecodeWorker.js | 2 +- html5/js/OffscreenDecodeWorker.js | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/html5/js/Client.js b/html5/js/Client.js index 03f81ab3..c59afebd 100644 --- a/html5/js/Client.js +++ b/html5/js/Client.js @@ -63,7 +63,7 @@ XpraClient.prototype.init_settings = function() { this.encoding = "auto"; //basic set of encodings: //(more may be added after checking via the DecodeWorker) - this.supported_encodings = ["jpeg", "png", "png/P", "png/L", "rgb", "rgb32", "rgb24", "scroll", "webp", "void"]; + this.supported_encodings = ["jpeg", "png", "png/P", "png/L", "rgb", "rgb32", "rgb24", "scroll", "webp", "void", "avif"]; //extra encodings we enable if validated via the decode worker: //(we also validate jpeg and png as a sanity check) this.check_encodings = this.supported_encodings; @@ -396,9 +396,11 @@ XpraClient.prototype.connect = function() { } XpraClient.prototype.initialize_workers = function() { + const safe_encodings = ["jpeg", "png", "png/P", "png/L", "rgb", "rgb32", "rgb24", "scroll", "void"]; // detect websocket in webworker support and degrade gracefully if (!window.Worker) { // no webworker support + this.supported_encodings = safe_encodings; this.offscreen_api = false; this.decode_worker = false; this.clog("no webworker support at all."); @@ -431,6 +433,7 @@ XpraClient.prototype.initialize_workers = function() { worker.postMessage({'cmd': 'check'}); if (!DECODE_WORKER) { + this.supported_encodings = safe_encodings; this.decode_worker = false; return; } diff --git a/html5/js/DecodeWorker.js b/html5/js/DecodeWorker.js index 1d0443d4..2dffafc0 100644 --- a/html5/js/DecodeWorker.js +++ b/html5/js/DecodeWorker.js @@ -136,7 +136,7 @@ function decode_draw_packet(packet, start) { const data = decode_rgb(packet); send_rgb32_back(data, width, height, bitmap_options); } - else if (coding.startsWith("png") || coding=="jpeg" || coding=="webp") { + else if (coding.startsWith("png") || coding=="jpeg" || coding=="webp" || coding=="avif") { const data = packet[7]; if (!data.buffer) { decode_error("missing pixel data buffer: "+(typeof data)); diff --git a/html5/js/OffscreenDecodeWorker.js b/html5/js/OffscreenDecodeWorker.js index 46da6a54..daaabbe7 100644 --- a/html5/js/OffscreenDecodeWorker.js +++ b/html5/js/OffscreenDecodeWorker.js @@ -24,7 +24,7 @@ importScripts("./Constants.js"); // WindowDecoder for each window we have control over: const offscreen_canvas = new Map(); -const image_coding = ["rgb", "rgb32", "rgb24", "jpeg", "png", "png/P", "png/L", "webp"]; +const image_coding = ["rgb", "rgb32", "rgb24", "jpeg", "png", "png/P", "png/L", "webp", "avif"]; const video_coding = ["h264"]; const all_encodings = ["void", "scroll"].concat(image_coding, video_coding);