diff options
Diffstat (limited to 'libavcodec/truespeech.c')
-rw-r--r-- | libavcodec/truespeech.c | 100 |
1 files changed, 48 insertions, 52 deletions
diff --git a/libavcodec/truespeech.c b/libavcodec/truespeech.c index 6b9afaedda..d4ddfcbf9c 100644 --- a/libavcodec/truespeech.c +++ b/libavcodec/truespeech.c @@ -2,33 +2,31 @@ * DSP Group TrueSpeech compatible decoder * Copyright (c) 2005 Konstantin Shishkov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * - * Libav is distributed in the hope that it will be useful, + * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "libavutil/channel_layout.h" #include "libavutil/intreadwrite.h" - #include "avcodec.h" -#include "bitstream.h" #include "bswapdsp.h" +#include "get_bits.h" #include "internal.h" #include "truespeech_data.h" - /** * @file * TrueSpeech decoder. @@ -79,50 +77,50 @@ static av_cold int truespeech_decode_init(AVCodecContext * avctx) static void truespeech_read_frame(TSContext *dec, const uint8_t *input) { - BitstreamContext bc; + GetBitContext gb; dec->bdsp.bswap_buf((uint32_t *) dec->buffer, (const uint32_t *) input, 8); - bitstream_init8(&bc, dec->buffer, 32); - - dec->vector[7] = ts_codebook[7][bitstream_read(&bc, 3)]; - dec->vector[6] = ts_codebook[6][bitstream_read(&bc, 3)]; - dec->vector[5] = ts_codebook[5][bitstream_read(&bc, 3)]; - dec->vector[4] = ts_codebook[4][bitstream_read(&bc, 4)]; - dec->vector[3] = ts_codebook[3][bitstream_read(&bc, 4)]; - dec->vector[2] = ts_codebook[2][bitstream_read(&bc, 4)]; - dec->vector[1] = ts_codebook[1][bitstream_read(&bc, 5)]; - dec->vector[0] = ts_codebook[0][bitstream_read(&bc, 5)]; - dec->flag = bitstream_read_bit(&bc); - - dec->offset1[0] = bitstream_read(&bc, 4) << 4; - dec->offset2[3] = bitstream_read(&bc, 7); - dec->offset2[2] = bitstream_read(&bc, 7); - dec->offset2[1] = bitstream_read(&bc, 7); - dec->offset2[0] = bitstream_read(&bc, 7); - - dec->offset1[1] = bitstream_read(&bc, 4); - dec->pulseval[1] = bitstream_read(&bc, 14); - dec->pulseval[0] = bitstream_read(&bc, 14); - - dec->offset1[1] |= bitstream_read(&bc, 4) << 4; - dec->pulseval[3] = bitstream_read(&bc, 14); - dec->pulseval[2] = bitstream_read(&bc, 14); - - dec->offset1[0] |= bitstream_read_bit(&bc); - dec->pulsepos[0] = bitstream_read(&bc, 27); - dec->pulseoff[0] = bitstream_read(&bc, 4); - - dec->offset1[0] |= bitstream_read_bit(&bc) << 1; - dec->pulsepos[1] = bitstream_read(&bc, 27); - dec->pulseoff[1] = bitstream_read(&bc, 4); - - dec->offset1[0] |= bitstream_read_bit(&bc) << 2; - dec->pulsepos[2] = bitstream_read(&bc, 27); - dec->pulseoff[2] = bitstream_read(&bc, 4); - - dec->offset1[0] |= bitstream_read_bit(&bc) << 3; - dec->pulsepos[3] = bitstream_read(&bc, 27); - dec->pulseoff[3] = bitstream_read(&bc, 4); + init_get_bits(&gb, dec->buffer, 32 * 8); + + dec->vector[7] = ts_codebook[7][get_bits(&gb, 3)]; + dec->vector[6] = ts_codebook[6][get_bits(&gb, 3)]; + dec->vector[5] = ts_codebook[5][get_bits(&gb, 3)]; + dec->vector[4] = ts_codebook[4][get_bits(&gb, 4)]; + dec->vector[3] = ts_codebook[3][get_bits(&gb, 4)]; + dec->vector[2] = ts_codebook[2][get_bits(&gb, 4)]; + dec->vector[1] = ts_codebook[1][get_bits(&gb, 5)]; + dec->vector[0] = ts_codebook[0][get_bits(&gb, 5)]; + dec->flag = get_bits1(&gb); + + dec->offset1[0] = get_bits(&gb, 4) << 4; + dec->offset2[3] = get_bits(&gb, 7); + dec->offset2[2] = get_bits(&gb, 7); + dec->offset2[1] = get_bits(&gb, 7); + dec->offset2[0] = get_bits(&gb, 7); + + dec->offset1[1] = get_bits(&gb, 4); + dec->pulseval[1] = get_bits(&gb, 14); + dec->pulseval[0] = get_bits(&gb, 14); + + dec->offset1[1] |= get_bits(&gb, 4) << 4; + dec->pulseval[3] = get_bits(&gb, 14); + dec->pulseval[2] = get_bits(&gb, 14); + + dec->offset1[0] |= get_bits1(&gb); + dec->pulsepos[0] = get_bits_long(&gb, 27); + dec->pulseoff[0] = get_bits(&gb, 4); + + dec->offset1[0] |= get_bits1(&gb) << 1; + dec->pulsepos[1] = get_bits_long(&gb, 27); + dec->pulseoff[1] = get_bits(&gb, 4); + + dec->offset1[0] |= get_bits1(&gb) << 2; + dec->pulsepos[2] = get_bits_long(&gb, 27); + dec->pulseoff[2] = get_bits(&gb, 4); + + dec->offset1[0] |= get_bits1(&gb) << 3; + dec->pulsepos[3] = get_bits_long(&gb, 27); + dec->pulseoff[3] = get_bits(&gb, 4); } static void truespeech_correlate_filter(TSContext *dec) @@ -327,10 +325,8 @@ static int truespeech_decode_frame(AVCodecContext *avctx, void *data, /* get output buffer */ frame->nb_samples = iterations * 240; - if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) { - av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); + if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) return ret; - } samples = (int16_t *)frame->data[0]; memset(samples, 0, iterations * 240 * sizeof(*samples)); |