#if !defined(EC_CLZ) /*This is a fallback for systems where we don't know how to access aBSRorCLZinstruction(seeecintrin.h). IfyouareoptimizingOpusonanewplatformandithasanativeCLZor BZR(e.g.cell,MIPS,x86,etc)thenmakingitavailabletoOpuswillbe
an easy performance win.*/ int ec_ilog(opus_uint32 _v){ /*On a Pentium M, this branchless version tested as the fastest on 1,000,000,000random32-bitintegers,edgingoutasimilarversionwith
branches, and a 256-entry LUT version.*/ int ret; int m;
ret=!!_v;
m=!!(_v&0xFFFF0000)<<4;
_v>>=m;
ret|=m;
m=!!(_v&0xFF00)<<3;
_v>>=m;
ret|=m;
m=!!(_v&0xF0)<<2;
_v>>=m;
ret|=m;
m=!!(_v&0xC)<<1;
_v>>=m;
ret|=m;
ret+=!!(_v&0x2); return ret;
} #endif
#if1 /* This is a faster version of ec_tell_frac() that takes advantage ofthelow(1/8bit)resolutiontousejustalinearfunction
followed by a lookup to determine the exact transition thresholds. */
opus_uint32 ec_tell_frac(ec_ctx *_this){ staticconstunsigned correction[8] =
{35733, 38967, 42495, 46340, 50535, 55109, 60097, 65535};
opus_uint32 nbits;
opus_uint32 r; int l; unsigned b;
nbits=_this->nbits_total<<BITRES;
l=EC_ILOG(_this->rng);
r=_this->rng>>(l-16);
b = (r>>12)-8;
b += r>correction[b];
l = (l<<3)+b; return nbits-l;
} #else
opus_uint32 ec_tell_frac(ec_ctx *_this){
opus_uint32 nbits;
opus_uint32 r; int l; int i; /*To handle the non-integral number of bits still left in the encoder/decoder state,wecomputetheworst-casenumberofbitsofvalthatmustbe encodedtoensurethatthevalueisinsidetherangeforanypossible subsequentbits. Thecomputationhereisindependentofvalitself(thedecoderdoesnot eventrackthatvalue),eventhoughtherealnumberofbitsusedafter ec_enc_done()maybe1smallerifrngisapoweroftwoandthe correspondingtrailingbitsofvalareallzeros. Ifwedidtrytotrackthatspecialcase,thencodingavaluewitha probabilityof1/(1<<n)mightsometimesappeartousemorethannbits. Thismayhelpexplainthesurprisingresultthatanewlyinitialized
encoder or decoder claims to have used 1 bit.*/
nbits=_this->nbits_total<<BITRES;
l=EC_ILOG(_this->rng);
r=_this->rng>>(l-16); for(i=BITRES;i-->0;){ int b;
r=r*r>>15;
b=(int)(r>>16);
l=l<<1|b;
r>>=b;
} return nbits-l;
} #endif
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.