mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
opus_rc: rename total_bits_used to total_bits and #define some constants
Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
This commit is contained in:
parent
8b80feb9a7
commit
084f3addda
@ -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 */
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user