function read_bits_n(buf, bl, n) {
	var w = (bl&7), h = (bl>>>3), f = ((1<<n)-1);
	var v = buf[h] >>> w;
	if(n < 8 - w) return v & f;
	v |= buf[h+1]<<(8-w);
	if(n < 16 - w) return v & f;
	v |= buf[h+2]<<(16-w);
	if(n < 24 - w) return v & f;
	v |= buf[h+3]<<(24-w);
	return v & f;
}
function read_bits_n(buf, bl, n) {
	var w = (bl&7), h = (bl>>>3), f = ((1<<n)-1);
	var v = buf[h] >>> w;
	if(n < 8 - w) return v & f;
	v |= buf[h+1]<<(8-w);
	if(n < 16 - w) return v & f;
	v |= buf[h+2]<<(16-w);
	if(n < 24 - w) return v & f;
	v |= buf[h+3]<<(24-w);
	return v & f;
}
function read_bits_n ( buf , bl , n ) { var w = ( bl & 7 ) , h = ( bl >>> 3 ) , f = ( ( 1 << n ) - 1 ) ; var v = buf [ h ] >>> w ; if ( n < 8 - w ) return v & f ; v |= buf [ h + 1 ] << ( 8 - w ) ; if ( n < 16 - w ) return v & f ; v |= buf [ h + 2 ] << ( 16 - w ) ; if ( n < 24 - w ) return v & f ; v |= buf [ h + 3 ] << ( 24 - w ) ; return v & f ; }
/* works up to n = 3 * 8 + 1 = 25
/ * works up to n = 3 * 8 + 1 = 25
read n bits from buffer