phpldapadmin/application/media/js/dojo-release-1.7.2/dojox/encoding/bits.js

59 lines
1.2 KiB
JavaScript
Raw Normal View History

2012-06-19 02:07:43 +00:00
//>>built
define("dojox/encoding/bits",["dojo/_base/lang"],function(_1){
var _2=_1.getObject("dojox.encoding.bits",true);
_2.OutputStream=function(){
this.reset();
};
_1.extend(_2.OutputStream,{reset:function(){
this.buffer=[];
this.accumulator=0;
this.available=8;
},putBits:function(_3,_4){
while(_4){
var w=Math.min(_4,this.available);
var v=(w<=_4?_3>>>(_4-w):_3)<<(this.available-w);
this.accumulator|=v&(255>>>(8-this.available));
this.available-=w;
if(!this.available){
this.buffer.push(this.accumulator);
this.accumulator=0;
this.available=8;
}
_4-=w;
}
},getWidth:function(){
return this.buffer.length*8+(8-this.available);
},getBuffer:function(){
var b=this.buffer;
if(this.available<8){
b.push(this.accumulator&(255<<this.available));
}
this.reset();
return b;
}});
_2.InputStream=function(_5,_6){
this.buffer=_5;
this.width=_6;
this.bbyte=this.bit=0;
};
_1.extend(_2.InputStream,{getBits:function(_7){
var r=0;
while(_7){
var w=Math.min(_7,8-this.bit);
var v=this.buffer[this.bbyte]>>>(8-this.bit-w);
r<<=w;
r|=v&~(~0<<w);
this.bit+=w;
if(this.bit==8){
++this.bbyte;
this.bit=0;
}
_7-=w;
}
return r;
},getWidth:function(){
return this.width-this.bbyte*8-this.bit;
}});
return _2;
});