diff options
author | Alexandra Hájková <alexandra@khirnov.net> | 2016-04-10 20:16:42 +0200 |
---|---|---|
committer | Alexandra Hájková <alexandra@khirnov.net> | 2016-05-22 16:47:58 +0200 |
commit | 20a0b3cffb7f29f9cf76f90320d7d674253aa6a1 (patch) | |
tree | 8dd3582331fecf8346e7c679cf8c016bf2f1b88b | |
parent | 12c07b9d6d7d0ab995d851b02344027ea75b7dc5 (diff) |
metasound: convert to the new bitstream reader
-rw-r--r-- | libavcodec/metasound.c | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/libavcodec/metasound.c b/libavcodec/metasound.c index dbb2a63e3e..1e7a343f0f 100644 --- a/libavcodec/metasound.c +++ b/libavcodec/metasound.c @@ -29,7 +29,7 @@ #include "libavutil/channel_layout.h" #include "libavutil/float_dsp.h" #include "avcodec.h" -#include "get_bits.h" +#include "bitstream.h" #include "fft.h" #include "internal.h" #include "lsp.h" @@ -148,7 +148,7 @@ static void dec_bark_env(TwinVQContext *tctx, const uint8_t *in, int use_hist, } } -static void read_cb_data(TwinVQContext *tctx, GetBitContext *gb, +static void read_cb_data(TwinVQContext *tctx, BitstreamContext *bc, uint8_t *dst, enum TwinVQFrameType ftype) { int i; @@ -156,8 +156,8 @@ static void read_cb_data(TwinVQContext *tctx, GetBitContext *gb, for (i = 0; i < tctx->n_div[ftype]; i++) { int bs_second_part = (i >= tctx->bits_main_spec_change[ftype]); - *dst++ = get_bits(gb, tctx->bits_main_spec[0][ftype][bs_second_part]); - *dst++ = get_bits(gb, tctx->bits_main_spec[1][ftype][bs_second_part]); + *dst++ = bitstream_read(bc, tctx->bits_main_spec[0][ftype][bs_second_part]); + *dst++ = bitstream_read(bc, tctx->bits_main_spec[1][ftype][bs_second_part]); } } @@ -168,16 +168,16 @@ static int metasound_read_bitstream(AVCodecContext *avctx, TwinVQContext *tctx, const TwinVQModeTab *mtab = tctx->mtab; int channels = tctx->avctx->channels; int sub; - GetBitContext gb; + BitstreamContext bc; int i, j, k; - init_get_bits(&gb, buf, buf_size * 8); + bitstream_init(&bc, buf, buf_size * 8); for (tctx->cur_frame = 0; tctx->cur_frame < tctx->frames_per_packet; tctx->cur_frame++) { bits = tctx->bits + tctx->cur_frame; - bits->window_type = get_bits(&gb, TWINVQ_WINDOW_TYPE_BITS); + bits->window_type = bitstream_read(&bc, TWINVQ_WINDOW_TYPE_BITS); if (bits->window_type > 8) { av_log(avctx, AV_LOG_ERROR, "Invalid window type, broken sample?\n"); @@ -189,51 +189,51 @@ static int metasound_read_bitstream(AVCodecContext *avctx, TwinVQContext *tctx, sub = mtab->fmode[bits->ftype].sub; if (bits->ftype != TWINVQ_FT_SHORT && !tctx->is_6kbps) - get_bits(&gb, 2); + bitstream_read(&bc, 2); - read_cb_data(tctx, &gb, bits->main_coeffs, bits->ftype); + read_cb_data(tctx, &bc, bits->main_coeffs, bits->ftype); for (i = 0; i < channels; i++) for (j = 0; j < sub; j++) for (k = 0; k < mtab->fmode[bits->ftype].bark_n_coef; k++) bits->bark1[i][j][k] = - get_bits(&gb, mtab->fmode[bits->ftype].bark_n_bit); + bitstream_read(&bc, mtab->fmode[bits->ftype].bark_n_bit); for (i = 0; i < channels; i++) for (j = 0; j < sub; j++) - bits->bark_use_hist[i][j] = get_bits1(&gb); + bits->bark_use_hist[i][j] = bitstream_read_bit(&bc); if (bits->ftype == TWINVQ_FT_LONG) { for (i = 0; i < channels; i++) - bits->gain_bits[i] = get_bits(&gb, TWINVQ_GAIN_BITS); + bits->gain_bits[i] = bitstream_read(&bc, TWINVQ_GAIN_BITS); } else { for (i = 0; i < channels; i++) { - bits->gain_bits[i] = get_bits(&gb, TWINVQ_GAIN_BITS); + bits->gain_bits[i] = bitstream_read(&bc, TWINVQ_GAIN_BITS); for (j = 0; j < sub; j++) bits->sub_gain_bits[i * sub + j] = - get_bits(&gb, TWINVQ_SUB_GAIN_BITS); + bitstream_read(&bc, TWINVQ_SUB_GAIN_BITS); } } for (i = 0; i < channels; i++) { - bits->lpc_hist_idx[i] = get_bits(&gb, mtab->lsp_bit0); - bits->lpc_idx1[i] = get_bits(&gb, mtab->lsp_bit1); + bits->lpc_hist_idx[i] = bitstream_read(&bc, mtab->lsp_bit0); + bits->lpc_idx1[i] = bitstream_read(&bc, mtab->lsp_bit1); for (j = 0; j < mtab->lsp_split; j++) - bits->lpc_idx2[i][j] = get_bits(&gb, mtab->lsp_bit2); + bits->lpc_idx2[i][j] = bitstream_read(&bc, mtab->lsp_bit2); } if (bits->ftype == TWINVQ_FT_LONG) { - read_cb_data(tctx, &gb, bits->ppc_coeffs, 3); + read_cb_data(tctx, &bc, bits->ppc_coeffs, 3); for (i = 0; i < channels; i++) { - bits->p_coef[i] = get_bits(&gb, mtab->ppc_period_bit); - bits->g_coef[i] = get_bits(&gb, mtab->pgain_bit); + bits->p_coef[i] = bitstream_read(&bc, mtab->ppc_period_bit); + bits->g_coef[i] = bitstream_read(&bc, mtab->pgain_bit); } } // subframes are aligned to nibbles - if (get_bits_count(&gb) & 3) - skip_bits(&gb, 4 - (get_bits_count(&gb) & 3)); + if (bitstream_tell(&bc) & 3) + bitstream_skip(&bc, 4 - (bitstream_tell(&bc) & 3)); } return 0; |