Use bitstream_init8() where appropriate

This commit is contained in:
Diego Biurrun 2016-06-06 13:20:17 +02:00
parent 71a49fe25f
commit a25dac976a
69 changed files with 98 additions and 98 deletions

View File

@ -454,7 +454,7 @@ static int decode_p_frame(FourXContext *f, const uint8_t *buf, int length)
bitstream_size / 4);
memset((uint8_t*)f->bitstream_buffer + bitstream_size,
0, AV_INPUT_BUFFER_PADDING_SIZE);
bitstream_init(&f->bc, f->bitstream_buffer, 8 * bitstream_size);
bitstream_init8(&f->bc, f->bitstream_buffer, bitstream_size);
wordstream_offset = extra + bitstream_size;
bytestream_offset = extra + bitstream_size + wordstream_size;
@ -765,7 +765,7 @@ static int decode_i_frame(FourXContext *f, const uint8_t *buf, int length)
return AVERROR_INVALIDDATA;
}
bitstream_init(&f->bc, buf + 4, 8 * bitstream_size);
bitstream_init8(&f->bc, buf + 4, bitstream_size);
prestream_size = length + buf - prestream;
@ -777,7 +777,7 @@ static int decode_i_frame(FourXContext *f, const uint8_t *buf, int length)
prestream_size / 4);
memset((uint8_t*)f->bitstream_buffer + prestream_size,
0, AV_INPUT_BUFFER_PADDING_SIZE);
bitstream_init(&f->pre_bc, f->bitstream_buffer, 8 * prestream_size);
bitstream_init8(&f->pre_bc, f->bitstream_buffer, prestream_size);
f->last_dc = 0 * 128 * 8 * 8;

View File

@ -76,7 +76,7 @@ static int adx_decode(ADXContext *c, int16_t *out, int offset,
if (scale & 0x8000)
return -1;
bitstream_init(&bc, in + 2, (BLOCK_SIZE - 2) * 8);
bitstream_init8(&bc, in + 2, BLOCK_SIZE - 2);
out += offset;
s1 = prev->s1;
s2 = prev->s2;

View File

@ -232,7 +232,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
a->bitstream_buffer[i] = ff_reverse[buf[i]];
}
bitstream_init(&a->bc, a->bitstream_buffer, buf_size * 8);
bitstream_init8(&a->bc, a->bitstream_buffer, buf_size);
for (mb_y = 0; mb_y < a->mb_height2; mb_y++) {
for (mb_x = 0; mb_x < a->mb_width2; mb_x++) {

View File

@ -297,7 +297,7 @@ static int atrac1_decode_frame(AVCodecContext *avctx, void *data,
for (ch = 0; ch < avctx->channels; ch++) {
AT1SUCtx* su = &q->SUs[ch];
bitstream_init(&bc, &buf[212 * ch], 212 * 8);
bitstream_init8(&bc, &buf[212 * ch], 212);
/* parse block_size_mode, 1st byte */
ret = at1_parse_bsm(&bc, su->log2_block_count);

View File

@ -645,7 +645,7 @@ static int decode_frame(AVCodecContext *avctx, const uint8_t *databuf,
if (q->coding_mode == JOINT_STEREO) {
/* channel coupling mode */
/* decode Sound Unit 1 */
bitstream_init(&q->bc, databuf, avctx->block_align * 8);
bitstream_init8(&q->bc, databuf, avctx->block_align);
ret = decode_channel_sound_unit(q, &q->bc, q->units, out_samples[0], 0,
JOINT_STEREO);
@ -674,7 +674,7 @@ static int decode_frame(AVCodecContext *avctx, const uint8_t *databuf,
/* set the bitstream reader at the start of the second Sound Unit*/
bitstream_init(&q->bc, ptr1, (avctx->block_align - i) * 8);
bitstream_init8(&q->bc, ptr1, avctx->block_align - i);
/* Fill the Weighting coeffs delay buffer */
memmove(q->weighting_delay, &q->weighting_delay[2],
@ -705,9 +705,9 @@ static int decode_frame(AVCodecContext *avctx, const uint8_t *databuf,
/* Decode the channel sound units. */
for (i = 0; i < avctx->channels; i++) {
/* Set the bitstream reader at the start of a channel sound unit. */
bitstream_init(&q->bc,
databuf + i * avctx->block_align / avctx->channels,
avctx->block_align * 8 / avctx->channels);
bitstream_init8(&q->bc,
databuf + i * avctx->block_align / avctx->channels,
avctx->block_align / avctx->channels);
ret = decode_channel_sound_unit(q, &q->bc, &q->units[i],
out_samples[i], i, q->coding_mode);

View File

@ -125,7 +125,7 @@ avs_decode_frame(AVCodecContext * avctx,
int map_size = ((318 / vect_w + 7) / 8) * (198 / vect_h);
if (buf_end - table < map_size)
return AVERROR_INVALIDDATA;
bitstream_init(&change_map, table, map_size * 8);
bitstream_init8(&change_map, table, map_size);
table += map_size;
}

View File

@ -73,7 +73,7 @@ static void bitplanar2chunky(CDXLVideoContext *c, int linesize, uint8_t *out)
BitstreamContext bc;
int x, y, plane;
bitstream_init(&bc, c->video, c->video_size * 8);
bitstream_init8(&bc, c->video, c->video_size);
for (plane = 0; plane < c->bpp; plane++) {
for (y = 0; y < c->avctx->height; y++) {
for (x = 0; x < c->avctx->width; x++)
@ -88,7 +88,7 @@ static void bitline2chunky(CDXLVideoContext *c, int linesize, uint8_t *out)
BitstreamContext bc;
int x, y, plane;
bitstream_init(&bc, c->video, c->video_size * 8);
bitstream_init8(&bc, c->video, c->video_size);
for (y = 0; y < c->avctx->height; y++) {
for (plane = 0; plane < c->bpp; plane++) {
for (x = 0; x < c->avctx->width; x++)

View File

@ -56,7 +56,7 @@ static int decode_frame(AVCodecContext *avctx,
p->pict_type = AV_PICTURE_TYPE_I;
p->key_frame = 1;
bitstream_init(&bc, buf, buf_size * 8);
bitstream_init8(&bc, buf, buf_size);
for (y = 0; y < avctx->height; y++) {
uint8_t *luma = &p->data[0][y * p->linesize[0]];

View File

@ -315,7 +315,7 @@ static void dss_sp_unpack_coeffs(DssSpContext *p, const uint8_t *src)
p->bits[i + 1] = src[i];
}
bitstream_init(&bc, p->bits, DSS_SP_FRAME_SIZE * 8);
bitstream_init8(&bc, p->bits, DSS_SP_FRAME_SIZE);
for (i = 0; i < 2; i++)
fparam->filter_idx[i] = bitstream_read(&bc, 5);

View File

@ -336,7 +336,7 @@ static int dvbsub_read_2bit_string(uint8_t *destbuf, int dbuf_len,
int run_length;
int pixels_read = 0;
bitstream_init(&bc, *srcbuf, buf_size << 3);
bitstream_init8(&bc, *srcbuf, buf_size);
while (bitstream_tell(&bc) < buf_size << 3 && pixels_read < dbuf_len) {
bits = bitstream_read(&bc, 2);
@ -441,7 +441,7 @@ static int dvbsub_read_4bit_string(uint8_t *destbuf, int dbuf_len,
int run_length;
int pixels_read = 0;
bitstream_init(&bc, *srcbuf, buf_size << 3);
bitstream_init8(&bc, *srcbuf, buf_size);
while (bitstream_tell(&bc) < buf_size << 3 && pixels_read < dbuf_len) {
bits = bitstream_read(&bc, 4);

View File

@ -157,7 +157,7 @@ static void tgq_decode_mb(TgqContext *s, AVFrame *frame, int mb_y, int mb_x)
mode = bytestream2_get_byte(&s->gb);
if (mode > 12) {
BitstreamContext bc;
bitstream_init(&bc, s->gb.buffer, FFMIN(s->gb.buffer_end - s->gb.buffer, mode) * 8);
bitstream_init8(&bc, s->gb.buffer, FFMIN(s->gb.buffer_end - s->gb.buffer, mode));
for (i = 0; i < 6; i++)
tgq_decode_block(s, s->block[i], &bc);
tgq_idct_put_mb(s, s->block, frame, mb_x, mb_y);

View File

@ -207,7 +207,7 @@ static int tgv_decode_inter(TgvContext *s, AVFrame *frame,
buf += num_blocks_raw * 16;
/* read compressed blocks */
bitstream_init(&bc, buf, (buf_end - buf) << 3);
bitstream_init8(&bc, buf, buf_end - buf);
for (i = 0; i < num_blocks_packed; i++) {
int tmp[4];
for (j = 0; j < 4; j++)

View File

@ -217,7 +217,7 @@ static int escape124_decode_frame(AVCodecContext *avctx,
unsigned old_stride, new_stride;
int ret;
bitstream_init(&bc, buf, buf_size * 8);
bitstream_init8(&bc, buf, buf_size);
// This call also guards the potential depth reads for the
// codebook unpacking.

View File

@ -216,7 +216,7 @@ static int escape130_decode_frame(AVCodecContext *avctx, void *data,
if ((ret = ff_get_buffer(avctx, pic, 0)) < 0)
return ret;
bitstream_init(&bc, buf + 16, (buf_size - 16) * 8);
bitstream_init8(&bc, buf + 16, buf_size - 16);
new_y = s->new_y;
new_cb = s->new_u;

View File

@ -289,7 +289,7 @@ int ff_ccitt_unpack(AVCodecContext *avctx, const uint8_t *src, int srcsize,
ref[0] = avctx->width;
ref[1] = 0;
ref[2] = 0;
bitstream_init(&bc, src, srcsize * 8);
bitstream_init8(&bc, src, srcsize);
for (j = 0; j < height; j++) {
runend = runs + runsize;
if (compr == TIFF_G4) {

View File

@ -268,7 +268,7 @@ static int flashsv_decode_frame(AVCodecContext *avctx, void *data,
if (buf_size < 4)
return -1;
bitstream_init(&bc, avpkt->data, buf_size * 8);
bitstream_init8(&bc, avpkt->data, buf_size);
/* start to parse the bitstream */
s->block_width = 16 * (bitstream_read(&bc, 4) + 1);

View File

@ -111,7 +111,7 @@ static int fraps2_decode_plane(FrapsContext *s, uint8_t *dst, int stride, int w,
s->bdsp.bswap_buf((uint32_t *) s->tmpbuf,
(const uint32_t *) src, size >> 2);
bitstream_init(&bc, s->tmpbuf, size * 8);
bitstream_init8(&bc, s->tmpbuf, size);
for (j = 0; j < h; j++) {
for (i = 0; i < w*step; i += step) {
dst[i] = bitstream_read_vlc(&bc, vlc.table, VLC_BITS, 3);

View File

@ -298,7 +298,7 @@ static int jpg_decode_data(JPGContext *c, int width, int height,
return ret;
jpg_unescape(src, src_size, c->buf, &unesc_size);
memset(c->buf + unesc_size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
bitstream_init(&bc, c->buf, unesc_size * 8);
bitstream_init8(&bc, c->buf, unesc_size);
width = FFALIGN(width, 16);
mb_w = width >> 4;
@ -1015,7 +1015,7 @@ static void kempf_restore_buf(const uint8_t *src, int len,
int i, j, nb, col;
int align_width = FFALIGN(width, 16);
bitstream_init(&bc, src, len * 8);
bitstream_init8(&bc, src, len);
if (npal <= 2) nb = 1;
else if (npal <= 4) nb = 2;

View File

@ -103,7 +103,7 @@ static int g722_decode_frame(AVCodecContext *avctx, void *data,
}
out_buf = (int16_t *)frame->data[0];
bitstream_init(&bc, avpkt->data, avpkt->size * 8);
bitstream_init8(&bc, avpkt->data, avpkt->size);
for (j = 0; j < avpkt->size; j++) {
int ilow, ihigh, rlow, rhigh, dhigh;

View File

@ -72,7 +72,7 @@ static int unpack_bitstream(G723_1_Context *p, const uint8_t *buf,
int ad_cb_len;
int temp, info_bits, i;
bitstream_init(&bc, buf, buf_size * 8);
bitstream_init8(&bc, buf, buf_size);
/* Extract frame type and rate info */
info_bits = bitstream_read(&bc, 2);

View File

@ -443,7 +443,7 @@ static int g726_decode_frame(AVCodecContext *avctx, void *data,
}
samples = (int16_t *)frame->data[0];
bitstream_init(&bc, buf, buf_size * 8);
bitstream_init8(&bc, buf, buf_size);
while (out_samples--)
*samples++ = g726_decode(c, bitstream_read(&bc, c->code_size));

View File

@ -88,7 +88,7 @@ static int gsm_decode_frame(AVCodecContext *avctx, void *data,
switch (avctx->codec_id) {
case AV_CODEC_ID_GSM:
bitstream_init(&bc, buf, buf_size * 8);
bitstream_init8(&bc, buf, buf_size);
if (bitstream_read(&bc, 4) != 0xd)
av_log(avctx, AV_LOG_WARNING, "Missing GSM magic!\n");
res = gsm_decode_block(avctx, samples, &bc, GSM_13000);

View File

@ -160,8 +160,8 @@ static int hq_decode_frame(HQContext *ctx, AVFrame *pic,
"Invalid slice size %zu.\n", data_size);
break;
}
bitstream_init(&bc, src + slice_off[slice],
(slice_off[slice + 1] - slice_off[slice]) * 8);
bitstream_init8(&bc, src + slice_off[slice],
slice_off[slice + 1] - slice_off[slice]);
for (i = 0; i < (next_off - start_off) * profile->tab_w; i++) {
ret = hq_decode_mb(ctx, pic, &bc, perm[0] * 16, perm[1] * 16);
@ -285,8 +285,8 @@ static int hqa_decode_frame(HQContext *ctx, AVFrame *pic, size_t data_size)
"Invalid slice size %zu.\n", data_size);
break;
}
bitstream_init(&bc, src + slice_off[slice],
(slice_off[slice + 1] - slice_off[slice]) * 8);
bitstream_init8(&bc, src + slice_off[slice],
slice_off[slice + 1] - slice_off[slice]);
ret = hqa_decode_slice(ctx, pic, &bc, quant, slice, width, height);
if (ret < 0)

View File

@ -1016,7 +1016,7 @@ static int imc_decode_frame(AVCodecContext *avctx, void *data,
q->bdsp.bswap16_buf(buf16, (const uint16_t *) buf, IMC_BLOCK_SIZE / 2);
bitstream_init(&q->bc, (const uint8_t*)buf16, IMC_BLOCK_SIZE * 8);
bitstream_init8(&q->bc, (const uint8_t *)buf16, IMC_BLOCK_SIZE);
buf += IMC_BLOCK_SIZE;

View File

@ -171,7 +171,7 @@ static int ir2_decode_frame(AVCodecContext *avctx,
buf[i] = ff_reverse[buf[i]];
#endif
bitstream_init(&s->bc, buf + start, (buf_size - start) * 8);
bitstream_init8(&s->bc, buf + start, buf_size - start);
ltab = buf[0x22] & 3;
ctab = buf[0x22] >> 2;

View File

@ -857,7 +857,7 @@ static int decode_plane(Indeo3DecodeContext *ctx, AVCodecContext *avctx,
ctx->mc_vectors = num_vectors ? data : 0;
/* init the bitreader */
bitstream_init(&ctx->bc, &data[num_vectors * 2], (data_size - num_vectors * 2) << 3);
bitstream_init8(&ctx->bc, &data[num_vectors * 2], data_size - num_vectors * 2);
ctx->skip_bits = 0;
ctx->need_resync = 0;

View File

@ -898,7 +898,7 @@ static void ipvideo_decode_opcodes(IpvideoContext *s, AVFrame *frame)
s->upper_motion_limit_offset = (s->avctx->height - 8) * frame->linesize[0]
+ (s->avctx->width - 8) * (1 + s->is_16bpp);
bitstream_init(&bc, s->decoding_map, s->decoding_map_size * 8);
bitstream_init8(&bc, s->decoding_map, s->decoding_map_size);
for (y = 0; y < s->avctx->height; y += 8) {
for (x = 0; x < s->avctx->width; x += 8) {
opcode = bitstream_read(&bc, 4);

View File

@ -1029,7 +1029,7 @@ int ff_ivi_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
int buf_size = avpkt->size;
int result, p, b;
bitstream_init(&ctx->bc, buf, buf_size * 8);
bitstream_init8(&ctx->bc, buf, buf_size);
ctx->frame_data = buf;
ctx->frame_size = buf_size;

View File

@ -164,7 +164,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
if (video_type == 0 || video_type == 1) {
BitstreamContext bc;
bitstream_init(&bc, buf, 8 * FFMIN(video_size, buf_end - buf));
bitstream_init8(&bc, buf, FFMIN(video_size, buf_end - buf));
for (j = 0; j < avctx->height; j += 8)
for (i = 0; i < avctx->width; i += 8)

View File

@ -436,7 +436,7 @@ static int lag_decode_arith_plane(LagarithContext *l, uint8_t *dst,
offset += 4;
}
bitstream_init(&bc, src + offset, src_size * 8);
bitstream_init8(&bc, src + offset, src_size);
if (lag_read_prob_header(&rac, &bc) < 0)
return -1;

View File

@ -172,7 +172,7 @@ static int metasound_read_bitstream(AVCodecContext *avctx, TwinVQContext *tctx,
BitstreamContext bc;
int i, j, k;
bitstream_init(&bc, buf, buf_size * 8);
bitstream_init8(&bc, buf, buf_size);
for (tctx->cur_frame = 0; tctx->cur_frame < tctx->frames_per_packet;
tctx->cur_frame++) {

View File

@ -426,7 +426,7 @@ static int mimic_decode_frame(AVCodecContext *avctx, void *data,
ctx->bbdsp.bswap_buf(ctx->swap_buf,
(const uint32_t *) (buf + MIMIC_HEADER_SIZE),
swap_buf_size >> 2);
bitstream_init(&ctx->bc, ctx->swap_buf, swap_buf_size << 3);
bitstream_init8(&ctx->bc, ctx->swap_buf, swap_buf_size);
res = decode(ctx, quality, num_coeffs, !is_pframe);
ff_thread_report_progress(&ctx->frames[ctx->cur_index], INT_MAX, 0);

View File

@ -332,7 +332,7 @@ static int mlp_parse(AVCodecParserContext *s,
BitstreamContext bc;
MLPHeaderInfo mh;
bitstream_init(&bc, buf + 4, (buf_size - 4) << 3);
bitstream_init8(&bc, buf + 4, buf_size - 4);
if (ff_mlp_read_major_sync(avctx, &mh, &bc) < 0)
goto lost_sync;

View File

@ -1095,7 +1095,7 @@ static int read_access_unit(AVCodecContext *avctx, void* data,
if (length < 4 || length > buf_size)
return AVERROR_INVALIDDATA;
bitstream_init(&bc, (buf + 4), (length - 4) * 8);
bitstream_init8(&bc, buf + 4, length - 4);
m->is_major_sync_unit = 0;
if (bitstream_peek(&bc, 31) == (0xf8726fba >> 1)) {
@ -1175,7 +1175,7 @@ static int read_access_unit(AVCodecContext *avctx, void* data,
for (substr = 0; substr <= m->max_decoded_substream; substr++) {
SubStream *s = &m->substream[substr];
bitstream_init(&bc, buf, substream_data_len[substr] * 8);
bitstream_init8(&bc, buf, substream_data_len[substr]);
m->matrix_changed = 0;
memset(m->filter_changed, 0, sizeof(m->filter_changed));

View File

@ -285,7 +285,7 @@ static int mp_decode_frame(AVCodecContext *avctx,
if (buf_size & 3)
memcpy(mp->bswapbuf + (buf_size & ~3), buf + (buf_size & ~3), buf_size & 3);
memset(mp->bswapbuf + buf_size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
bitstream_init(&bc, mp->bswapbuf, buf_size * 8);
bitstream_init8(&bc, mp->bswapbuf, buf_size);
memset(mp->changes_map, 0, avctx->width * avctx->height);
for (i = !(avctx->extradata[1] & 2); i < 2; ++i) {

View File

@ -238,7 +238,7 @@ static int mpc7_decode_frame(AVCodecContext * avctx, void *data,
return AVERROR(ENOMEM);
c->bdsp.bswap_buf((uint32_t *) c->bits, (const uint32_t *) buf,
buf_size >> 2);
bitstream_init(&bc, c->bits, buf_size * 8);
bitstream_init8(&bc, c->bits, buf_size);
bitstream_skip(&bc, skip);
/* read subband indexes */

View File

@ -259,7 +259,7 @@ static int mpc8_decode_frame(AVCodecContext * avctx, void *data,
memset(c->Q, 0, sizeof(c->Q));
c->last_bits_used = 0;
}
bitstream_init(bc, buf, buf_size * 8);
bitstream_init8(bc, buf, buf_size);
bitstream_skip(bc, c->last_bits_used & 7);
if(keyframe)

View File

@ -32,7 +32,7 @@ int ff_msgsm_decode_block(AVCodecContext *avctx, int16_t *samples,
{
int res;
BitstreamContext bc;
bitstream_init(&bc, buf, GSM_MS_BLOCK_SIZE * 8);
bitstream_init8(&bc, buf, GSM_MS_BLOCK_SIZE);
res = gsm_decode_block(avctx, samples, &bc, mode);
if (res < 0)
return res;

View File

@ -67,7 +67,7 @@ static void nelly_decode_block(NellyMoserDecodeContext *s,
int bits[NELLY_BUF_LEN];
unsigned char v;
bitstream_init(&s->bc, block, NELLY_BLOCK_LEN * 8);
bitstream_init8(&s->bc, block, NELLY_BLOCK_LEN);
bptr = buf;
pptr = pows;
@ -88,7 +88,7 @@ static void nelly_decode_block(NellyMoserDecodeContext *s,
for (i = 0; i < 2; i++) {
aptr = audio + i * NELLY_BUF_LEN;
bitstream_init(&s->bc, block, NELLY_BLOCK_LEN * 8);
bitstream_init8(&s->bc, block, NELLY_BLOCK_LEN);
bitstream_skip(&s->bc, NELLY_HEADER_BITS + i * NELLY_DETAIL_BITS);
for (j = 0; j < NELLY_FILL_LEN; j++) {

View File

@ -183,7 +183,7 @@ static int pcx_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
BitstreamContext s;
for (y = 0; y < h; y++) {
bitstream_init(&s, scanline, bytes_per_scanline << 3);
bitstream_init8(&s, scanline, bytes_per_scanline);
pcx_rle_decode(&gb, scanline, bytes_per_scanline, compressed);

View File

@ -719,7 +719,7 @@ static int qcelp_decode_frame(AVCodecContext *avctx, void *data,
qcelp_unpacking_bitmaps_lengths[q->bitrate];
uint8_t *unpacked_data = (uint8_t *)&q->frame;
bitstream_init(&q->bc, buf, 8 * buf_size);
bitstream_init8(&q->bc, buf, buf_size);
memset(&q->frame, 0, sizeof(QCELPFrame));

View File

@ -1105,7 +1105,7 @@ static void process_subpacket_9(QDM2Context *q, QDM2SubPNode *node)
BitstreamContext bc;
int i, j, k, n, ch, run, level, diff;
bitstream_init(&bc, node->packet->data, node->packet->size * 8);
bitstream_init8(&bc, node->packet->data, node->packet->size);
n = coeff_per_sb_for_avg[q->coeff_per_sb_select][QDM2_SB_USED(q->sub_sampling) - 1] + 1;
@ -1142,7 +1142,7 @@ static void process_subpacket_10(QDM2Context *q, QDM2SubPNode *node)
BitstreamContext bc;
if (node) {
bitstream_init(&bc, node->packet->data, node->packet->size * 8);
bitstream_init8(&bc, node->packet->data, node->packet->size);
init_tone_level_dequantization(q, &bc);
fill_tone_level_array(q, 1);
} else {
@ -1252,7 +1252,7 @@ static void qdm2_decode_super_block(QDM2Context *q)
average_quantized_coeffs(q); // average elements in quantized_coeffs[max_ch][10][8]
bitstream_init(&bc, q->compressed_data, q->compressed_size * 8);
bitstream_init8(&bc, q->compressed_data, q->compressed_size);
qdm2_decode_sub_packet_header(&bc, &header);
if (header.type < 2 || header.type >= 8) {
@ -1264,7 +1264,7 @@ static void qdm2_decode_super_block(QDM2Context *q)
q->superblocktype_2_3 = (header.type == 2 || header.type == 3);
packet_bytes = (q->compressed_size - bitstream_tell(&bc) / 8);
bitstream_init(&bc, header.data, header.size * 8);
bitstream_init8(&bc, header.data, header.size);
if (header.type == 2 || header.type == 4 || header.type == 5) {
int csum = 257 * bitstream_read(&bc, 8);
@ -1300,7 +1300,7 @@ static void qdm2_decode_super_block(QDM2Context *q)
q->sub_packet_list_A[i - 1].next = &q->sub_packet_list_A[i];
/* seek to next block */
bitstream_init(&bc, header.data, header.size * 8);
bitstream_init8(&bc, header.data, header.size);
bitstream_skip(&bc, next_index * 8);
if (next_index >= header.size)
@ -1495,7 +1495,7 @@ static void qdm2_decode_fft_packets(QDM2Context *q)
return;
/* decode FFT tones */
bitstream_init(&bc, packet->data, packet->size * 8);
bitstream_init8(&bc, packet->data, packet->size);
if (packet->type >= 32 && packet->type < 48 && !fft_subpackets[packet->type - 16])
unknown_flag = 1;

View File

@ -92,7 +92,7 @@ static int ra144_decode_frame(AVCodecContext * avctx, void *data,
}
samples = (int16_t *)frame->data[0];
bitstream_init(&bc, buf, FRAMESIZE * 8);
bitstream_init8(&bc, buf, FRAMESIZE);
for (i = 0; i < LPC_ORDER; i++)
lpc_refl[i] = ff_lpc_refl_cb[i][bitstream_read(&bc, sizes[i])];

View File

@ -198,7 +198,7 @@ static int ra288_decode_frame(AVCodecContext * avctx, void *data,
}
out = (float *)frame->data[0];
bitstream_init(&bc, buf, avctx->block_align * 8);
bitstream_init8(&bc, buf, avctx->block_align);
for (i=0; i < RA288_BLOCKS_PER_FRAME; i++) {
float gain = amptable[bitstream_read(&bc, 3)];

View File

@ -302,7 +302,7 @@ static int decode_header_trees(SmackVContext *smk) {
full_size = AV_RL32(smk->avctx->extradata + 8);
type_size = AV_RL32(smk->avctx->extradata + 12);
bitstream_init(&bc, smk->avctx->extradata + 16, (smk->avctx->extradata_size - 16) * 8);
bitstream_init8(&bc, smk->avctx->extradata + 16, smk->avctx->extradata_size - 16);
if (!bitstream_read_bit(&bc)) {
av_log(smk->avctx, AV_LOG_INFO, "Skipping MMAP tree\n");
@ -417,7 +417,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
last_reset(smk->mclr_tbl, smk->mclr_last);
last_reset(smk->full_tbl, smk->full_last);
last_reset(smk->type_tbl, smk->type_last);
bitstream_init(&bc, avpkt->data + 769, (avpkt->size - 769) * 8);
bitstream_init8(&bc, avpkt->data + 769, avpkt->size - 769);
blk = 0;
bw = avctx->width >> 2;
@ -618,7 +618,7 @@ static int smka_decode_frame(AVCodecContext *avctx, void *data,
unp_size = AV_RL32(buf);
bitstream_init(&bc, buf + 4, (buf_size - 4) * 8);
bitstream_init8(&bc, buf + 4, buf_size - 4);
if (!bitstream_read_bit(&bc)) {
av_log(avctx, AV_LOG_INFO, "Sound: no data\n");

View File

@ -616,7 +616,7 @@ static int svq1_decode_frame(AVCodecContext *avctx, void *data,
svq1_pmv *pmv;
/* initialize bit buffer */
bitstream_init(&s->bc, buf, buf_size * 8);
bitstream_init8(&s->bc, buf, buf_size);
/* decode frame header */
s->frame_code = bitstream_read(&s->bc, 22);
@ -647,7 +647,7 @@ static int svq1_decode_frame(AVCodecContext *avctx, void *data,
for (i = 0; i < 4; i++)
src[i] = ((src[i] << 16) | (src[i] >> 16)) ^ src[7 - i];
bitstream_init(&s->bc, buf, buf_size * 8);
bitstream_init8(&s->bc, buf, buf_size);
bitstream_skip(&s->bc, 22);
}

View File

@ -45,7 +45,7 @@ static const unsigned char *seq_unpack_rle_block(const unsigned char *src,
int code_table[64];
/* get the rle codes */
bitstream_init(&bc, src, (src_end - src) * 8);
bitstream_init8(&bc, src, src_end - src);
for (i = 0, sz = 0; i < 64 && sz < dst_size; i++) {
if (bitstream_bits_left(&bc) < 4)
return NULL;
@ -113,7 +113,7 @@ static const unsigned char *seq_decode_op1(SeqVideoContext *seq,
return NULL;
color_table = src;
src += len;
bitstream_init(&bc, src, bits * 8 * 8);
bitstream_init8(&bc, src, bits * 8);
src += bits * 8;
for (b = 0; b < 8; b++) {
for (i = 0; i < 8; i++)
@ -188,7 +188,7 @@ static int seqvideo_decode(SeqVideoContext *seq, const unsigned char *data, int
if (flags & 2) {
if (data_end - data < 128)
return AVERROR_INVALIDDATA;
bitstream_init(&bc, data, 128 * 8);
bitstream_init8(&bc, data, 128);
data += 128;
for (y = 0; y < 128; y += 8)
for (x = 0; x < 256; x += 8) {

View File

@ -306,7 +306,7 @@ static int tm2_read_stream(TM2Context *ctx, const uint8_t *buf, int stream_id, i
pos = bytestream2_tell(&gb);
if (skip <= pos)
return AVERROR_INVALIDDATA;
bitstream_init(&ctx->bc, buf + pos, (skip - pos) * 8);
bitstream_init8(&ctx->bc, buf + pos, skip - pos);
if ((ret = tm2_read_deltas(ctx, stream_id)) < 0)
return ret;
bytestream2_skip(&gb, ((bitstream_tell(&ctx->bc) + 31) >> 5) << 2);
@ -323,7 +323,7 @@ static int tm2_read_stream(TM2Context *ctx, const uint8_t *buf, int stream_id, i
pos = bytestream2_tell(&gb);
if (skip <= pos)
return AVERROR_INVALIDDATA;
bitstream_init(&ctx->bc, buf + pos, (skip - pos) * 8);
bitstream_init8(&ctx->bc, buf + pos, skip - pos);
if ((ret = tm2_build_huff_table(ctx, &codes)) < 0)
return ret;
bytestream2_skip(&gb, ((bitstream_tell(&ctx->bc) + 31) >> 5) << 2);
@ -342,7 +342,7 @@ static int tm2_read_stream(TM2Context *ctx, const uint8_t *buf, int stream_id, i
pos = bytestream2_tell(&gb);
if (skip <= pos)
return AVERROR_INVALIDDATA;
bitstream_init(&ctx->bc, buf + pos, (skip - pos) * 8);
bitstream_init8(&ctx->bc, buf + pos, skip - pos);
for (i = 0; i < toks; i++) {
if (bitstream_bits_left(&ctx->bc) <= 0) {
av_log(ctx->avctx, AV_LOG_ERROR, "Incorrect number of tokens: %i\n", toks);

View File

@ -82,7 +82,7 @@ static void truespeech_read_frame(TSContext *dec, const uint8_t *input)
BitstreamContext bc;
dec->bdsp.bswap_buf((uint32_t *) dec->buffer, (const uint32_t *) input, 8);
bitstream_init(&bc, dec->buffer, 32 * 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)];

View File

@ -195,7 +195,7 @@ static int tscc2_decode_slice(TSCC2Context *c, int mb_y,
int i, mb_x, q, ret;
int off;
bitstream_init(&c->bc, buf, buf_size * 8);
bitstream_init8(&c->bc, buf, buf_size);
for (mb_x = 0; mb_x < c->mb_width; mb_x++) {
q = c->slice_quants[mb_x + c->mb_width * mb_y];

View File

@ -197,7 +197,7 @@ static av_cold int tta_decode_init(AVCodecContext * avctx)
if (avctx->extradata_size < 30)
return -1;
bitstream_init(&s->bc, avctx->extradata, avctx->extradata_size * 8);
bitstream_init8(&s->bc, avctx->extradata, avctx->extradata_size);
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);
@ -315,7 +315,7 @@ static int tta_decode_frame(AVCodecContext *avctx, void *data,
return AVERROR_INVALIDDATA;
}
bitstream_init(&s->bc, buf, buf_size * 8);
bitstream_init8(&s->bc, buf, buf_size);
/* get output buffer */
frame->nb_samples = framelen;

View File

@ -259,7 +259,7 @@ static int twinvq_read_bitstream(AVCodecContext *avctx, TwinVQContext *tctx,
BitstreamContext bc;
int i, j, k;
bitstream_init(&bc, buf, buf_size * 8);
bitstream_init8(&bc, buf, buf_size);
bitstream_skip(&bc, bitstream_read(&bc, 8));
bits->window_type = bitstream_read(&bc, TWINVQ_WINDOW_TYPE_BITS);

View File

@ -147,7 +147,7 @@ static int decode_plane(UtvideoContext *c, int plane_no,
c->bdsp.bswap_buf((uint32_t *) c->slice_bits,
(uint32_t *) c->slice_bits,
(slice_data_end - slice_data_start + 3) >> 2);
bitstream_init(&bc, c->slice_bits, slice_size * 8);
bitstream_init8(&bc, c->slice_bits, slice_size);
prev = 0x80;
for (j = sstart; j < send; j++) {

View File

@ -140,7 +140,7 @@ static int vble_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
if (version != 1)
av_log(avctx, AV_LOG_WARNING, "Unsupported VBLE Version: %d\n", version);
bitstream_init(&bc, src + 4, (avpkt->size - 4) * 8);
bitstream_init8(&bc, src + 4, avpkt->size - 4);
/* Unpack */
if (vble_unpack(ctx, &bc) < 0) {

View File

@ -1039,7 +1039,7 @@ static int apply_color_indexing_transform(WebPContext *s)
for (y = 0; y < img->frame->height; y++) {
p = GET_PIXEL(img->frame, 0, y);
memcpy(line, p, img->frame->linesize[0]);
bitstream_init(&bc_g, line, img->frame->linesize[0] * 8);
bitstream_init8(&bc_g, line, img->frame->linesize[0]);
bitstream_skip(&bc_g, 16);
i = 0;
for (x = 0; x < img->frame->width; x++) {
@ -1083,7 +1083,7 @@ static int vp8_lossless_decode_frame(AVCodecContext *avctx, AVFrame *p,
avctx->pix_fmt = AV_PIX_FMT_ARGB;
}
ret = bitstream_init(&s->bc, data_start, data_size * 8);
ret = bitstream_init8(&s->bc, data_start, data_size);
if (ret < 0)
return ret;

View File

@ -90,7 +90,7 @@ static int decode_frame(AVCodecContext *avctx,
for (i = 8; i < buf_size; i++)
rbuf[i] = ff_reverse[buf[i]];
bitstream_init(&l->bc, rbuf + 8, (buf_size - 8) * 8);
bitstream_init8(&l->bc, rbuf + 8, buf_size - 8);
if (buf[2] >> 4 == 6)
l->shift = 2;

View File

@ -129,7 +129,7 @@ static int xan_huffman_decode(unsigned char *dest, int dest_len,
if (ptr_len < 0)
return AVERROR_INVALIDDATA;
bitstream_init(&bc, ptr, ptr_len * 8);
bitstream_init8(&bc, ptr, ptr_len);
while (val != 0x16) {
unsigned idx = val - 0x17 + bitstream_read_bit(&bc) * byte;

View File

@ -147,7 +147,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
#endif
// process RLE-compressed data
bitstream_init(&bc, buf, (buf_end - buf) * 8);
bitstream_init8(&bc, buf, buf_end - buf);
bitmap = sub->rects[0]->data[0];
for (y = 0; y < h; y++) {
// interlaced: do odd lines

View File

@ -34,7 +34,7 @@ static int h261_probe(AVProbeData *p)
int src_fmt=0;
BitstreamContext bc;
bitstream_init(&bc, p->buf, p->buf_size * 8);
bitstream_init8(&bc, p->buf, p->buf_size);
for(i=0; i<p->buf_size*8; i++){
if ((code & 0x01ff0000) || !(code & 0xff00)) {

View File

@ -2138,7 +2138,7 @@ static int mov_read_stsz(MOVContext *c, AVIOContext *pb, MOVAtom atom)
return ret;
}
bitstream_init(&bc, buf, 8 * num_bytes);
bitstream_init8(&bc, buf, num_bytes);
for (i = 0; i < entries && !pb->eof_reached; i++) {
sc->sample_sizes[i] = bitstream_read(&bc, field_size);

View File

@ -252,7 +252,7 @@ static int mov_write_ac3_tag(AVIOContext *pb, MOVTrack *track)
avio_wb32(pb, 11);
ffio_wfourcc(pb, "dac3");
bitstream_init(&bc, track->vos_data + 4, (track->vos_len - 4) * 8);
bitstream_init8(&bc, track->vos_data + 4, track->vos_len - 4);
fscod = bitstream_read(&bc, 2);
frmsizecod = bitstream_read(&bc, 6);
bsid = bitstream_read(&bc, 5);
@ -470,7 +470,7 @@ static int mov_write_dvc1_structs(MOVTrack *track, uint8_t *buf)
if (size <= 0)
continue;
unescaped_size = vc1_unescape_buffer(start + 4, size, unescaped);
bitstream_init(&bc, unescaped, 8 * unescaped_size);
bitstream_init8(&bc, unescaped, unescaped_size);
if (AV_RB32(start) == VC1_CODE_SEQHDR) {
int profile = bitstream_read(&bc, 2);
if (profile != PROFILE_ADVANCED) {

View File

@ -742,7 +742,7 @@ static int read_sl_header(PESContext *pes, SLConfigDescr *sl,
int padding_flag = 0, padding_bits = 0, inst_bitrate_flag = 0;
int dts_flag = -1, cts_flag = -1;
int64_t dts = AV_NOPTS_VALUE, cts = AV_NOPTS_VALUE;
bitstream_init(&bc, buf, buf_size * 8);
bitstream_init8(&bc, buf, buf_size);
if (sl->use_au_start)
au_start_flag = bitstream_read_bit(&bc);

View File

@ -41,7 +41,7 @@ flac_header (AVFormatContext * s, int idx)
if (os->buf[os->pstart] == 0xff)
return 0;
bitstream_init(&bc, os->buf + os->pstart, os->psize * 8);
bitstream_init8(&bc, os->buf + os->pstart, os->psize);
bitstream_skip(&bc, 1); /* metadata_last */
mdt = bitstream_read(&bc, 7);

View File

@ -63,7 +63,7 @@ static int theora_header(AVFormatContext *s, int idx)
BitstreamContext bc;
AVRational timebase;
bitstream_init(&bc, os->buf + os->pstart, os->psize * 8);
bitstream_init8(&bc, os->buf + os->pstart, os->psize);
/* 0x80"theora" */
bitstream_skip(&bc, 7 * 8);

View File

@ -262,7 +262,7 @@ ff_rdt_parse_header(const uint8_t *buf, int len,
* [2] http://www.wireshark.org/docs/dfref/r/rdt.html and
* http://anonsvn.wireshark.org/viewvc/trunk/epan/dissectors/packet-rdt.c
*/
bitstream_init(&bc, buf, len << 3);
bitstream_init8(&bc, buf, len);
len_included = bitstream_read_bit(&bc);
need_reliable = bitstream_read_bit(&bc);
set_id = bitstream_read(&bc, 5);

View File

@ -103,7 +103,7 @@ static int parse_fmtp_config(AVStream *st, const char *value)
if (!config)
return AVERROR(ENOMEM);
ff_hex_to_data(config, value);
bitstream_init(&bc, config, len * 8);
bitstream_init8(&bc, config, len);
audio_mux_version = bitstream_read(&bc, 1);
same_time_framing = bitstream_read(&bc, 1);
bitstream_skip(&bc, 6); /* num_sub_frames */

View File

@ -136,7 +136,7 @@ static int rtp_parse_mp4_au(PayloadContext *data, const uint8_t *buf, int len)
if (len < data->au_headers_length_bytes)
return AVERROR_INVALIDDATA;
bitstream_init(&bctx, buf, data->au_headers_length_bytes * 8);
bitstream_init8(&bctx, buf, data->au_headers_length_bytes);
/* XXX: Wrong if optional additional sections are present (cts, dts etc...) */
au_header_size = data->sizelength + data->indexlength;

View File

@ -72,7 +72,7 @@ static int qt_rtp_parse_packet(AVFormatContext *s, PayloadContext *qt,
* The RTP payload is described in:
* http://developer.apple.com/quicktime/icefloe/dispatch026.html
*/
bitstream_init(&bc, buf, len << 3);
bitstream_init8(&bc, buf, len);
ffio_init_context(&pb, buf, len, 0, NULL, NULL, NULL, NULL);
if (len < 4)

View File

@ -112,7 +112,7 @@ void ff_rtp_send_h263_rfc2190(AVFormatContext *s1, const uint8_t *buf, int size,
s->timestamp = s->cur_timestamp;
bitstream_init(&bc, buf, size * 8);
bitstream_init8(&bc, buf, size);
if (bitstream_read(&bc, 22) == 0x20) { /* Picture Start Code */
info.tr = bitstream_read(&bc, 8);
bitstream_skip(&bc, 2); /* PTYPE start, H.261 disambiguation */