1 if(!dojo._hasResource["dojox.encoding.bits"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
2 dojo._hasResource["dojox.encoding.bits"] = true;
3 dojo.provide("dojox.encoding.bits");
5 dojox.encoding.bits.OutputStream = function(){
9 dojo.extend(dojox.encoding.bits.OutputStream, {
15 putBits: function(value, width){
17 var w = Math.min(width, this.available);
18 var v = (w <= width ? value >>> (width - w) : value) << (this.available - w);
19 this.accumulator |= v & (255 >>> (8 - this.available));
22 this.buffer.push(this.accumulator);
30 return this.buffer.length * 8 + (8 - this.available);
32 getBuffer: function(){
34 if(this.available < 8){ b.push(this.accumulator & (255 << this.available)); }
40 dojox.encoding.bits.InputStream = function(buffer, width){
43 this.bbyte = this.bit = 0;
46 dojo.extend(dojox.encoding.bits.InputStream, {
47 getBits: function(width){
50 var w = Math.min(width, 8 - this.bit);
51 var v = this.buffer[this.bbyte] >>> (8 - this.bit - w);
64 return this.width - this.bbyte * 8 - this.bit;