/*Given the current total integer number of bits used and the current value of rng,computesthefractionnumberofbitsusedtoOD_BITRESprecision. Thisisusedbyod_ec_enc_tell_frac()andod_ec_dec_tell_frac(). nbits_total:Thenumberofwholebitscurrentlyused,i.e.,thevalue returnedbyod_ec_enc_tell()orod_ec_dec_tell(). rng:Thecurrentvalueofrngfromeithertheencoderordecoderstate. Return:Thenumberofbitsscaledby2**OD_BITRES. Thiswillalwaysbeslightlylargerthantheexactvalue(e.g.,all
rounding error is in the positive direction).*/
uint32_t od_ec_tell_frac(uint32_t nbits_total, uint32_t rng) {
uint32_t nbits; 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 od_ec_enc_done()maybe1smallerifrngisapoweroftwoandthe correspondingtrailingbitsofvalareallzeros. Ifwedidtrytotrackthatspecialcase,thencodingavaluewitha probabilityof1/(1<<n)mightsometimesappeartousemorethannbits. Thismayhelpexplainthesurprisingresultthatanewlyinitialized
encoder or decoder claims to have used 1 bit.*/
nbits = nbits_total << OD_BITRES;
l = 0; for (i = OD_BITRES; i-- > 0;) { int b;
rng = rng * rng >> 15;
b = (int)(rng >> 16);
l = l << 1 | b;
rng >>= b;
} return nbits - l;
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.14 Sekunden
(vorverarbeitet am 2026-08-24)
¤
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.