Skip to content

Commit

Permalink
add avif decoding
Browse files Browse the repository at this point in the history
  • Loading branch information
totaam committed Feb 12, 2022
1 parent 3562c86 commit 29ffa3f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion html5/js/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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.");
Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion html5/js/DecodeWorker.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion html5/js/OffscreenDecodeWorker.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 29ffa3f

Please sign in to comment.