[Spice-commits] 8 commits - quic.js
Jeremy White
jwhite at kemper.freedesktop.org
Mon Sep 24 09:09:30 PDT 2012
quic.js | 726 ++++++++++++++++++++++++++++++++++++++++------------------------
1 file changed, 464 insertions(+), 262 deletions(-)
New commits:
commit 3e91256b817d17d4f3b9db5cc15869d25a4de008
Author: Aric Stewart <aric at codeweavers.com>
Date: Mon Sep 24 10:53:06 2012 -0500
quic: implemenet QUIC_IMAGE_TYPE_RGBA decoding
Signed-off-by: Aric Stewart <aric at codeweavers.com>
diff --git a/quic.js b/quic.js
index 26a021f..9bb9f47 100644
--- a/quic.js
+++ b/quic.js
@@ -942,6 +942,245 @@ QuicEncoder.prototype.quic_rgb32_uncompress_row = function (prev_row, cur_row)
}
}
+QuicEncoder.prototype.quic_four_uncompress_row0_seg = function (channel, i,
+ correlate_row, cur_row, end, waitmask,
+ bpc, bpc_mask)
+{
+ var stopidx;
+ var a;
+
+ if (i == 0) {
+ a = golomb_decoding_8bpc(channel.buckets_ptrs[correlate_row.zero].bestcode, this.io_word);
+ correlate_row.row[0] = a.rc;
+ cur_row[rgb32_pixel_pad] = family_8bpc.xlatL2U[a.rc];
+ this.decode_eatbits(a.codewordlen);
+
+ if (channel.state.waitcnt) {
+ --channel.state.waitcnt;
+ } else {
+ channel.state.waitcnt = (channel.state.tabrand() & waitmask);
+ channel.buckets_ptrs[correlate_row.zero].update_model_8bpc(channel.state, correlate_row.row[0], bpc);
+ }
+ stopidx = ++i + channel.state.waitcnt;
+ } else {
+ stopidx = i + channel.state.waitcnt;
+ }
+
+ while (stopidx < end) {
+ var pbucket;
+
+ for (; i <= stopidx; i++) {
+ pbucket = channel.buckets_ptrs[correlate_row.row[i - 1]];
+
+ a = golomb_decoding_8bpc(pbucket.bestcode, this.io_word);
+ correlate_row.row[i] = a.rc;
+ cur_row[(i*rgb32_pixel_size)+rgb32_pixel_pad] = (family_8bpc.xlatL2U[a.rc] + cur_row[((i-1)*rgb32_pixel_size)+rgb32_pixel_pad]) & bpc_mask;
+ this.decode_eatbits(a.codewordlen);
+ }
+
+ pbucket.update_model_8bpc(channel.state, correlate_row.row[stopidx], bpc);
+
+ stopidx = i + (channel.state.tabrand() & waitmask);
+ }
+
+ for (; i < end; i++) {
+ a = golomb_decoding_8bpc(channel.buckets_ptrs[correlate_row.row[i-1]].bestcode, this.io_word);
+
+ correlate_row.row[i] = a.rc;
+ cur_row[(i*rgb32_pixel_size)+rgb32_pixel_pad] = (family_8bpc.xlatL2U[a.rc] + cur_row[((i-1)*rgb32_pixel_size)+rgb32_pixel_pad]) & bpc_mask;
+ this.decode_eatbits(a.codewordlen);
+ }
+ channel.state.waitcnt = stopidx - end;
+}
+
+QuicEncoder.prototype.quic_four_uncompress_row0 = function(channel, cur_row)
+{
+ var bpc = 8;
+ var bpc_mask = 0xff;
+ var correlate_row = channel.correlate_row;
+ var pos = 0;
+ var width = this.width;
+
+ while ((wmimax > channel.state.wmidx) && (channel.state.wmileft <= width)) {
+ if (channel.state.wmileft) {
+ this.quic_four_uncompress_row0_seg(channel, pos, correlate_row, cur_row,
+ pos + channel.state.wmileft, bppmask[channel.state.wmidx],
+ bpc, bpc_mask);
+ pos += channel.state.wmileft;
+ width -= channel.state.wmileft;
+ }
+
+ channel.state.wmidx++;
+ channel.state.set_wm_trigger();
+ channel.state.wmileft = wminext;
+ }
+
+ if (width) {
+ this.quic_four_uncompress_row0_seg(channel, pos, correlate_row, cur_row, pos + width,
+ bppmask[channel.state.wmidx], bpc, bpc_mask);
+ if (wmimax > channel.state.wmidx) {
+ channel.state.wmileft -= width;
+ }
+ }
+}
+
+QuicEncoder.prototype.quic_four_uncompress_row_seg = function (channel,
+ correlate_row, prev_row, cur_row, i,
+ end, bpc, bpc_mask)
+{
+ var waitmask = bppmask[channel.state.wmidx];
+ var stopidx;
+
+ var run_index = 0;
+ var run_end;
+
+ var a;
+
+ if (i == 0) {
+ a = golomb_decoding_8bpc(channel.buckets_ptrs[correlate_row.zero].bestcode, this.io_word);
+
+ correlate_row.row[0] = a.rc
+ cur_row[rgb32_pixel_pad] = (family_8bpc.xlatL2U[a.rc] + prev_row[rgb32_pixel_pad]) & bpc_mask;
+ this.decode_eatbits(a.codewordlen);
+
+ if (channel.state.waitcnt) {
+ --channel.state.waitcnt;
+ } else {
+ channel.state.waitcnt = (channel.state.tabrand() & waitmask);
+ channel.buckets_ptrs[correlate_row.zero].update_model_8bpc(channel.state, correlate_row.row[0], bpc);
+ }
+ stopidx = ++i + channel.state.waitcnt;
+ } else {
+ stopidx = i + channel.state.waitcnt;
+ }
+ for (;;) {
+ var rc = 0;
+ while (stopidx < end && !rc) {
+ var pbucket;
+ for (; i <= stopidx && !rc; i++) {
+ var pixel = i * rgb32_pixel_size;
+ var pixelm1 = (i-1) * rgb32_pixel_size;
+ var pixelm2 = (i-2) * rgb32_pixel_size;
+
+ if (prev_row[pixelm1+rgb32_pixel_pad] == prev_row[pixel+rgb32_pixel_pad])
+ {
+ if (run_index != i && i > 2 && cur_row[pixelm1+rgb32_pixel_pad] == cur_row[pixelm2+rgb32_pixel_pad])
+ {
+ /* do run */
+ channel.state.waitcnt = stopidx - i;
+ run_index = i;
+
+ run_end = i + this.decode_run(channel.state);
+
+ for (; i < run_end; i++) {
+ var pixel = i * rgb32_pixel_size;
+ var pixelm1 = (i-1) * rgb32_pixel_size;
+ cur_row[pixel+rgb32_pixel_pad] = cur_row[pixelm1+rgb32_pixel_pad];
+ }
+
+ if (i == end) {
+ return;
+ }
+ else
+ {
+ stopidx = i + channel.state.waitcnt;
+ rc = 1;
+ break;
+ }
+ }
+ }
+
+ pbucket = channel.buckets_ptrs[correlate_row.row[i - 1]];
+ a = golomb_decoding_8bpc(pbucket.bestcode, this.io_word);
+ correlate_row.row[i] = a.rc
+ cur_row[pixel+rgb32_pixel_pad] = (family_8bpc.xlatL2U[a.rc] + ((cur_row[pixelm1+rgb32_pixel_pad] + prev_row[pixel+rgb32_pixel_pad]) >> 1)) & bpc_mask;
+ this.decode_eatbits(a.codewordlen);
+ }
+ if (rc)
+ break;
+
+ pbucket.update_model_8bpc(channel.state, correlate_row.row[stopidx], bpc);
+
+ stopidx = i + (channel.state.tabrand() & waitmask);
+ }
+
+ for (; i < end && !rc; i++) {
+ var pixel = i * rgb32_pixel_size;
+ var pixelm1 = (i-1) * rgb32_pixel_size;
+ var pixelm2 = (i-2) * rgb32_pixel_size;
+ if (prev_row[pixelm1+rgb32_pixel_pad] == prev_row[pixel+rgb32_pixel_pad])
+ {
+ if (run_index != i && i > 2 && cur_row[pixelm1+rgb32_pixel_pad] == cur_row[pixelm2+rgb32_pixel_pad])
+ {
+ /* do run */
+ channel.state.waitcnt = stopidx - i;
+ run_index = i;
+
+ run_end = i + this.decode_run(channel.state);
+
+ for (; i < run_end; i++) {
+ var pixel = i * rgb32_pixel_size;
+ var pixelm1 = (i-1) * rgb32_pixel_size;
+ cur_row[pixel+rgb32_pixel_pad] = cur_row[pixelm1+rgb32_pixel_pad];
+ }
+
+ if (i == end) {
+ return;
+ }
+ else
+ {
+ stopidx = i + channel.state.waitcnt;
+ rc = 1;
+ break;
+ }
+ }
+ }
+
+ a = golomb_decoding_8bpc(channel.buckets_ptrs[correlate_row.row[i-1]].bestcode, this.io_word);
+ correlate_row.row[i] = a.rc;
+ cur_row[pixel+rgb32_pixel_pad] = (family_8bpc.xlatL2U[a.rc] + ((cur_row[pixelm1+rgb32_pixel_pad] + prev_row[pixel+rgb32_pixel_pad]) >> 1)) & bpc_mask;
+ this.decode_eatbits(a.codewordlen);
+ }
+
+ if (!rc)
+ {
+ channel.state.waitcnt = stopidx - end;
+ return;
+ }
+ }
+}
+
+QuicEncoder.prototype.quic_four_uncompress_row = function(channel, prev_row,
+ cur_row)
+{
+ var bpc = 8;
+ var bpc_mask = 0xff;
+ var correlate_row = channel.correlate_row;
+ var pos = 0;
+ var width = this.width;
+
+ while ((wmimax > channel.state.wmidx) && (channel.state.wmileft <= width)) {
+ if (channel.state.wmileft) {
+ this.quic_four_uncompress_row_seg(channel, correlate_row, prev_row, cur_row, pos,
+ pos + channel.state.wmileft, bpc, bpc_mask);
+ pos += channel.state.wmileft;
+ width -= channel.state.wmileft;
+ }
+
+ channel.state.wmidx++;
+ channel.state.set_wm_trigger();
+ channel.state.wmileft = wminext;
+ }
+
+ if (width) {
+ this.quic_four_uncompress_row_seg(channel, correlate_row, prev_row, cur_row, pos,
+ pos + width, bpc, bpc_mask);
+ if (wmimax > channel.state.wmidx) {
+ channel.state.wmileft -= width;
+ }
+ }
+}
+
/* We need to be generating rgb32 or rgba */
QuicEncoder.prototype.quic_decode = function(buf, stride)
{
@@ -973,8 +1212,28 @@ QuicEncoder.prototype.quic_decode = function(buf, stride)
return false;
break;
case QUIC_IMAGE_TYPE_RGBA:
- console.log("quic: unsupported output format\n");
- return false;
+ this.channels[0].correlate_row.zero = 0;
+ this.channels[1].correlate_row.zero = 0;
+ this.channels[2].correlate_row.zero = 0;
+ this.quic_rgb32_uncompress_row0(buf);
+
+ this.channels[3].correlate_row.zero = 0;
+ this.quic_four_uncompress_row0(this.channels[3], buf);
+
+ this.rows_completed++;
+ for (row = 1; row < this.height; row++) {
+ var prev = buf;
+ buf = prev.subarray(stride);
+
+ this.channels[0].correlate_row.zero = this.channels[0].correlate_row.row[0];
+ this.channels[1].correlate_row.zero = this.channels[1].correlate_row.row[0];
+ this.channels[2].correlate_row.zero = this.channels[2].correlate_row.row[0];
+ this.quic_rgb32_uncompress_row(prev, buf);
+
+ this.channels[3].correlate_row.zero = this.channels[3].correlate_row.row[0];
+ this.quic_four_uncompress_row(encoder.channels[3], prev, buf);
+ this.rows_completed++;
+ }
break;
case QUIC_IMAGE_TYPE_GRAY:
@@ -995,7 +1254,8 @@ QuicEncoder.prototype.simple_quic_decode = function(buf)
var stride = 4; /* FIXME - proper stride calc please */
if (!this.quic_decode_begin(buf))
return undefined;
- if (this.type != QUIC_IMAGE_TYPE_RGB32 && this.type != QUIC_IMAGE_TYPE_RGB24)
+ if (this.type != QUIC_IMAGE_TYPE_RGB32 && this.type != QUIC_IMAGE_TYPE_RGB24
+ && this.type != QUIC_IMAGE_TYPE_RGBA)
return undefined;
var out = new Uint8Array(this.width*this.height*4);
out[0] = 69;
@@ -1041,7 +1301,7 @@ function convert_spice_quic_to_web(context, spice_quic)
if (spice_quic.type !== QUIC_IMAGE_TYPE_RGBA)
ret.data[i + 3] = 255;
else
- ret.data[i + 3] = spice_quic.outptr[i + 3];
+ ret.data[i + 3] = 255 - spice_quic.outptr[i + 3];
}
return ret;
}
commit 8054befaec9d4bb2e03af1d446237a0bd32fadec
Author: Aric Stewart <aric at codeweavers.com>
Date: Mon Sep 24 10:52:48 2012 -0500
quic: generalize QuicEncoder.prototype.decode_run
Signed-off-by: Aric Stewart <aric at codeweavers.com>
diff --git a/quic.js b/quic.js
index 699820f..26a021f 100644
--- a/quic.js
+++ b/quic.js
@@ -775,7 +775,7 @@ QuicEncoder.prototype.quic_rgb32_uncompress_row_seg = function( prev_row, cur_ro
/* do run */
this.rgb_state.waitcnt = stopidx - i;
run_index = i;
- run_end = i + this.decode_run();
+ run_end = i + this.decode_run(this.rgb_state);
for (; i < run_end; i++) {
var pixel = i * rgb32_pixel_size;
@@ -833,7 +833,7 @@ QuicEncoder.prototype.quic_rgb32_uncompress_row_seg = function( prev_row, cur_ro
/* do run */
this.rgb_state.waitcnt = stopidx - i;
run_index = i;
- run_end = i + this.decode_run();
+ run_end = i + this.decode_run(this.rgb_state);
for (; i < run_end; i++) {
var pixel = i * rgb32_pixel_size;
@@ -875,7 +875,7 @@ QuicEncoder.prototype.quic_rgb32_uncompress_row_seg = function( prev_row, cur_ro
}
}
-QuicEncoder.prototype.decode_run = function()
+QuicEncoder.prototype.decode_run = function(state)
{
var runlen = 0;
@@ -885,11 +885,11 @@ QuicEncoder.prototype.decode_run = function()
var temp = zeroLUT[x];
for (hits = 1; hits <= temp; hits++) {
- runlen += this.rgb_state.melcorder;
+ runlen += state.melcorder;
- if (this.rgb_state.melcstate < 32) {
- this.rgb_state.melclen = J[++this.rgb_state.melcstate];
- this.rgb_state.melcorder = (1 << this.rgb_state.melclen);
+ if (state.melcstate < 32) {
+ state.melclen = J[++state.melcstate];
+ state.melcorder = (1 << state.melclen);
}
}
if (temp != 8) {
@@ -900,14 +900,14 @@ QuicEncoder.prototype.decode_run = function()
this.decode_eatbits(8);
} while (true);
- if (this.rgb_state.melclen) {
- runlen += this.io_word >>> (32 - this.rgb_state.melclen);
- this.decode_eatbits(this.rgb_state.melclen);
+ if (state.melclen) {
+ runlen += this.io_word >>> (32 - state.melclen);
+ this.decode_eatbits(state.melclen);
}
- if (this.rgb_state.melcstate) {
- this.rgb_state.melclen = J[--this.rgb_state.melcstate];
- this.rgb_state.melcorder = (1 << this.rgb_state.melclen);
+ if (state.melcstate) {
+ state.melclen = J[--state.melcstate];
+ state.melcorder = (1 << state.melclen);
}
return runlen;
commit bf15d1622106928eae792fee6e254173e87811de
Author: Aric Stewart <aric at codeweavers.com>
Date: Mon Sep 24 10:50:08 2012 -0500
quic javascript code cleanups
check with strict but do not enable it.
Signed-off-by: Aric Stewart <aric at codeweavers.com>
diff --git a/quic.js b/quic.js
index 15d2dbf..699820f 100644
--- a/quic.js
+++ b/quic.js
@@ -1,3 +1,5 @@
+/*"use strict";*/
+/* use strict is commented out because it results in a 5x slowdone in chrome */
/*
* Copyright (C) 2012 by Jeremy P. White <jwhite at codeweavers.com>
* Copyright (C) 2012 by Aric Stewart <aric at codeweavers.com>
@@ -188,7 +190,6 @@ function family_init(family, bpc, limit)
function quic_image_bpc(type)
{
- var bpc;
switch (type) {
case QUIC_IMAGE_TYPE_GRAY:
return 8;
@@ -224,20 +225,17 @@ function golomb_decoding_8bpc(l, bits)
{
var rc;
var cwlen;
- var usBits = bits;
if (bits < 0 || bits > family_8bpc.notGRprefixmask[l])
{
var zeroprefix = cnt_l_zeroes(bits);
cwlen = zeroprefix + 1 + l;
- var cwm = 32 - cwlen;
- rc = (zeroprefix << l) | (bits >> cwm) & bppmask[l];
+ rc = (zeroprefix << l) | (bits >> (32-cwlen)) & bppmask[l];
}
else
{
cwlen = family_8bpc.notGRcwlen[l];
- var cwm = 32 - cwlen;
- rc = family_8bpc.nGRcodewords[l] + ((bits >> cwm) & bppmask[family_8bpc.notGRsuffixlen[l]]);
+ rc = family_8bpc.nGRcodewords[l] + ((bits >> (32-cwlen)) & bppmask[family_8bpc.notGRsuffixlen[l]]);
}
return {'codewordlen':cwlen, 'rc':rc};
}
@@ -253,44 +251,42 @@ function golomb_code_len_8bpc(n, l)
function QuicModel(bpc)
{
- var bsize;
var bstart;
var bend = 0;
- var repcntr;
this.levels = 0x1 << bpc;
this.n_buckets_ptrs = 0;
switch (evol) {
- case 1:
- this.repfirst = 3;
- this.firstsize = 1;
- this.repnext = 2;
- this.mulsize = 2;
- break;
- case 3:
- this.repfirst = 1;
- this.firstsize = 1;
- this.repnext = 1;
- this.mulsize = 2;
- break;
- case 5:
- this.repfirst = 1;
- this.firstsize = 1;
- this.repnext = 1;
- this.mulsize = 4;
- break;
- case 0:
- case 2:
- case 4:
- console.log("quic: findmodelparams(): evol value obsolete!!!\n");
- default:
- console.log("quic: findmodelparams(): evol out of range!!!\n");
+ case 1:
+ this.repfirst = 3;
+ this.firstsize = 1;
+ this.repnext = 2;
+ this.mulsize = 2;
+ break;
+ case 3:
+ this.repfirst = 1;
+ this.firstsize = 1;
+ this.repnext = 1;
+ this.mulsize = 2;
+ break;
+ case 5:
+ this.repfirst = 1;
+ this.firstsize = 1;
+ this.repnext = 1;
+ this.mulsize = 4;
+ break;
+ case 0:
+ case 2:
+ case 4:
+ console.log("quic: findmodelparams(): evol value obsolete!!!\n");
+ default:
+ console.log("quic: findmodelparams(): evol out of range!!!\n");
}
this.n_buckets = 0;
- repcntr = this.repfirst + 1;
- bsize = this.firstsize;
+ var repcntr = this.repfirst + 1;
+ var bsize = this.firstsize;
do {
if (this.n_buckets) {
@@ -311,7 +307,6 @@ function QuicModel(bpc)
if (!this.n_buckets_ptrs) {
this.n_buckets_ptrs = this.levels;
-
}
(this.n_buckets)++;
@@ -345,11 +340,9 @@ QuicBucket.prototype = {
update_model_8bpc : function (state, curval, bpp)
{
var i;
- var bestcode;
- var bestcodelen;
- bestcode = bpp - 1;
- bestcodelen = (this.counters[bestcode] += golomb_code_len_8bpc(curval, bestcode));
+ var bestcode = bpp - 1;
+ var bestcodelen = (this.counters[bestcode] += golomb_code_len_8bpc(curval, bestcode));
for (i = bpp - 2; i >= 0; i--) {
var ithcodelen = (this.counters[i] += golomb_code_len_8bpc(curval, i));
@@ -380,12 +373,12 @@ QuicFamilyStat.prototype = {
fill_model_structures : function(model)
{
- var bsize, bstart, repcntr;
+ var bstart;
var bend = 0;
var bnumber = 0;
- repcntr = model.repfirst + 1;
- bsize = model.firstsize;
+ var repcntr = model.repfirst + 1;
+ var bsize = model.firstsize;
do {
if (bnumber) {
@@ -438,15 +431,14 @@ QuicChannel.prototype = {
reste : function (bpc)
{
+ var j;
this.correlate_row = { zero: 0 , row: []};
if (bpc == 8) {
- var j;
for (j = 0; j < this.model_8bpc.n_buckets; j++)
this.family_stat_8bpc.buckets_buf[j].reste(7);
this.buckets_ptrs = this.family_stat_8bpc.buckets_ptrs;
} else if (bpc == 5) {
- var j;
for (j = 0; j < this.model_5bpc.n_buckets; j++)
this.family_stat_8bpc.buckets_buf[j].reste(4);
this.buckets_ptrs = this.family_stat_5bpc.buckets_ptrs;
@@ -639,10 +631,9 @@ QuicEncoder.prototype.quic_rgb32_uncompress_row0_seg = function (i, cur_row, end
var stopidx;
var n_channels = 3;
var c;
+ var a;
if (!i) {
- var a;
-
cur_row[rgb32_pixel_pad] = 0;
c = 0;
do
@@ -670,8 +661,6 @@ QuicEncoder.prototype.quic_rgb32_uncompress_row0_seg = function (i, cur_row, end
while (stopidx < end) {
for (; i <= stopidx; i++) {
- var a;
-
cur_row[(i* rgb32_pixel_size)+rgb32_pixel_pad] = 0;
c = 0;
do
@@ -691,8 +680,6 @@ QuicEncoder.prototype.quic_rgb32_uncompress_row0_seg = function (i, cur_row, end
}
for (; i < end; i++) {
- var a;
-
cur_row[(i* rgb32_pixel_size)+rgb32_pixel_pad] = 0;
c = 0;
do
@@ -911,15 +898,13 @@ QuicEncoder.prototype.decode_run = function()
break;
}
this.decode_eatbits(8);
- } while (1);
-
+ } while (true);
if (this.rgb_state.melclen) {
runlen += this.io_word >>> (32 - this.rgb_state.melclen);
this.decode_eatbits(this.rgb_state.melclen);
}
-
if (this.rgb_state.melcstate) {
this.rgb_state.melclen = J[--this.rgb_state.melcstate];
this.rgb_state.melcorder = (1 << this.rgb_state.melclen);
@@ -961,8 +946,6 @@ QuicEncoder.prototype.quic_rgb32_uncompress_row = function (prev_row, cur_row)
QuicEncoder.prototype.quic_decode = function(buf, stride)
{
var row;
- var prev;
- var cur = buf;
switch (this.type)
{
@@ -971,17 +954,17 @@ QuicEncoder.prototype.quic_decode = function(buf, stride)
this.channels[0].correlate_row.zero = 0;
this.channels[1].correlate_row.zero = 0;
this.channels[2].correlate_row.zero = 0;
- this.quic_rgb32_uncompress_row0(cur);
+ this.quic_rgb32_uncompress_row0(buf);
this.rows_completed++;
for (row = 1; row < this.height; row++)
{
- prev = cur;
- cur = prev.subarray(stride);
+ var prev = buf;
+ buf = prev.subarray(stride);
this.channels[0].correlate_row.zero = this.channels[0].correlate_row.row[0];
this.channels[1].correlate_row.zero = this.channels[1].correlate_row.row[0];
this.channels[2].correlate_row.zero = this.channels[2].correlate_row.row[0];
- this.quic_rgb32_uncompress_row(prev, cur);
+ this.quic_rgb32_uncompress_row(prev, buf);
this.rows_completed++;
};
break;
commit a1ef6e3c146fac101ddd855434107701ccfa38fd
Author: Aric Stewart <aric at codeweavers.com>
Date: Mon Sep 24 10:49:53 2012 -0500
QUIC_IMAGE_TYPE_RGB24 decodes the same as QUIC_IMAGE_TYPE_RGB32
Signed-off-by: Aric Stewart <aric at codeweavers.com>
diff --git a/quic.js b/quic.js
index 138b052..15d2dbf 100644
--- a/quic.js
+++ b/quic.js
@@ -957,6 +957,7 @@ QuicEncoder.prototype.quic_rgb32_uncompress_row = function (prev_row, cur_row)
}
}
+/* We need to be generating rgb32 or rgba */
QuicEncoder.prototype.quic_decode = function(buf, stride)
{
var row;
@@ -966,6 +967,7 @@ QuicEncoder.prototype.quic_decode = function(buf, stride)
switch (this.type)
{
case QUIC_IMAGE_TYPE_RGB32:
+ case QUIC_IMAGE_TYPE_RGB24:
this.channels[0].correlate_row.zero = 0;
this.channels[1].correlate_row.zero = 0;
this.channels[2].correlate_row.zero = 0;
@@ -983,10 +985,6 @@ QuicEncoder.prototype.quic_decode = function(buf, stride)
this.rows_completed++;
};
break;
- case QUIC_IMAGE_TYPE_RGB24:
- console.log("quic: unsupported output format\n");
- return false;
- break;
case QUIC_IMAGE_TYPE_RGB16:
console.log("quic: unsupported output format\n");
return false;
@@ -1014,7 +1012,7 @@ QuicEncoder.prototype.simple_quic_decode = function(buf)
var stride = 4; /* FIXME - proper stride calc please */
if (!this.quic_decode_begin(buf))
return undefined;
- if (this.type != QUIC_IMAGE_TYPE_RGB32 && this.type != QUIC_IMAGE_TYPE_RGBA)
+ if (this.type != QUIC_IMAGE_TYPE_RGB32 && this.type != QUIC_IMAGE_TYPE_RGB24)
return undefined;
var out = new Uint8Array(this.width*this.height*4);
out[0] = 69;
@@ -1057,7 +1055,7 @@ function convert_spice_quic_to_web(context, spice_quic)
ret.data[i + 0] = spice_quic.outptr[i + 2];
ret.data[i + 1] = spice_quic.outptr[i + 1];
ret.data[i + 2] = spice_quic.outptr[i + 0];
- if (spice_quic.type == 4)
+ if (spice_quic.type !== QUIC_IMAGE_TYPE_RGBA)
ret.data[i + 3] = 255;
else
ret.data[i + 3] = spice_quic.outptr[i + 3];
commit cd9f5b52ef09eea93e7bf9e5283af18d779059e4
Author: Aric Stewart <aric at codeweavers.com>
Date: Mon Sep 24 10:49:35 2012 -0500
remove function find_bucket_8bpc
removing the function call overhead improves performance
Signed-off-by: Aric Stewart <aric at codeweavers.com>
diff --git a/quic.js b/quic.js
index 0e33610..138b052 100644
--- a/quic.js
+++ b/quic.js
@@ -436,11 +436,6 @@ function QuicChannel(model_8bpc, model_5bpc)
QuicChannel.prototype = {
- find_bucket_8bpc : function(val)
- {
- return this.buckets_ptrs[val];
- },
-
reste : function (bpc)
{
this.correlate_row = { zero: 0 , row: []};
@@ -652,7 +647,7 @@ QuicEncoder.prototype.quic_rgb32_uncompress_row0_seg = function (i, cur_row, end
c = 0;
do
{
- a = golomb_decoding_8bpc(this.channels[c].find_bucket_8bpc(this.channels[c].correlate_row.zero).bestcode, this.io_word);
+ a = golomb_decoding_8bpc(this.channels[c].buckets_ptrs[this.channels[c].correlate_row.zero].bestcode, this.io_word);
this.channels[c].correlate_row.row[0] = a.rc;
cur_row[2-c] = (family_8bpc.xlatL2U[a.rc]&0xFF);
this.decode_eatbits(a.codewordlen);
@@ -665,7 +660,7 @@ QuicEncoder.prototype.quic_rgb32_uncompress_row0_seg = function (i, cur_row, end
c = 0;
do
{
- this.channels[c].find_bucket_8bpc(this.channels[c].correlate_row.zero).update_model_8bpc(this.rgb_state, this.channels[c].correlate_row.row[0], bpc);
+ this.channels[c].buckets_ptrs[this.channels[c].correlate_row.zero].update_model_8bpc(this.rgb_state, this.channels[c].correlate_row.row[0], bpc);
} while (++c < n_channels);
}
stopidx = ++i + this.rgb_state.waitcnt;
@@ -681,7 +676,7 @@ QuicEncoder.prototype.quic_rgb32_uncompress_row0_seg = function (i, cur_row, end
c = 0;
do
{
- a = golomb_decoding_8bpc(this.channels[c].find_bucket_8bpc(this.channels[c].correlate_row.row[i - 1]).bestcode, this.io_word);
+ a = golomb_decoding_8bpc(this.channels[c].buckets_ptrs[this.channels[c].correlate_row.row[i - 1]].bestcode, this.io_word);
this.channels[c].correlate_row.row[i] = a.rc;
cur_row[(i* rgb32_pixel_size)+(2-c)] = (family_8bpc.xlatL2U[a.rc] + cur_row[((i-1) * rgb32_pixel_size) + (2-c)]) & bpc_mask;
this.decode_eatbits(a.codewordlen);
@@ -690,7 +685,7 @@ QuicEncoder.prototype.quic_rgb32_uncompress_row0_seg = function (i, cur_row, end
c = 0;
do
{
- this.channels[c].find_bucket_8bpc(this.channels[c].correlate_row.row[stopidx - 1]).update_model_8bpc(this.rgb_state, this.channels[c].correlate_row.row[stopidx], bpc);
+ this.channels[c].buckets_ptrs[this.channels[c].correlate_row.row[stopidx - 1]].update_model_8bpc(this.rgb_state, this.channels[c].correlate_row.row[stopidx], bpc);
} while (++c < n_channels);
stopidx = i + (this.rgb_state.tabrand() & waitmask);
}
@@ -702,7 +697,7 @@ QuicEncoder.prototype.quic_rgb32_uncompress_row0_seg = function (i, cur_row, end
c = 0;
do
{
- a = golomb_decoding_8bpc(this.channels[c].find_bucket_8bpc(this.channels[c].correlate_row.row[i - 1]).bestcode, this.io_word);
+ a = golomb_decoding_8bpc(this.channels[c].buckets_ptrs[this.channels[c].correlate_row.row[i - 1]].bestcode, this.io_word);
this.channels[c].correlate_row.row[i] = a.rc;
cur_row[(i* rgb32_pixel_size)+(2-c)] = (family_8bpc.xlatL2U[a.rc] + cur_row[((i-1) * rgb32_pixel_size) + (2-c)]) & bpc_mask;
this.decode_eatbits(a.codewordlen);
@@ -759,7 +754,7 @@ QuicEncoder.prototype.quic_rgb32_uncompress_row_seg = function( prev_row, cur_ro
c = 0;
do {
- a = golomb_decoding_8bpc(this.channels[c].find_bucket_8bpc(this.channels[c].correlate_row.zero).bestcode, this.io_word);
+ a = golomb_decoding_8bpc(this.channels[c].buckets_ptrs[this.channels[c].correlate_row.zero].bestcode, this.io_word);
this.channels[c].correlate_row.row[0] = a.rc;
cur_row[2-c] = (family_8bpc.xlatL2U[this.channels[c].correlate_row.row[0]] + prev_row[2-c]) & bpc_mask;
this.decode_eatbits(a.codewordlen);
@@ -771,7 +766,7 @@ QuicEncoder.prototype.quic_rgb32_uncompress_row_seg = function( prev_row, cur_ro
this.rgb_state.waitcnt = (this.rgb_state.tabrand() & waitmask);
c = 0;
do {
- this.channels[c].find_bucket_8bpc(this.channels[c].correlate_row.zero).update_model_8bpc(this.rgb_state, this.channels[c].correlate_row.row[0], bpc);
+ this.channels[c].buckets_ptrs[this.channels[c].correlate_row.zero].update_model_8bpc(this.rgb_state, this.channels[c].correlate_row.row[0], bpc);
} while (++c < n_channels);
}
stopidx = ++i + this.rgb_state.waitcnt;
@@ -779,7 +774,7 @@ QuicEncoder.prototype.quic_rgb32_uncompress_row_seg = function( prev_row, cur_ro
stopidx = i + this.rgb_state.waitcnt;
}
for (;;) {
- rc = 0;
+ var rc = 0;
while (stopidx < end && !rc) {
for (; i <= stopidx && !rc; i++) {
var pixel = i * rgb32_pixel_size;
@@ -822,7 +817,7 @@ QuicEncoder.prototype.quic_rgb32_uncompress_row_seg = function( prev_row, cur_ro
var cc = this.channels[c];
var cr = cc.correlate_row;
- a = golomb_decoding_8bpc(cc.find_bucket_8bpc(cr.row[i-1]).bestcode, this.io_word);
+ a = golomb_decoding_8bpc(cc.buckets_ptrs[cr.row[i-1]].bestcode, this.io_word);
cr.row[i] = a.rc;
cur_row[pixel+(2-c)] = (family_8bpc.xlatL2U[a.rc] + ((cur_row[pixelm1+(2-c)] + prev_row[pixel+(2-c)]) >> 1)) & bpc_mask;
this.decode_eatbits(a.codewordlen);
@@ -833,7 +828,7 @@ QuicEncoder.prototype.quic_rgb32_uncompress_row_seg = function( prev_row, cur_ro
c = 0;
do {
- this.channels[c].find_bucket_8bpc(this.channels[c].correlate_row.row[stopidx - 1]).update_model_8bpc(this.rgb_state, this.channels[c].correlate_row.row[stopidx], bpc);
+ this.channels[c].buckets_ptrs[this.channels[c].correlate_row.row[stopidx - 1]].update_model_8bpc(this.rgb_state, this.channels[c].correlate_row.row[stopidx], bpc);
} while (++c < n_channels);
stopidx = i + (this.rgb_state.tabrand() & waitmask);
@@ -878,7 +873,7 @@ QuicEncoder.prototype.quic_rgb32_uncompress_row_seg = function( prev_row, cur_ro
c = 0;
do
{
- a = golomb_decoding_8bpc(this.channels[c].find_bucket_8bpc(this.channels[c].correlate_row.row[i-1]).bestcode, this.io_word);
+ a = golomb_decoding_8bpc(this.channels[c].buckets_ptrs[this.channels[c].correlate_row.row[i-1]].bestcode, this.io_word);
this.channels[c].correlate_row.row[i] = a.rc;
cur_row[pixel+(2-c)] = (family_8bpc.xlatL2U[a.rc] + ((cur_row[pixelm1+(2-c)] + prev_row[pixel+(2-c)]) >> 1)) & bpc_mask;
this.decode_eatbits(a.codewordlen);
commit 8306bbab2c5f72edc6a5c5cdd8740ec70c388f40
Author: Aric Stewart <aric at codeweavers.com>
Date: Mon Sep 24 10:49:18 2012 -0500
fold do_run into uncompress
eliminates a function call and many object references for performance
Signed-off-by: Aric Stewart <aric at codeweavers.com>
diff --git a/quic.js b/quic.js
index 0bae57e..0e33610 100644
--- a/quic.js
+++ b/quic.js
@@ -748,16 +748,12 @@ QuicEncoder.prototype.quic_rgb32_uncompress_row_seg = function( prev_row, cur_ro
var waitmask = bppmask[this.rgb_state.wmidx];
var a;
- var b = {
- i: i,
- run_index: 0,
- stopidx: 0,
- run_end: 0,
- end : end
- };
+ var run_index = 0;
+ var stopidx = 0;
+ var run_end = 0;
var c;
- if (!b.i)
+ if (!i)
{
cur_row[rgb32_pixel_pad] = 0;
@@ -778,25 +774,45 @@ QuicEncoder.prototype.quic_rgb32_uncompress_row_seg = function( prev_row, cur_ro
this.channels[c].find_bucket_8bpc(this.channels[c].correlate_row.zero).update_model_8bpc(this.rgb_state, this.channels[c].correlate_row.row[0], bpc);
} while (++c < n_channels);
}
- b.stopidx = ++b.i + this.rgb_state.waitcnt;
+ stopidx = ++i + this.rgb_state.waitcnt;
} else {
- b.stopidx = b.i + this.rgb_state.waitcnt;
+ stopidx = i + this.rgb_state.waitcnt;
}
for (;;) {
- b.rc = 0;
- while (b.stopidx < b.end && !b.rc) {
- for (; b.i <= b.stopidx && !b.rc; b.i++) {
- var pixel = b.i * rgb32_pixel_size;
- var pixelm1 = (b.i-1) * rgb32_pixel_size;
- var pixelm2 = (b.i-2) * rgb32_pixel_size;
+ rc = 0;
+ while (stopidx < end && !rc) {
+ for (; i <= stopidx && !rc; i++) {
+ var pixel = i * rgb32_pixel_size;
+ var pixelm1 = (i-1) * rgb32_pixel_size;
+ var pixelm2 = (i-2) * rgb32_pixel_size;
if ( prev_row[pixelm1+rgb32_pixel_r] == prev_row[pixel+rgb32_pixel_r] && prev_row[pixelm1+rgb32_pixel_g] == prev_row[pixel+rgb32_pixel_g] && prev_row[pixelm1 + rgb32_pixel_b] == prev_row[pixel+rgb32_pixel_b])
{
- if (b.run_index != b.i && b.i > 2 && (cur_row[pixelm1+rgb32_pixel_r] == cur_row[pixelm2+rgb32_pixel_r] && cur_row[pixelm1+rgb32_pixel_g] == cur_row[pixelm2+rgb32_pixel_g] && cur_row[pixelm1+rgb32_pixel_b] == cur_row[pixelm2+rgb32_pixel_b]))
+ if (run_index != i && i > 2 && (cur_row[pixelm1+rgb32_pixel_r] == cur_row[pixelm2+rgb32_pixel_r] && cur_row[pixelm1+rgb32_pixel_g] == cur_row[pixelm2+rgb32_pixel_g] && cur_row[pixelm1+rgb32_pixel_b] == cur_row[pixelm2+rgb32_pixel_b]))
{
- this.do_run(b, cur_row);
- if (b.rc === 2) return;
- else break;
+ /* do run */
+ this.rgb_state.waitcnt = stopidx - i;
+ run_index = i;
+ run_end = i + this.decode_run();
+
+ for (; i < run_end; i++) {
+ var pixel = i * rgb32_pixel_size;
+ var pixelm1 = (i-1) * rgb32_pixel_size;
+ cur_row[pixel+rgb32_pixel_pad] = 0;
+ cur_row[pixel+rgb32_pixel_r] = cur_row[pixelm1+rgb32_pixel_r];
+ cur_row[pixel+rgb32_pixel_g] = cur_row[pixelm1+rgb32_pixel_g];
+ cur_row[pixel+rgb32_pixel_b] = cur_row[pixelm1+rgb32_pixel_b];
+ }
+
+ if (i == end) {
+ return;
+ }
+ else
+ {
+ stopidx = i + this.rgb_state.waitcnt;
+ rc = 1;
+ break;
+ }
}
}
@@ -806,35 +822,55 @@ QuicEncoder.prototype.quic_rgb32_uncompress_row_seg = function( prev_row, cur_ro
var cc = this.channels[c];
var cr = cc.correlate_row;
- a = golomb_decoding_8bpc(cc.find_bucket_8bpc(cr.row[b.i-1]).bestcode, this.io_word);
- cr.row[b.i] = a.rc;
+ a = golomb_decoding_8bpc(cc.find_bucket_8bpc(cr.row[i-1]).bestcode, this.io_word);
+ cr.row[i] = a.rc;
cur_row[pixel+(2-c)] = (family_8bpc.xlatL2U[a.rc] + ((cur_row[pixelm1+(2-c)] + prev_row[pixel+(2-c)]) >> 1)) & bpc_mask;
this.decode_eatbits(a.codewordlen);
} while (++c < n_channels);
}
- if (b.rc)
+ if (rc)
break;
c = 0;
do {
- this.channels[c].find_bucket_8bpc(this.channels[c].correlate_row.row[b.stopidx - 1]).update_model_8bpc(this.rgb_state, this.channels[c].correlate_row.row[b.stopidx], bpc);
+ this.channels[c].find_bucket_8bpc(this.channels[c].correlate_row.row[stopidx - 1]).update_model_8bpc(this.rgb_state, this.channels[c].correlate_row.row[stopidx], bpc);
} while (++c < n_channels);
- b.stopidx = b.i + (this.rgb_state.tabrand() & waitmask);
+ stopidx = i + (this.rgb_state.tabrand() & waitmask);
}
- for (; b.i < b.end && !b.rc; b.i++) {
- var pixel = b.i * rgb32_pixel_size;
- var pixelm1 = (b.i-1) * rgb32_pixel_size;
- var pixelm2 = (b.i-2) * rgb32_pixel_size;
+ for (; i < end && !rc; i++) {
+ var pixel = i * rgb32_pixel_size;
+ var pixelm1 = (i-1) * rgb32_pixel_size;
+ var pixelm2 = (i-2) * rgb32_pixel_size;
if (prev_row[pixelm1+rgb32_pixel_r] == prev_row[pixel+rgb32_pixel_r] && prev_row[pixelm1+rgb32_pixel_g] == prev_row[pixel+rgb32_pixel_g] && prev_row[pixelm1+rgb32_pixel_b] == prev_row[pixel+rgb32_pixel_b])
{
- if (b.run_index != b.i && b.i > 2 && (cur_row[pixelm1+rgb32_pixel_r] == cur_row[pixelm2+rgb32_pixel_r] && cur_row[pixelm1+rgb32_pixel_g] == cur_row[pixelm2+rgb32_pixel_g] && cur_row[pixelm1+rgb32_pixel_b] == cur_row[pixelm2+rgb32_pixel_b]))
+ if (run_index != i && i > 2 && (cur_row[pixelm1+rgb32_pixel_r] == cur_row[pixelm2+rgb32_pixel_r] && cur_row[pixelm1+rgb32_pixel_g] == cur_row[pixelm2+rgb32_pixel_g] && cur_row[pixelm1+rgb32_pixel_b] == cur_row[pixelm2+rgb32_pixel_b]))
{
- this.do_run(b, cur_row);
- if (b.rc==2) return;
- else break;
+ /* do run */
+ this.rgb_state.waitcnt = stopidx - i;
+ run_index = i;
+ run_end = i + this.decode_run();
+
+ for (; i < run_end; i++) {
+ var pixel = i * rgb32_pixel_size;
+ var pixelm1 = (i-1) * rgb32_pixel_size;
+ cur_row[pixel+rgb32_pixel_pad] = 0;
+ cur_row[pixel+rgb32_pixel_r] = cur_row[pixelm1+rgb32_pixel_r];
+ cur_row[pixel+rgb32_pixel_g] = cur_row[pixelm1+rgb32_pixel_g];
+ cur_row[pixel+rgb32_pixel_b] = cur_row[pixelm1+rgb32_pixel_b];
+ }
+
+ if (i == end) {
+ return;
+ }
+ else
+ {
+ stopidx = i + this.rgb_state.waitcnt;
+ rc = 1;
+ break;
+ }
}
}
@@ -842,16 +878,16 @@ QuicEncoder.prototype.quic_rgb32_uncompress_row_seg = function( prev_row, cur_ro
c = 0;
do
{
- a = golomb_decoding_8bpc(this.channels[c].find_bucket_8bpc(this.channels[c].correlate_row.row[b.i-1]).bestcode, this.io_word);
- this.channels[c].correlate_row.row[b.i] = a.rc;
+ a = golomb_decoding_8bpc(this.channels[c].find_bucket_8bpc(this.channels[c].correlate_row.row[i-1]).bestcode, this.io_word);
+ this.channels[c].correlate_row.row[i] = a.rc;
cur_row[pixel+(2-c)] = (family_8bpc.xlatL2U[a.rc] + ((cur_row[pixelm1+(2-c)] + prev_row[pixel+(2-c)]) >> 1)) & bpc_mask;
this.decode_eatbits(a.codewordlen);
} while (++c < n_channels);
}
- if (!b.rc)
+ if (!rc)
{
- this.rgb_state.waitcnt = b.stopidx - b.end;
+ this.rgb_state.waitcnt = stopidx - end;
return;
}
}
@@ -897,30 +933,6 @@ QuicEncoder.prototype.decode_run = function()
return runlen;
}
-QuicEncoder.prototype.do_run = function(b, cur_row)
-{
- this.rgb_state.waitcnt = b.stopidx - b.i;
- b.run_index = b.i;
- b.run_end = b.i + this.decode_run();
-
- for (; b.i < b.run_end; b.i++) {
- var pixel = b.i * rgb32_pixel_size;
- var pixelm1 = (b.i-1) * rgb32_pixel_size;
- cur_row[pixel+rgb32_pixel_pad] = 0;
- cur_row[pixel+rgb32_pixel_r] = cur_row[pixelm1+rgb32_pixel_r];
- cur_row[pixel+rgb32_pixel_g] = cur_row[pixelm1+rgb32_pixel_g];
- cur_row[pixel+rgb32_pixel_b] = cur_row[pixelm1+rgb32_pixel_b];
- }
-
- if (b.i == b.end) {
- b.rc = 2;
- return;
- }
-
- b.stopidx = b.i + this.rgb_state.waitcnt;
- b.rc = 1;
-}
-
QuicEncoder.prototype.quic_rgb32_uncompress_row = function (prev_row, cur_row)
{
var bpc = 8;
commit 1c33ccff66c1a367ac1e95422e8109f2fb687bba
Author: Aric Stewart <aric at codeweavers.com>
Date: Mon Sep 24 10:49:00 2012 -0500
remove code duplications in uncompress
Signed-off-by: Aric Stewart <aric at codeweavers.com>
diff --git a/quic.js b/quic.js
index 3007624..0bae57e 100644
--- a/quic.js
+++ b/quic.js
@@ -641,41 +641,32 @@ QuicEncoder.prototype.quic_decode_begin = function(io_ptr)
QuicEncoder.prototype.quic_rgb32_uncompress_row0_seg = function (i, cur_row, end,
waitmask, bpc, bpc_mask)
{
- var channel_r = this.channels[0];
- var channel_g = this.channels[1];
- var channel_b = this.channels[2];
-
- var correlate_row_r = channel_r.correlate_row;
- var correlate_row_g = channel_g.correlate_row;
- var correlate_row_b = channel_b.correlate_row;
var stopidx;
+ var n_channels = 3;
+ var c;
if (!i) {
var a;
cur_row[rgb32_pixel_pad] = 0;
- a = golomb_decoding_8bpc(channel_r.find_bucket_8bpc(correlate_row_r.zero).bestcode, this.io_word);
- correlate_row_r.row[0] = a.rc;
- cur_row[rgb32_pixel_r] = (family_8bpc.xlatL2U[correlate_row_r.row[0]]&0xFF);
- this.decode_eatbits(a.codewordlen);
-
- a = golomb_decoding_8bpc(channel_g.find_bucket_8bpc(correlate_row_g.zero).bestcode, this.io_word);
- correlate_row_g.row[0] = a.rc;
- cur_row[rgb32_pixel_g] = (family_8bpc.xlatL2U[correlate_row_g.row[0]]&0xFF);
- this.decode_eatbits(a.codewordlen);
-
- a = golomb_decoding_8bpc(channel_b.find_bucket_8bpc(correlate_row_b.zero).bestcode, this.io_word);
- correlate_row_b.row[0] = a.rc;
- cur_row[rgb32_pixel_b] = (family_8bpc.xlatL2U[correlate_row_b.row[0]]&0xFF);
- this.decode_eatbits(a.codewordlen);
+ c = 0;
+ do
+ {
+ a = golomb_decoding_8bpc(this.channels[c].find_bucket_8bpc(this.channels[c].correlate_row.zero).bestcode, this.io_word);
+ this.channels[c].correlate_row.row[0] = a.rc;
+ cur_row[2-c] = (family_8bpc.xlatL2U[a.rc]&0xFF);
+ this.decode_eatbits(a.codewordlen);
+ } while (++c < n_channels);
if (this.rgb_state.waitcnt) {
--this.rgb_state.waitcnt;
} else {
this.rgb_state.waitcnt = (this.rgb_state.tabrand() & waitmask);
- channel_r.find_bucket_8bpc(correlate_row_r.zero).update_model_8bpc(this.rgb_state, correlate_row_r.row[0], bpc);
- channel_g.find_bucket_8bpc(correlate_row_g.zero).update_model_8bpc(this.rgb_state, correlate_row_g.row[0], bpc);
- channel_b.find_bucket_8bpc(correlate_row_b.zero).update_model_8bpc(this.rgb_state, correlate_row_b.row[0], bpc);
+ c = 0;
+ do
+ {
+ this.channels[c].find_bucket_8bpc(this.channels[c].correlate_row.zero).update_model_8bpc(this.rgb_state, this.channels[c].correlate_row.row[0], bpc);
+ } while (++c < n_channels);
}
stopidx = ++i + this.rgb_state.waitcnt;
} else {
@@ -687,24 +678,20 @@ QuicEncoder.prototype.quic_rgb32_uncompress_row0_seg = function (i, cur_row, end
var a;
cur_row[(i* rgb32_pixel_size)+rgb32_pixel_pad] = 0;
- a = golomb_decoding_8bpc(channel_r.find_bucket_8bpc(correlate_row_r.row[i - 1]).bestcode, this.io_word);
- correlate_row_r.row[i] = a.rc;
- cur_row[(i* rgb32_pixel_size)+rgb32_pixel_r] = (family_8bpc.xlatL2U[correlate_row_r.row[i]] + cur_row[((i-1) * rgb32_pixel_size) + rgb32_pixel_r]) & bpc_mask;
- this.decode_eatbits(a.codewordlen);
-
- a = golomb_decoding_8bpc(channel_g.find_bucket_8bpc(correlate_row_g.row[i - 1]).bestcode, this.io_word);
- correlate_row_g.row[i] = a.rc;
- cur_row[(i* rgb32_pixel_size)+rgb32_pixel_g] = (family_8bpc.xlatL2U[correlate_row_g.row[i]] + cur_row[((i-1) * rgb32_pixel_size) + rgb32_pixel_g]) & bpc_mask;
- this.decode_eatbits(a.codewordlen);
-
- a = golomb_decoding_8bpc(channel_b.find_bucket_8bpc(correlate_row_b.row[i - 1]).bestcode, this.io_word);
- correlate_row_b.row[i] = a.rc;
- cur_row[(i* rgb32_pixel_size)+rgb32_pixel_b] = (family_8bpc.xlatL2U[correlate_row_b.row[i]] + cur_row[((i-1) * rgb32_pixel_size) + rgb32_pixel_b]) & bpc_mask;
- this.decode_eatbits(a.codewordlen);
+ c = 0;
+ do
+ {
+ a = golomb_decoding_8bpc(this.channels[c].find_bucket_8bpc(this.channels[c].correlate_row.row[i - 1]).bestcode, this.io_word);
+ this.channels[c].correlate_row.row[i] = a.rc;
+ cur_row[(i* rgb32_pixel_size)+(2-c)] = (family_8bpc.xlatL2U[a.rc] + cur_row[((i-1) * rgb32_pixel_size) + (2-c)]) & bpc_mask;
+ this.decode_eatbits(a.codewordlen);
+ } while (++c < n_channels);
}
- channel_r.find_bucket_8bpc(correlate_row_r.row[stopidx - 1]).update_model_8bpc(this.rgb_state, correlate_row_r.row[stopidx], bpc);
- channel_g.find_bucket_8bpc(correlate_row_g.row[stopidx - 1]).update_model_8bpc(this.rgb_state, correlate_row_g.row[stopidx], bpc);
- channel_b.find_bucket_8bpc(correlate_row_b.row[stopidx - 1]).update_model_8bpc(this.rgb_state, correlate_row_b.row[stopidx], bpc);
+ c = 0;
+ do
+ {
+ this.channels[c].find_bucket_8bpc(this.channels[c].correlate_row.row[stopidx - 1]).update_model_8bpc(this.rgb_state, this.channels[c].correlate_row.row[stopidx], bpc);
+ } while (++c < n_channels);
stopidx = i + (this.rgb_state.tabrand() & waitmask);
}
@@ -712,18 +699,14 @@ QuicEncoder.prototype.quic_rgb32_uncompress_row0_seg = function (i, cur_row, end
var a;
cur_row[(i* rgb32_pixel_size)+rgb32_pixel_pad] = 0;
- a = golomb_decoding_8bpc(channel_r.find_bucket_8bpc(correlate_row_r.row[i - 1]).bestcode, this.io_word);
- correlate_row_r.row[i] = a.rc;
- cur_row[(i* rgb32_pixel_size)+rgb32_pixel_r] = (family_8bpc.xlatL2U[correlate_row_r.row[i]] + cur_row[((i-1) * rgb32_pixel_size) + rgb32_pixel_r]) & bpc_mask;
- this.decode_eatbits(a.codewordlen);
- a = golomb_decoding_8bpc(channel_g.find_bucket_8bpc(correlate_row_g.row[i - 1]).bestcode, this.io_word);
- correlate_row_g.row[i] = a.rc;
- cur_row[(i* rgb32_pixel_size)+rgb32_pixel_g] = (family_8bpc.xlatL2U[correlate_row_g.row[i]] + cur_row[((i-1) * rgb32_pixel_size) + rgb32_pixel_g]) & bpc_mask;
- this.decode_eatbits(a.codewordlen);
- a = golomb_decoding_8bpc(channel_b.find_bucket_8bpc(correlate_row_b.row[i - 1]).bestcode, this.io_word);
- correlate_row_b.row[i] = a;
- cur_row[(i* rgb32_pixel_size)+rgb32_pixel_b] = (family_8bpc.xlatL2U[correlate_row_b.row[i]] + cur_row[((i-1) * rgb32_pixel_size) + rgb32_pixel_b]) & bpc_mask;
- this.decode_eatbits(a.codewordlen);
+ c = 0;
+ do
+ {
+ a = golomb_decoding_8bpc(this.channels[c].find_bucket_8bpc(this.channels[c].correlate_row.row[i - 1]).bestcode, this.io_word);
+ this.channels[c].correlate_row.row[i] = a.rc;
+ cur_row[(i* rgb32_pixel_size)+(2-c)] = (family_8bpc.xlatL2U[a.rc] + cur_row[((i-1) * rgb32_pixel_size) + (2-c)]) & bpc_mask;
+ this.decode_eatbits(a.codewordlen);
+ } while (++c < n_channels);
}
this.rgb_state.waitcnt = stopidx - end;
}
@@ -761,18 +744,10 @@ QuicEncoder.prototype.quic_rgb32_uncompress_row0 = function (cur_row)
QuicEncoder.prototype.quic_rgb32_uncompress_row_seg = function( prev_row, cur_row, i, end, bpc, bpc_mask)
{
- var channel_r = this.channels[0];
- var channel_g = this.channels[1];
- var channel_b = this.channels[2];
-
- var correlate_row_r = channel_r.correlate_row;
- var correlate_row_g = channel_g.correlate_row;
- var correlate_row_b = channel_b.correlate_row;
-
+ var n_channels = 3;
var waitmask = bppmask[this.rgb_state.wmidx];
var a;
-
var b = {
i: i,
run_index: 0,
@@ -780,32 +755,28 @@ QuicEncoder.prototype.quic_rgb32_uncompress_row_seg = function( prev_row, cur_ro
run_end: 0,
end : end
};
+ var c;
if (!b.i)
{
cur_row[rgb32_pixel_pad] = 0;
- a = golomb_decoding_8bpc(channel_r.find_bucket_8bpc(correlate_row_r.zero).bestcode, this.io_word);
- correlate_row_r.row[0] = a.rc;
- cur_row[rgb32_pixel_r] = (family_8bpc.xlatL2U[correlate_row_r.row[0]] + prev_row[rgb32_pixel_r]) & bpc_mask;
- this.decode_eatbits(a.codewordlen);
-
- a = golomb_decoding_8bpc(channel_g.find_bucket_8bpc(correlate_row_g.zero).bestcode, this.io_word);
- correlate_row_g.row[0] = a.rc;
- cur_row[rgb32_pixel_g] = (family_8bpc.xlatL2U[correlate_row_g.row[0]] + prev_row[rgb32_pixel_g]) & bpc_mask;
- this.decode_eatbits(a.codewordlen);
- a = golomb_decoding_8bpc(channel_b.find_bucket_8bpc(correlate_row_b.zero).bestcode, this.io_word);
- correlate_row_b.row[0] = a.rc;
- cur_row[rgb32_pixel_b] = (family_8bpc.xlatL2U[correlate_row_b.row[0]] + prev_row[rgb32_pixel_b]) & bpc_mask;
- this.decode_eatbits(a.codewordlen);
+ c = 0;
+ do {
+ a = golomb_decoding_8bpc(this.channels[c].find_bucket_8bpc(this.channels[c].correlate_row.zero).bestcode, this.io_word);
+ this.channels[c].correlate_row.row[0] = a.rc;
+ cur_row[2-c] = (family_8bpc.xlatL2U[this.channels[c].correlate_row.row[0]] + prev_row[2-c]) & bpc_mask;
+ this.decode_eatbits(a.codewordlen);
+ } while (++c < n_channels);
if (this.rgb_state.waitcnt) {
--this.rgb_state.waitcnt;
} else {
this.rgb_state.waitcnt = (this.rgb_state.tabrand() & waitmask);
- channel_r.find_bucket_8bpc(correlate_row_r.zero).update_model_8bpc(this.rgb_state, correlate_row_r.row[0], bpc);
- channel_g.find_bucket_8bpc(correlate_row_g.zero).update_model_8bpc(this.rgb_state, correlate_row_g.row[0], bpc);
- channel_b.find_bucket_8bpc(correlate_row_b.zero).update_model_8bpc(this.rgb_state, correlate_row_b.row[0], bpc);
+ c = 0;
+ do {
+ this.channels[c].find_bucket_8bpc(this.channels[c].correlate_row.zero).update_model_8bpc(this.rgb_state, this.channels[c].correlate_row.row[0], bpc);
+ } while (++c < n_channels);
}
b.stopidx = ++b.i + this.rgb_state.waitcnt;
} else {
@@ -829,28 +800,25 @@ QuicEncoder.prototype.quic_rgb32_uncompress_row_seg = function( prev_row, cur_ro
}
}
+ c = 0;
cur_row[pixel+rgb32_pixel_pad] = 0;
- a = golomb_decoding_8bpc(channel_r.find_bucket_8bpc(correlate_row_r.row[b.i-1]).bestcode, this.io_word);
- correlate_row_r.row[b.i] = a.rc;
- cur_row[pixel+rgb32_pixel_r] = (family_8bpc.xlatL2U[a.rc] + ((cur_row[pixelm1+rgb32_pixel_r] + prev_row[pixel+rgb32_pixel_r]) >>> 1)) & bpc_mask;
- this.decode_eatbits(a.codewordlen);
-
- a = golomb_decoding_8bpc(channel_g.find_bucket_8bpc(correlate_row_g.row[b.i-1]).bestcode, this.io_word);
- correlate_row_g.row[b.i] = a.rc;
- cur_row[pixel+rgb32_pixel_g] = ((family_8bpc.xlatL2U[a.rc] + ((cur_row[pixelm1+rgb32_pixel_g] + prev_row[pixel+rgb32_pixel_g]) >>> 1)) & bpc_mask);
- this.decode_eatbits(a.codewordlen);
-
- a = golomb_decoding_8bpc(channel_b.find_bucket_8bpc(correlate_row_b.row[b.i-1]).bestcode, this.io_word);
- correlate_row_b.row[b.i] = a.rc;
- cur_row[pixel+rgb32_pixel_b] = ((family_8bpc.xlatL2U[a.rc] + ((cur_row[pixelm1+rgb32_pixel_b] + prev_row[pixel+rgb32_pixel_b]) >>> 1)) & bpc_mask);
- this.decode_eatbits(a.codewordlen);
+ do {
+ var cc = this.channels[c];
+ var cr = cc.correlate_row;
+
+ a = golomb_decoding_8bpc(cc.find_bucket_8bpc(cr.row[b.i-1]).bestcode, this.io_word);
+ cr.row[b.i] = a.rc;
+ cur_row[pixel+(2-c)] = (family_8bpc.xlatL2U[a.rc] + ((cur_row[pixelm1+(2-c)] + prev_row[pixel+(2-c)]) >> 1)) & bpc_mask;
+ this.decode_eatbits(a.codewordlen);
+ } while (++c < n_channels);
}
if (b.rc)
break;
- channel_r.find_bucket_8bpc(correlate_row_r.row[b.stopidx - 1]).update_model_8bpc(this.rgb_state, correlate_row_r.row[b.stopidx], bpc);
- channel_g.find_bucket_8bpc(correlate_row_g.row[b.stopidx - 1]).update_model_8bpc(this.rgb_state, correlate_row_g.row[b.stopidx], bpc);
- channel_b.find_bucket_8bpc(correlate_row_b.row[b.stopidx - 1]).update_model_8bpc(this.rgb_state, correlate_row_b.row[b.stopidx], bpc);
+ c = 0;
+ do {
+ this.channels[c].find_bucket_8bpc(this.channels[c].correlate_row.row[b.stopidx - 1]).update_model_8bpc(this.rgb_state, this.channels[c].correlate_row.row[b.stopidx], bpc);
+ } while (++c < n_channels);
b.stopidx = b.i + (this.rgb_state.tabrand() & waitmask);
}
@@ -871,20 +839,14 @@ QuicEncoder.prototype.quic_rgb32_uncompress_row_seg = function( prev_row, cur_ro
}
cur_row[pixel+rgb32_pixel_pad] = 0;
- a = golomb_decoding_8bpc(channel_r.find_bucket_8bpc(correlate_row_r.row[b.i-1]).bestcode, this.io_word);
- correlate_row_r.row[b.i] = a.rc;
- cur_row[pixel+rgb32_pixel_r] = (family_8bpc.xlatL2U[a.rc] + ((cur_row[pixelm1+rgb32_pixel_r] + prev_row[pixel+rgb32_pixel_r]) >>> 1)) & bpc_mask;
- this.decode_eatbits(a.codewordlen);
-
- a = golomb_decoding_8bpc(channel_g.find_bucket_8bpc(correlate_row_g.row[b.i-1]).bestcode, this.io_word);
- correlate_row_g.row[b.i] = a.rc;
- cur_row[pixel+rgb32_pixel_g] = (family_8bpc.xlatL2U[a.rc] + ((cur_row[pixelm1+rgb32_pixel_g] + prev_row[pixel+rgb32_pixel_g]) >>> 1)) & bpc_mask;
- this.decode_eatbits(a.codewordlen);
-
- a = golomb_decoding_8bpc(channel_b.find_bucket_8bpc(correlate_row_b.row[b.i-1]).bestcode, this.io_word);
- correlate_row_b.row[b.i] = a.rc;
- cur_row[pixel+rgb32_pixel_b] = (family_8bpc.xlatL2U[a.rc] + ((cur_row[pixelm1+rgb32_pixel_b] + prev_row[pixel+rgb32_pixel_b]) >>> 1)) & bpc_mask;
- this.decode_eatbits(a.codewordlen);
+ c = 0;
+ do
+ {
+ a = golomb_decoding_8bpc(this.channels[c].find_bucket_8bpc(this.channels[c].correlate_row.row[b.i-1]).bestcode, this.io_word);
+ this.channels[c].correlate_row.row[b.i] = a.rc;
+ cur_row[pixel+(2-c)] = (family_8bpc.xlatL2U[a.rc] + ((cur_row[pixelm1+(2-c)] + prev_row[pixel+(2-c)]) >> 1)) & bpc_mask;
+ this.decode_eatbits(a.codewordlen);
+ } while (++c < n_channels);
}
if (!b.rc)
commit ad66ff9d6a91eda79fc3ec22e9b5416fe346b73d
Author: Aric Stewart <aric at codeweavers.com>
Date: Mon Sep 24 10:52:09 2012 -0500
correct some issues with prototype vs instance member objects
Resending Patch set for Jeremy White.
Sorry my total for patches is missing.
-aric
Signed-off-by: Aric Stewart <aric at codeweavers.com>
diff --git a/quic.js b/quic.js
index 7c5be6b..3007624 100644
--- a/quic.js
+++ b/quic.js
@@ -330,11 +330,11 @@ QuicModel.prototype = {
function QuicBucket()
{
+ this.counters = [0,0,0,0,0,0,0,0];
}
QuicBucket.prototype = {
bestcode: 0,
- counters: [0,0,0,0,0,0,0,0],
reste : function (bpp)
{
@@ -372,11 +372,11 @@ QuicBucket.prototype = {
function QuicFamilyStat()
{
+ this.buckets_ptrs = [];
+ this.buckets_buf = [];
}
QuicFamilyStat.prototype = {
- buckets_ptrs : [],
- buckets_buf : [],
fill_model_structures : function(model)
{
@@ -421,14 +421,11 @@ function QuicChannel(model_8bpc, model_5bpc)
{
this.state = new CommonState;
this.family_stat_8bpc = new QuicFamilyStat;
- this.family_stat_8bpc.buckets_ptrs = [];
- this.family_stat_8bpc.buckets_buf = [];
this.family_stat_5bpc = new QuicFamilyStat;
- this.family_stat_5bpc.buckets_ptrs = [];
- this.family_stat_5bpc.buckets_buf = [];
this.correlate_row = { zero: 0 , row:[] };
this.model_8bpc = model_8bpc;
this.model_5bpc = model_5bpc;
+ this.buckets_ptrs = [];
if (!this.family_stat_8bpc.fill_model_structures(this.model_8bpc))
return undefined;
@@ -438,11 +435,6 @@ function QuicChannel(model_8bpc, model_5bpc)
}
QuicChannel.prototype = {
- correlate_row : {},
- state : CommonState,
- family_stat_8bpc : QuicFamilyStat,
- family_stat_5bpc : QuicFamilyStat,
- buckets_ptrs: [],
find_bucket_8bpc : function(val)
{
@@ -524,6 +516,7 @@ function QuicEncoder()
this.rgb_state = new CommonState;
this.model_8bpc = new QuicModel(8);
this.model_5bpc = new QuicModel(5);
+ this.channels = [];
var i;
for (i = 0; i < 4; i++) {
@@ -547,7 +540,6 @@ QuicEncoder.prototype = {
io_now: 0,
io_end: 0,
rows_completed: 0,
- channels: []
};
QuicEncoder.prototype.reste = function(io_ptr)
More information about the Spice-commits
mailing list