From b3c05b6be2a6579af55a625903e9e70687a4d77f Mon Sep 17 00:00:00 2001 From: "Timothy B. Terriberry" Date: Mon, 14 Feb 2011 14:40:27 -0500 Subject: [PATCH] Implements ec_enc_patch_initial_bits() --- libcelt/entenc.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/libcelt/entenc.c b/libcelt/entenc.c index d322dae9..94201327 100644 --- a/libcelt/entenc.c +++ b/libcelt/entenc.c @@ -215,6 +215,31 @@ void ec_enc_bits(ec_enc *_this,ec_uint32 _fl,unsigned _bits){ _this->nbits_total+=_bits; } +int ec_enc_patch_initial_bits(ec_enc *_this,unsigned _val,int _nbits){ + int shift; + unsigned mask; + if(_nbits<0||_nbits>EC_SYM_BITS)return -1; + shift=EC_SYM_BITS-_nbits; + mask=(1<<_nbits)-1<offs>0){ + /*The first byte has been finalized.*/ + _this->buf[0]=(unsigned char)(_this->buf[0]&~mask|_val<rem>=0){ + /*The first byte is still awaiting carry propagation.*/ + _this->rem=_this->rem&~mask|_val<rng<=EC_CODE_TOP>>shift){ + /*The renormalization loop has never been run.*/ + _this->val=_this->val&~((ec_uint32)mask<offs+_this->end_offs<=_size); CELT_MOVE(_this->buf+_size-_this->end_offs,