summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexandra Hájková <alexandra@khirnov.net>2016-04-14 10:54:11 +0200
committerAlexandra Hájková <alexandra@khirnov.net>2016-05-22 16:47:59 +0200
commit568ae58966a241a9180a8dbf5b910e0e79b80bae (patch)
tree6d0d090d5433d28511d9e5977f81a80c87b68e4c
parenta703c8c98ade444fc61a833e81e8a6c5da67403d (diff)
tta: convert to the new bitstream reader
-rw-r--r--libavcodec/tta.c48
1 files changed, 24 insertions, 24 deletions
diff --git a/libavcodec/tta.c b/libavcodec/tta.c
index 7399827f2f..2b895d8bc7 100644
--- a/libavcodec/tta.c
+++ b/libavcodec/tta.c
@@ -30,7 +30,7 @@
#define BITSTREAM_READER_LE
#include <limits.h>
#include "avcodec.h"
-#include "get_bits.h"
+#include "bitstream.h"
#include "internal.h"
#include "libavutil/crc.h"
@@ -57,7 +57,7 @@ typedef struct TTAChannel {
typedef struct TTAContext {
AVCodecContext *avctx;
- GetBitContext gb;
+ BitstreamContext bc;
const AVCRC *crc_table;
int format, channels, bps;
@@ -169,12 +169,12 @@ static void rice_init(TTARice *c, uint32_t k0, uint32_t k1)
c->sum1 = shift_16[k1];
}
-static int tta_get_unary(GetBitContext *gb)
+static int tta_get_unary(BitstreamContext *bc)
{
int ret = 0;
// count ones
- while (get_bits_left(gb) > 0 && get_bits1(gb))
+ while (bitstream_bits_left(bc) > 0 && bitstream_read_bit(bc))
ret++;
return ret;
}
@@ -204,8 +204,8 @@ static av_cold int tta_decode_init(AVCodecContext * avctx)
if (avctx->extradata_size < 30)
return -1;
- init_get_bits(&s->gb, avctx->extradata, avctx->extradata_size * 8);
- if (show_bits_long(&s->gb, 32) == AV_RL32("TTA1"))
+ bitstream_init(&s->bc, avctx->extradata, avctx->extradata_size * 8);
+ if (bitstream_peek(&s->bc, 32) == AV_RL32("TTA1"))
{
if (avctx->err_recognition & AV_EF_CRCCHECK) {
s->crc_table = av_crc_get_table(AV_CRC_32_IEEE_LE);
@@ -213,9 +213,9 @@ static av_cold int tta_decode_init(AVCodecContext * avctx)
}
/* signature */
- skip_bits_long(&s->gb, 32);
+ bitstream_skip(&s->bc, 32);
- s->format = get_bits(&s->gb, 16);
+ s->format = bitstream_read(&s->bc, 16);
if (s->format > 2) {
av_log(s->avctx, AV_LOG_ERROR, "Invalid format\n");
return -1;
@@ -224,12 +224,12 @@ static av_cold int tta_decode_init(AVCodecContext * avctx)
avpriv_report_missing_feature(s->avctx, "Encrypted TTA");
return AVERROR_PATCHWELCOME;
}
- avctx->channels = s->channels = get_bits(&s->gb, 16);
- avctx->bits_per_coded_sample = get_bits(&s->gb, 16);
+ avctx->channels = s->channels = bitstream_read(&s->bc, 16);
+ avctx->bits_per_coded_sample = bitstream_read(&s->bc, 16);
s->bps = (avctx->bits_per_coded_sample + 7) / 8;
- avctx->sample_rate = get_bits_long(&s->gb, 32);
- s->data_length = get_bits_long(&s->gb, 32);
- skip_bits_long(&s->gb, 32); // CRC32 of header
+ avctx->sample_rate = bitstream_read(&s->bc, 32);
+ s->data_length = bitstream_read(&s->bc, 32);
+ bitstream_skip(&s->bc, 32); // CRC32 of header
if (s->channels == 0) {
av_log(s->avctx, AV_LOG_ERROR, "Invalid number of channels\n");
@@ -279,8 +279,8 @@ static av_cold int tta_decode_init(AVCodecContext * avctx)
if (ret < 0 && avctx->err_recognition & AV_EF_EXPLODE)
return AVERROR_INVALIDDATA;
}
- skip_bits_long(&s->gb, 32 * total_frames);
- skip_bits_long(&s->gb, 32); // CRC32 of seektable
+ bitstream_skip(&s->bc, 32 * total_frames);
+ bitstream_skip(&s->bc, 32); // CRC32 of seektable
if(s->frame_length >= UINT_MAX / (s->channels * sizeof(int32_t))){
av_log(avctx, AV_LOG_ERROR, "frame_length too large\n");
@@ -322,7 +322,7 @@ static int tta_decode_frame(AVCodecContext *avctx, void *data,
return AVERROR_INVALIDDATA;
}
- init_get_bits(&s->gb, buf, buf_size*8);
+ bitstream_init(&s->bc, buf, buf_size*8);
/* get output buffer */
frame->nb_samples = framelen;
@@ -350,7 +350,7 @@ static int tta_decode_frame(AVCodecContext *avctx, void *data,
uint32_t unary, depth, k;
int32_t value;
- unary = tta_get_unary(&s->gb);
+ unary = tta_get_unary(&s->bc);
if (unary == 0) {
depth = 0;
@@ -361,17 +361,17 @@ static int tta_decode_frame(AVCodecContext *avctx, void *data,
unary--;
}
- if (get_bits_left(&s->gb) < k) {
+ if (bitstream_bits_left(&s->bc) < k) {
ret = AVERROR_INVALIDDATA;
goto error;
}
if (k) {
- if (k > MIN_CACHE_BITS) {
+ if (k > 25) {
ret = AVERROR_INVALIDDATA;
goto error;
}
- value = (unary << k) + get_bits(&s->gb, k);
+ value = (unary << k) + bitstream_read(&s->bc, k);
} else
value = unary;
@@ -421,19 +421,19 @@ static int tta_decode_frame(AVCodecContext *avctx, void *data,
cur_chan = 0;
i++;
// check for last frame
- if (i == s->last_frame_length && get_bits_left(&s->gb) / 8 == 4) {
+ if (i == s->last_frame_length && bitstream_bits_left(&s->bc) / 8 == 4) {
frame->nb_samples = framelen = s->last_frame_length;
break;
}
}
}
- align_get_bits(&s->gb);
- if (get_bits_left(&s->gb) < 32) {
+ bitstream_align(&s->bc);
+ if (bitstream_bits_left(&s->bc) < 32) {
ret = AVERROR_INVALIDDATA;
goto error;
}
- skip_bits_long(&s->gb, 32); // frame crc
+ bitstream_skip(&s->bc, 32); // frame crc
// convert to output buffer
if (s->bps == 2) {