crblib/vqarith.c
/** routines to insert raw bits in an arith bit stream;
	all divisions eliminated **/
routines to insert raw bits in an arith bit stream;
all divisions eliminated
routines to insert raw bits in an arith bit stream ; all divisions eliminated
void FastArithBit(struct FAI * FAI,bool bit)
{
register ulong regcode,regrange,regQlength;
regcode    = FAI->code;
regrange   = FAI->range;
regQlength = FAI->Qlength;
if ( bit ) {
	ulong lowincr;
	lowincr = regrange>>1;
	regcode  += lowincr;
	regrange -= lowincr;
} else {
	regrange = regrange>>1;
}
if ( regcode & One ) {
	regcode -= One;
	BitIO_WriteBit(FAI->BII,1);
	while ( --regQlength ) { BitIO_WriteZeroBit(FAI->BII); }
}
while( regrange <= Half ) {
	if ( regcode >= Half ) {
		if ( regQlength == 0 )
	  		BitIO_WriteBit(FAI->BII,1);
		else
			regQlength ++;
		regcode -= Half;
	} else {
		if ( regQlength ) {
	  		BitIO_WriteZeroBit(FAI->BII);
	  		while ( --regQlength ) { BitIO_WriteBit(FAI->BII,1); }
	  	}
		regQlength = 1;
	}
	regcode  += regcode;
	regrange += regrange;
}
FAI->code  = regcode;
FAI->range = regrange;
FAI->Qlength = regQlength;
}
void FastArithBit ( struct FAI * FAI , bool bit ) { register ulong regcode , regrange , regQlength ; regcode = FAI -> code ; regrange = FAI -> range ; regQlength = FAI -> Qlength ; if ( bit ) { ulong lowincr ; lowincr = regrange >> 1 ; regcode += lowincr ; regrange -= lowincr ; } else { regrange = regrange >> 1 ; } if ( regcode & One ) { regcode -= One ; BitIO_WriteBit ( FAI -> BII , 1 ) ; while ( -- regQlength ) { BitIO_WriteZeroBit ( FAI -> BII ) ; } } while ( regrange <= Half ) { if ( regcode >= Half ) { if ( regQlength == 0 ) BitIO_WriteBit ( FAI -> BII , 1 ) ; else regQlength ++ ; regcode -= Half ; } else { if ( regQlength ) { BitIO_WriteZeroBit ( FAI -> BII ) ; while ( -- regQlength ) { BitIO_WriteBit ( FAI -> BII , 1 ) ; } } regQlength = 1 ; } regcode += regcode ; regrange += regrange ; } FAI -> code = regcode ; FAI -> range = regrange ; FAI -> Qlength = regQlength ; }
routines to insert raw bits in an arith bit stream;
all divisions eliminated
routines to insert raw bits in an arith bit stream ; all divisions eliminated
/** the standard queue-flush: **/