#include "audiodsp.h"
#include "avcodec.h"
-#include "get_bits.h"
+#include "bitstream.h"
#include "bytestream.h"
#include "fft.h"
#include "internal.h"
AVCodecContext* avctx;
AudioDSPContext adsp;
- GetBitContext gb;
+ BitstreamContext bc;
/* stream data */
int num_vectors;
int samples_per_channel;
/**
* Fill the gain array for the timedomain quantization.
*
- * @param gb pointer to the GetBitContext
+ * @param bc pointer to the BitstreamContext
* @param gaininfo array[9] of gain indexes
*/
-static void decode_gain_info(GetBitContext *gb, int *gaininfo)
+static void decode_gain_info(BitstreamContext *bc, int *gaininfo)
{
int i, n;
- while (get_bits1(gb)) {
+ while (bitstream_read_bit(bc)) {
/* NOTHING */
}
- n = get_bits_count(gb) - 1; // amount of elements*2 to update
+ n = bitstream_tell(bc) - 1; // amount of elements * 2 to update
i = 0;
while (n--) {
- int index = get_bits(gb, 3);
- int gain = get_bits1(gb) ? get_bits(gb, 4) - 7 : -1;
+ int index = bitstream_read(bc, 3);
+ int gain = bitstream_read_bit(bc) ? bitstream_read(bc, 4) - 7 : -1;
while (i <= index)
gaininfo[i++] = gain;
{
int i, j, vlc_index;
- quant_index_table[0] = get_bits(&q->gb, 6) - 6; // This is used later in categorize
+ quant_index_table[0] = bitstream_read(&q->bc, 6) - 6; // This is used later in categorize
for (i = 1; i < p->total_subbands; i++) {
vlc_index = i;
if (vlc_index > 13)
vlc_index = 13; // the VLC tables >13 are identical to No. 13
- j = get_vlc2(&q->gb, q->envelope_quant_index[vlc_index - 1].table,
- q->envelope_quant_index[vlc_index - 1].bits, 2);
+ j = bitstream_read_vlc(&q->bc, q->envelope_quant_index[vlc_index - 1].table,
+ q->envelope_quant_index[vlc_index - 1].bits, 2);
quant_index_table[i] = quant_index_table[i - 1] + j - 12; // differential encoding
if (quant_index_table[i] > 63 || quant_index_table[i] < -63) {
av_log(q->avctx, AV_LOG_ERROR,
int tmp_categorize_array1_idx = p->numvector_size;
int tmp_categorize_array2_idx = p->numvector_size;
- bits_left = p->bits_per_subpacket - get_bits_count(&q->gb);
+ bits_left = p->bits_per_subpacket - bitstream_tell(&q->bc);
if (bits_left > q->samples_per_channel)
bits_left = q->samples_per_channel +
vd = vd_tab[category];
result = 0;
for (i = 0; i < vpr_tab[category]; i++) {
- vlc = get_vlc2(&q->gb, q->sqvh[category].table, q->sqvh[category].bits, 3);
- if (p->bits_per_subpacket < get_bits_count(&q->gb)) {
+ vlc = bitstream_read_vlc(&q->bc, q->sqvh[category].table, q->sqvh[category].bits, 3);
+ if (p->bits_per_subpacket < bitstream_tell(&q->bc)) {
vlc = 0;
result = 1;
}
}
for (j = 0; j < vd; j++) {
if (subband_coef_index[i * vd + j]) {
- if (get_bits_count(&q->gb) < p->bits_per_subpacket) {
- subband_coef_sign[i * vd + j] = get_bits1(&q->gb);
+ if (bitstream_tell(&q->bc) < p->bits_per_subpacket) {
+ subband_coef_sign[i * vd + j] = bitstream_read_bit(&q->bc);
} else {
result = 1;
subband_coef_sign[i * vd + j] = 0;
if ((res = decode_envelope(q, p, quant_index_table)) < 0)
return res;
- q->num_vectors = get_bits(&q->gb, p->log2_numvector_size);
+ q->num_vectors = bitstream_read(&q->bc, p->log2_numvector_size);
categorize(q, p, quant_index_table, category, category_index);
expand_category(q, category, category_index);
decode_vectors(q, p, category, quant_index_table, mlt_buffer);
static void decouple_info(COOKContext *q, COOKSubpacket *p, int *decouple_tab)
{
int i;
- int vlc = get_bits1(&q->gb);
+ int vlc = bitstream_read_bit(&q->bc);
int start = cplband[p->js_subband_start];
int end = cplband[p->subbands - 1];
int length = end - start + 1;
if (vlc)
for (i = 0; i < length; i++)
- decouple_tab[start + i] = get_vlc2(&q->gb,
- p->channel_coupling.table,
- p->channel_coupling.bits, 2);
+ decouple_tab[start + i] =
+ bitstream_read_vlc(&q->bc,
+ p->channel_coupling.table,
+ p->channel_coupling.bits, 2);
else
for (i = 0; i < length; i++)
- decouple_tab[start + i] = get_bits(&q->gb, p->js_vlc_bits);
+ decouple_tab[start + i] = bitstream_read(&q->bc, p->js_vlc_bits);
}
/*
offset = decode_bytes(inbuffer, q->decoded_bytes_buffer,
p->bits_per_subpacket / 8);
- init_get_bits(&q->gb, q->decoded_bytes_buffer + offset,
- p->bits_per_subpacket);
- decode_gain_info(&q->gb, gains_ptr->now);
+ bitstream_init(&q->bc, q->decoded_bytes_buffer + offset,
+ p->bits_per_subpacket);
+ decode_gain_info(&q->bc, gains_ptr->now);
/* Swap current and previous gains */
FFSWAP(int *, gains_ptr->now, gains_ptr->previous);
offset += q->subpacket[i].size;
chidx += q->subpacket[i].num_channels;
av_log(avctx, AV_LOG_DEBUG, "subpacket[%i] %i %i\n",
- i, q->subpacket[i].size * 8, get_bits_count(&q->gb));
+ i, q->subpacket[i].size * 8, bitstream_tell(&q->bc));
}
/* Discard the first two frames: no valid audio. */