On 1 February 2017 at 03:13, Rostislav Pehlivanov <atomnu...@gmail.com> wrote:
> Signed-off-by: Rostislav Pehlivanov <atomnu...@gmail.com> > --- > libavcodec/opus_celt.c | 2 +- > libavcodec/opus_rc.c | 19 +++++++++++++------ > libavcodec/opus_rc.h | 6 +++--- > 3 files changed, 17 insertions(+), 10 deletions(-) > > diff --git a/libavcodec/opus_celt.c b/libavcodec/opus_celt.c > index c115ee7ad3..96fedb7a49 100644 > --- a/libavcodec/opus_celt.c > +++ b/libavcodec/opus_celt.c > @@ -1641,7 +1641,7 @@ int ff_celt_decode_frame(CeltContext *s, > OpusRangeCoder *rc, > > if (silence) { > consumed = s->framebits; > - rc->total_read_bits += s->framebits - opus_rc_tell(rc); > + rc->total_bits += s->framebits - opus_rc_tell(rc); > } > > /* obtain post-filter options */ > diff --git a/libavcodec/opus_rc.c b/libavcodec/opus_rc.c > index 1f9af041aa..b0e72f6ffe 100644 > --- a/libavcodec/opus_rc.c > +++ b/libavcodec/opus_rc.c > @@ -22,12 +22,19 @@ > > #include "opus_rc.h" > > +#define OPUS_RC_BITS 32 > +#define OPUS_RC_SYM 8 > +#define OPUS_RC_CEIL ((1 << OPUS_RC_SYM) - 1) > +#define OPUS_RC_TOP (1u << 31) > +#define OPUS_RC_BOT (OPUS_RC_TOP >> OPUS_RC_SYM) > +#define OPUS_RC_SHIFT (OPUS_RC_BITS - OPUS_RC_SYM - 1) > + > static av_always_inline void opus_rc_dec_normalize(OpusRangeCoder *rc) > { > - while (rc->range <= 1<<23) { > - rc->value = ((rc->value << 8) | (get_bits(&rc->gb, 8) ^ 0xFF)) & > ((1u << 31) - 1); > - rc->range <<= 8; > - rc->total_read_bits += 8; > + while (rc->range <= OPUS_RC_BOT) { > + rc->value = ((rc->value << OPUS_RC_SYM) | (get_bits(&rc->gb, > OPUS_RC_SYM) ^ OPUS_RC_CEIL)) & (OPUS_RC_TOP - 1); > + rc->range <<= OPUS_RC_SYM; > + rc->total_bits += OPUS_RC_SYM; > } > } > > @@ -93,7 +100,7 @@ uint32_t ff_opus_rc_get_raw(OpusRangeCoder *rc, > uint32_t count) > value = av_mod_uintp2(rc->rb.cacheval, count); > rc->rb.cacheval >>= count; > rc->rb.cachelen -= count; > - rc->total_read_bits += count; > + rc->total_bits += count; > > return value; > } > @@ -206,7 +213,7 @@ int ff_opus_rc_dec_init(OpusRangeCoder *rc, const > uint8_t *data, int size) > > rc->range = 128; > rc->value = 127 - get_bits(&rc->gb, 7); > - rc->total_read_bits = 9; > + rc->total_bits = 9; > opus_rc_dec_normalize(rc); > > return 0; > diff --git a/libavcodec/opus_rc.h b/libavcodec/opus_rc.h > index 68ebc05af6..9f5253b51d 100644 > --- a/libavcodec/opus_rc.h > +++ b/libavcodec/opus_rc.h > @@ -40,7 +40,7 @@ typedef struct OpusRangeCoder { > RawBitsContext rb; > uint32_t range; > uint32_t value; > - uint32_t total_read_bits; > + uint32_t total_bits; > } OpusRangeCoder; > > /** > @@ -49,14 +49,14 @@ typedef struct OpusRangeCoder { > */ > static av_always_inline uint32_t opus_rc_tell(const OpusRangeCoder *rc) > { > - return rc->total_read_bits - av_log2(rc->range) - 1; > + return rc->total_bits - av_log2(rc->range) - 1; > } > > static av_always_inline uint32_t opus_rc_tell_frac(const OpusRangeCoder > *rc) > { > uint32_t i, total_bits, rcbuffer, range; > > - total_bits = rc->total_read_bits << 3; > + total_bits = rc->total_bits << 3; > rcbuffer = av_log2(rc->range) + 1; > range = rc->range >> (rcbuffer-16); > > -- > 2.11.0.483.g087da7b7c > > Applied _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel