/*OPT: ec_window must be at least 32 bits, but if you have fast arithmetic on a
larger type, you can speed up the decoder by using it here.*/ typedef opus_uint32 ec_window; typedefstruct ec_ctx ec_ctx; typedefstruct ec_ctx ec_enc; typedefstruct ec_ctx ec_dec;
/*The number of bits to use for the range-coded part of unsigned integers.*/ # define EC_UINT_BITS (8)
/*The resolution of fractional-precision bit usage measurements, i.e.,
3 => 1/8th bits.*/ # define BITRES 3
/*The entropy encoder/decoder context. Weusethesamestructureforboth,sothatcommonfunctionslikeec_tell()
can be used on either one.*/ struct ec_ctx{ /*Buffered input/output.*/ unsignedchar *buf; /*The size of the buffer.*/
opus_uint32 storage; /*The offset at which the last byte containing raw bits was read/written.*/
opus_uint32 end_offs; /*Bits that will be read from/written at the end.*/
ec_window end_window; /*Number of valid bits in end_window.*/ int nend_bits; /*The total number of whole bits read/written.
This does not include partial bits currently in the range coder.*/ int nbits_total; /*The offset at which the next range coder byte will be read/written.*/
opus_uint32 offs; /*The number of values in the current range.*/
opus_uint32 rng; /*In the decoder: the difference between the top of the current range and theinputvalue,minusone.
In the encoder: the low end of the current range.*/
opus_uint32 val; /*In the decoder: the saved normalization factor from ec_decode().
In the encoder: the number of outstanding carry propagating symbols.*/
opus_uint32 ext; /*A buffered input/output symbol, awaiting carry propagation.*/ int rem; /*Nonzero if an error occurred.*/ int error;
};
static OPUS_INLINE int ec_get_error(ec_ctx *_this){ return _this->error;
}
/*Returns the number of bits "used" by the encoded or decoded symbols so far. Thissamenumbercanbecomputedineithertheencoderorthedecoder,andis suitableformakingcodingdecisions. Return:Thenumberofbits. Thiswillalwaysbeslightlylargerthantheexactvalue(e.g.,all
rounding error is in the positive direction).*/ static OPUS_INLINE int ec_tell(ec_ctx *_this){ return _this->nbits_total-EC_ILOG(_this->rng);
}
/*Returns the number of bits "used" by the encoded or decoded symbols so far. Thissamenumbercanbecomputedineithertheencoderorthedecoder,andis suitableformakingcodingdecisions. Return:Thenumberofbitsscaledby2**BITRES. Thiswillalwaysbeslightlylargerthantheexactvalue(e.g.,all
rounding error is in the positive direction).*/
opus_uint32 ec_tell_frac(ec_ctx *_this);
/* Tested exhaustively for all n and for 1<=d<=256 */ static OPUS_INLINE opus_uint32 celt_udiv(opus_uint32 n, opus_uint32 d) {
celt_sig_assert(d>0); #ifdef USE_SMALL_DIV_TABLE if (d>256) return n/d; else {
opus_uint32 t, q;
t = EC_ILOG(d&-d);
q = (opus_uint64)SMALL_DIV_TABLE[d>>t]*(n>>(t-1))>>32; return q+(n-q*d >= d);
} #else return n/d; #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.