summaryrefslogtreecommitdiff
path: root/libavcodec/opusdec.c
diff options
context:
space:
mode:
authorRostislav Pehlivanov <atomnuker@gmail.com>2016-11-07 22:33:11 +0000
committerRostislav Pehlivanov <atomnuker@gmail.com>2016-11-08 14:18:59 +0000
commit317be31eaf4f07b3bbeb703e8ee73d04b08a587c (patch)
tree9a07a44dde6a86a34bb8d6f7675b8eeaabd15f56 /libavcodec/opusdec.c
parent0660a09dd1d12e17216d44ec42584690d812b7f3 (diff)
opus: move the entropy decoding functions to opus_rc.c
The intention is to have both encoding and decoding functions in opus_rc.c. Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
Diffstat (limited to 'libavcodec/opusdec.c')
-rw-r--r--libavcodec/opusdec.c40
1 files changed, 7 insertions, 33 deletions
diff --git a/libavcodec/opusdec.c b/libavcodec/opusdec.c
index 95a2435e53..ec793c6c47 100644
--- a/libavcodec/opusdec.c
+++ b/libavcodec/opusdec.c
@@ -73,32 +73,6 @@ static int get_silk_samplerate(int config)
return 16000;
}
-/**
- * Range decoder
- */
-static int opus_rc_init(OpusRangeCoder *rc, const uint8_t *data, int size)
-{
- int ret = init_get_bits8(&rc->gb, data, size);
- if (ret < 0)
- return ret;
-
- rc->range = 128;
- rc->value = 127 - get_bits(&rc->gb, 7);
- rc->total_read_bits = 9;
- opus_rc_normalize(rc);
-
- return 0;
-}
-
-static void opus_raw_init(OpusRangeCoder *rc, const uint8_t *rightend,
- unsigned int bytes)
-{
- rc->rb.position = rightend;
- rc->rb.bytes = bytes;
- rc->rb.cachelen = 0;
- rc->rb.cacheval = 0;
-}
-
static void opus_fade(float *out,
const float *in1, const float *in2,
const float *window, int len)
@@ -185,10 +159,10 @@ static int opus_decode_redundancy(OpusStreamContext *s, const uint8_t *data, int
bw == OPUS_BANDWIDTH_MEDIUMBAND)
bw = OPUS_BANDWIDTH_WIDEBAND;
- ret = opus_rc_init(&s->redundancy_rc, data, size);
+ ret = ff_opus_rc_dec_init(&s->redundancy_rc, data, size);
if (ret < 0)
goto fail;
- opus_raw_init(&s->redundancy_rc, data + size, size);
+ ff_opus_rc_dec_raw_init(&s->redundancy_rc, data + size, size);
ret = ff_celt_decode_frame(s->celt, &s->redundancy_rc,
s->redundancy_output,
@@ -211,7 +185,7 @@ static int opus_decode_frame(OpusStreamContext *s, const uint8_t *data, int size
int ret, i, consumed;
int delayed_samples = s->delayed_samples;
- ret = opus_rc_init(&s->rc, data, size);
+ ret = ff_opus_rc_dec_init(&s->rc, data, size);
if (ret < 0)
return ret;
@@ -246,15 +220,15 @@ static int opus_decode_frame(OpusStreamContext *s, const uint8_t *data, int size
// decode redundancy information
consumed = opus_rc_tell(&s->rc);
if (s->packet.mode == OPUS_MODE_HYBRID && consumed + 37 <= size * 8)
- redundancy = opus_rc_p2model(&s->rc, 12);
+ redundancy = ff_opus_rc_dec_log(&s->rc, 12);
else if (s->packet.mode == OPUS_MODE_SILK && consumed + 17 <= size * 8)
redundancy = 1;
if (redundancy) {
- redundancy_pos = opus_rc_p2model(&s->rc, 1);
+ redundancy_pos = ff_opus_rc_dec_log(&s->rc, 1);
if (s->packet.mode == OPUS_MODE_HYBRID)
- redundancy_size = opus_rc_unimodel(&s->rc, 256) + 2;
+ redundancy_size = ff_opus_rc_dec_uint(&s->rc, 256) + 2;
else
redundancy_size = size - (consumed + 7) / 8;
size -= redundancy_size;
@@ -298,7 +272,7 @@ static int opus_decode_frame(OpusStreamContext *s, const uint8_t *data, int size
}
}
- opus_raw_init(&s->rc, data + size, size);
+ ff_opus_rc_dec_raw_init(&s->rc, data + size, size);
ret = ff_celt_decode_frame(s->celt, &s->rc, dst,
s->packet.stereo + 1,