Use bitstream_init8() where appropriate

pull/273/head
Diego Biurrun 9 years ago
parent 71a49fe25f
commit a25dac976a
  1. 6
      libavcodec/4xm.c
  2. 2
      libavcodec/adxdec.c
  3. 2
      libavcodec/asvdec.c
  4. 2
      libavcodec/atrac1.c
  5. 10
      libavcodec/atrac3.c
  6. 2
      libavcodec/avs.c
  7. 4
      libavcodec/cdxl.c
  8. 2
      libavcodec/cljrdec.c
  9. 2
      libavcodec/dss_sp.c
  10. 4
      libavcodec/dvbsubdec.c
  11. 2
      libavcodec/eatgq.c
  12. 2
      libavcodec/eatgv.c
  13. 2
      libavcodec/escape124.c
  14. 2
      libavcodec/escape130.c
  15. 2
      libavcodec/faxcompr.c
  16. 2
      libavcodec/flashsv.c
  17. 2
      libavcodec/fraps.c
  18. 4
      libavcodec/g2meet.c
  19. 2
      libavcodec/g722dec.c
  20. 2
      libavcodec/g723_1dec.c
  21. 2
      libavcodec/g726.c
  22. 2
      libavcodec/gsmdec.c
  23. 8
      libavcodec/hq_hqa.c
  24. 2
      libavcodec/imc.c
  25. 2
      libavcodec/indeo2.c
  26. 2
      libavcodec/indeo3.c
  27. 2
      libavcodec/interplayvideo.c
  28. 2
      libavcodec/ivi.c
  29. 2
      libavcodec/jvdec.c
  30. 2
      libavcodec/lagarith.c
  31. 2
      libavcodec/metasound.c
  32. 2
      libavcodec/mimic.c
  33. 2
      libavcodec/mlp_parser.c
  34. 4
      libavcodec/mlpdec.c
  35. 2
      libavcodec/motionpixels.c
  36. 2
      libavcodec/mpc7.c
  37. 2
      libavcodec/mpc8.c
  38. 2
      libavcodec/msgsmdec.c
  39. 4
      libavcodec/nellymoserdec.c
  40. 2
      libavcodec/pcx.c
  41. 2
      libavcodec/qcelpdec.c
  42. 12
      libavcodec/qdm2.c
  43. 2
      libavcodec/ra144dec.c
  44. 2
      libavcodec/ra288.c
  45. 6
      libavcodec/smacker.c
  46. 4
      libavcodec/svq1dec.c
  47. 6
      libavcodec/tiertexseqv.c
  48. 6
      libavcodec/truemotion2.c
  49. 2
      libavcodec/truespeech.c
  50. 2
      libavcodec/tscc2.c
  51. 4
      libavcodec/tta.c
  52. 2
      libavcodec/twinvqdec.c
  53. 2
      libavcodec/utvideodec.c
  54. 2
      libavcodec/vble.c
  55. 4
      libavcodec/webp.c
  56. 2
      libavcodec/wnv1.c
  57. 2
      libavcodec/xan.c
  58. 2
      libavcodec/xsubdec.c
  59. 2
      libavformat/h261dec.c
  60. 2
      libavformat/mov.c
  61. 4
      libavformat/movenc.c
  62. 2
      libavformat/mpegts.c
  63. 2
      libavformat/oggparseflac.c
  64. 2
      libavformat/oggparsetheora.c
  65. 2
      libavformat/rdt.c
  66. 2
      libavformat/rtpdec_latm.c
  67. 2
      libavformat/rtpdec_mpeg4.c
  68. 2
      libavformat/rtpdec_qt.c
  69. 2
      libavformat/rtpenc_h263_rfc2190.c

@ -454,7 +454,7 @@ static int decode_p_frame(FourXContext *f, const uint8_t *buf, int length)
bitstream_size / 4); bitstream_size / 4);
memset((uint8_t*)f->bitstream_buffer + bitstream_size, memset((uint8_t*)f->bitstream_buffer + bitstream_size,
0, AV_INPUT_BUFFER_PADDING_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; wordstream_offset = extra + bitstream_size;
bytestream_offset = extra + bitstream_size + wordstream_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; 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; 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); prestream_size / 4);
memset((uint8_t*)f->bitstream_buffer + prestream_size, memset((uint8_t*)f->bitstream_buffer + prestream_size,
0, AV_INPUT_BUFFER_PADDING_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; f->last_dc = 0 * 128 * 8 * 8;

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

@ -232,7 +232,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
a->bitstream_buffer[i] = ff_reverse[buf[i]]; 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_y = 0; mb_y < a->mb_height2; mb_y++) {
for (mb_x = 0; mb_x < a->mb_width2; mb_x++) { for (mb_x = 0; mb_x < a->mb_width2; mb_x++) {

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

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

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

@ -73,7 +73,7 @@ static void bitplanar2chunky(CDXLVideoContext *c, int linesize, uint8_t *out)
BitstreamContext bc; BitstreamContext bc;
int x, y, plane; 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 (plane = 0; plane < c->bpp; plane++) {
for (y = 0; y < c->avctx->height; y++) { for (y = 0; y < c->avctx->height; y++) {
for (x = 0; x < c->avctx->width; x++) for (x = 0; x < c->avctx->width; x++)
@ -88,7 +88,7 @@ static void bitline2chunky(CDXLVideoContext *c, int linesize, uint8_t *out)
BitstreamContext bc; BitstreamContext bc;
int x, y, plane; 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 (y = 0; y < c->avctx->height; y++) {
for (plane = 0; plane < c->bpp; plane++) { for (plane = 0; plane < c->bpp; plane++) {
for (x = 0; x < c->avctx->width; x++) for (x = 0; x < c->avctx->width; x++)

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

@ -315,7 +315,7 @@ static void dss_sp_unpack_coeffs(DssSpContext *p, const uint8_t *src)
p->bits[i + 1] = src[i]; 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++) for (i = 0; i < 2; i++)
fparam->filter_idx[i] = bitstream_read(&bc, 5); fparam->filter_idx[i] = bitstream_read(&bc, 5);

@ -336,7 +336,7 @@ static int dvbsub_read_2bit_string(uint8_t *destbuf, int dbuf_len,
int run_length; int run_length;
int pixels_read = 0; 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) { while (bitstream_tell(&bc) < buf_size << 3 && pixels_read < dbuf_len) {
bits = bitstream_read(&bc, 2); 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 run_length;
int pixels_read = 0; 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) { while (bitstream_tell(&bc) < buf_size << 3 && pixels_read < dbuf_len) {
bits = bitstream_read(&bc, 4); bits = bitstream_read(&bc, 4);

@ -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); mode = bytestream2_get_byte(&s->gb);
if (mode > 12) { if (mode > 12) {
BitstreamContext bc; 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++) for (i = 0; i < 6; i++)
tgq_decode_block(s, s->block[i], &bc); tgq_decode_block(s, s->block[i], &bc);
tgq_idct_put_mb(s, s->block, frame, mb_x, mb_y); tgq_idct_put_mb(s, s->block, frame, mb_x, mb_y);

@ -207,7 +207,7 @@ static int tgv_decode_inter(TgvContext *s, AVFrame *frame,
buf += num_blocks_raw * 16; buf += num_blocks_raw * 16;
/* read compressed blocks */ /* 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++) { for (i = 0; i < num_blocks_packed; i++) {
int tmp[4]; int tmp[4];
for (j = 0; j < 4; j++) for (j = 0; j < 4; j++)

@ -217,7 +217,7 @@ static int escape124_decode_frame(AVCodecContext *avctx,
unsigned old_stride, new_stride; unsigned old_stride, new_stride;
int ret; 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 // This call also guards the potential depth reads for the
// codebook unpacking. // codebook unpacking.

@ -216,7 +216,7 @@ static int escape130_decode_frame(AVCodecContext *avctx, void *data,
if ((ret = ff_get_buffer(avctx, pic, 0)) < 0) if ((ret = ff_get_buffer(avctx, pic, 0)) < 0)
return ret; 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_y = s->new_y;
new_cb = s->new_u; new_cb = s->new_u;

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

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

@ -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, s->bdsp.bswap_buf((uint32_t *) s->tmpbuf,
(const uint32_t *) src, size >> 2); (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 (j = 0; j < h; j++) {
for (i = 0; i < w*step; i += step) { for (i = 0; i < w*step; i += step) {
dst[i] = bitstream_read_vlc(&bc, vlc.table, VLC_BITS, 3); dst[i] = bitstream_read_vlc(&bc, vlc.table, VLC_BITS, 3);

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

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

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

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

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

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

@ -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); 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; buf += IMC_BLOCK_SIZE;

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

@ -857,7 +857,7 @@ static int decode_plane(Indeo3DecodeContext *ctx, AVCodecContext *avctx,
ctx->mc_vectors = num_vectors ? data : 0; ctx->mc_vectors = num_vectors ? data : 0;
/* init the bitreader */ /* 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->skip_bits = 0;
ctx->need_resync = 0; ctx->need_resync = 0;

@ -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->upper_motion_limit_offset = (s->avctx->height - 8) * frame->linesize[0]
+ (s->avctx->width - 8) * (1 + s->is_16bpp); + (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 (y = 0; y < s->avctx->height; y += 8) {
for (x = 0; x < s->avctx->width; x += 8) { for (x = 0; x < s->avctx->width; x += 8) {
opcode = bitstream_read(&bc, 4); opcode = bitstream_read(&bc, 4);

@ -1029,7 +1029,7 @@ int ff_ivi_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
int buf_size = avpkt->size; int buf_size = avpkt->size;
int result, p, b; 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_data = buf;
ctx->frame_size = buf_size; ctx->frame_size = buf_size;

@ -164,7 +164,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
if (video_type == 0 || video_type == 1) { if (video_type == 0 || video_type == 1) {
BitstreamContext bc; 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 (j = 0; j < avctx->height; j += 8)
for (i = 0; i < avctx->width; i += 8) for (i = 0; i < avctx->width; i += 8)

@ -436,7 +436,7 @@ static int lag_decode_arith_plane(LagarithContext *l, uint8_t *dst,
offset += 4; 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) if (lag_read_prob_header(&rac, &bc) < 0)
return -1; return -1;

@ -172,7 +172,7 @@ static int metasound_read_bitstream(AVCodecContext *avctx, TwinVQContext *tctx,
BitstreamContext bc; BitstreamContext bc;
int i, j, k; 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; for (tctx->cur_frame = 0; tctx->cur_frame < tctx->frames_per_packet;
tctx->cur_frame++) { tctx->cur_frame++) {

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

@ -332,7 +332,7 @@ static int mlp_parse(AVCodecParserContext *s,
BitstreamContext bc; BitstreamContext bc;
MLPHeaderInfo mh; 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) if (ff_mlp_read_major_sync(avctx, &mh, &bc) < 0)
goto lost_sync; goto lost_sync;

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

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

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

@ -259,7 +259,7 @@ static int mpc8_decode_frame(AVCodecContext * avctx, void *data,
memset(c->Q, 0, sizeof(c->Q)); memset(c->Q, 0, sizeof(c->Q));
c->last_bits_used = 0; 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); bitstream_skip(bc, c->last_bits_used & 7);
if(keyframe) if(keyframe)

@ -32,7 +32,7 @@ int ff_msgsm_decode_block(AVCodecContext *avctx, int16_t *samples,
{ {
int res; int res;
BitstreamContext bc; 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); res = gsm_decode_block(avctx, samples, &bc, mode);
if (res < 0) if (res < 0)
return res; return res;

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

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

@ -719,7 +719,7 @@ static int qcelp_decode_frame(AVCodecContext *avctx, void *data,
qcelp_unpacking_bitmaps_lengths[q->bitrate]; qcelp_unpacking_bitmaps_lengths[q->bitrate];
uint8_t *unpacked_data = (uint8_t *)&q->frame; 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)); memset(&q->frame, 0, sizeof(QCELPFrame));

@ -1105,7 +1105,7 @@ static void process_subpacket_9(QDM2Context *q, QDM2SubPNode *node)
BitstreamContext bc; BitstreamContext bc;
int i, j, k, n, ch, run, level, diff; 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; 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; BitstreamContext bc;
if (node) { 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); init_tone_level_dequantization(q, &bc);
fill_tone_level_array(q, 1); fill_tone_level_array(q, 1);
} else { } 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] 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); qdm2_decode_sub_packet_header(&bc, &header);
if (header.type < 2 || header.type >= 8) { 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); q->superblocktype_2_3 = (header.type == 2 || header.type == 3);
packet_bytes = (q->compressed_size - bitstream_tell(&bc) / 8); 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) { if (header.type == 2 || header.type == 4 || header.type == 5) {
int csum = 257 * bitstream_read(&bc, 8); 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]; q->sub_packet_list_A[i - 1].next = &q->sub_packet_list_A[i];
/* seek to next block */ /* 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); bitstream_skip(&bc, next_index * 8);
if (next_index >= header.size) if (next_index >= header.size)
@ -1495,7 +1495,7 @@ static void qdm2_decode_fft_packets(QDM2Context *q)
return; return;
/* decode FFT tones */ /* 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]) if (packet->type >= 32 && packet->type < 48 && !fft_subpackets[packet->type - 16])
unknown_flag = 1; unknown_flag = 1;

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

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

@ -302,7 +302,7 @@ static int decode_header_trees(SmackVContext *smk) {
full_size = AV_RL32(smk->avctx->extradata + 8); full_size = AV_RL32(smk->avctx->extradata + 8);
type_size = AV_RL32(smk->avctx->extradata + 12); 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)) { if (!bitstream_read_bit(&bc)) {
av_log(smk->avctx, AV_LOG_INFO, "Skipping MMAP tree\n"); 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->mclr_tbl, smk->mclr_last);
last_reset(smk->full_tbl, smk->full_last); last_reset(smk->full_tbl, smk->full_last);
last_reset(smk->type_tbl, smk->type_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; blk = 0;
bw = avctx->width >> 2; bw = avctx->width >> 2;
@ -618,7 +618,7 @@ static int smka_decode_frame(AVCodecContext *avctx, void *data,
unp_size = AV_RL32(buf); 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)) { if (!bitstream_read_bit(&bc)) {
av_log(avctx, AV_LOG_INFO, "Sound: no data\n"); av_log(avctx, AV_LOG_INFO, "Sound: no data\n");

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

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

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

@ -82,7 +82,7 @@ static void truespeech_read_frame(TSContext *dec, const uint8_t *input)
BitstreamContext bc; BitstreamContext bc;
dec->bdsp.bswap_buf((uint32_t *) dec->buffer, (const uint32_t *) input, 8); 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[7] = ts_codebook[7][bitstream_read(&bc, 3)];
dec->vector[6] = ts_codebook[6][bitstream_read(&bc, 3)]; dec->vector[6] = ts_codebook[6][bitstream_read(&bc, 3)];

@ -195,7 +195,7 @@ static int tscc2_decode_slice(TSCC2Context *c, int mb_y,
int i, mb_x, q, ret; int i, mb_x, q, ret;
int off; 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++) { for (mb_x = 0; mb_x < c->mb_width; mb_x++) {
q = c->slice_quants[mb_x + c->mb_width * mb_y]; q = c->slice_quants[mb_x + c->mb_width * mb_y];

@ -197,7 +197,7 @@ static av_cold int tta_decode_init(AVCodecContext * avctx)
if (avctx->extradata_size < 30) if (avctx->extradata_size < 30)
return -1; 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 (bitstream_peek(&s->bc, 32) == AV_RL32("TTA1")) {
if (avctx->err_recognition & AV_EF_CRCCHECK) { if (avctx->err_recognition & AV_EF_CRCCHECK) {
s->crc_table = av_crc_get_table(AV_CRC_32_IEEE_LE); 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; return AVERROR_INVALIDDATA;
} }
bitstream_init(&s->bc, buf, buf_size * 8); bitstream_init8(&s->bc, buf, buf_size);
/* get output buffer */ /* get output buffer */
frame->nb_samples = framelen; frame->nb_samples = framelen;

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

@ -147,7 +147,7 @@ static int decode_plane(UtvideoContext *c, int plane_no,
c->bdsp.bswap_buf((uint32_t *) c->slice_bits, c->bdsp.bswap_buf((uint32_t *) c->slice_bits,
(uint32_t *) c->slice_bits, (uint32_t *) c->slice_bits,
(slice_data_end - slice_data_start + 3) >> 2); (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; prev = 0x80;
for (j = sstart; j < send; j++) { for (j = sstart; j < send; j++) {

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

@ -1039,7 +1039,7 @@ static int apply_color_indexing_transform(WebPContext *s)
for (y = 0; y < img->frame->height; y++) { for (y = 0; y < img->frame->height; y++) {
p = GET_PIXEL(img->frame, 0, y); p = GET_PIXEL(img->frame, 0, y);
memcpy(line, p, img->frame->linesize[0]); 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); bitstream_skip(&bc_g, 16);
i = 0; i = 0;
for (x = 0; x < img->frame->width; x++) { 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; 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) if (ret < 0)
return ret; return ret;

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

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

@ -147,7 +147,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
#endif #endif
// process RLE-compressed data // 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]; bitmap = sub->rects[0]->data[0];
for (y = 0; y < h; y++) { for (y = 0; y < h; y++) {
// interlaced: do odd lines // interlaced: do odd lines

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

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

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

@ -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 padding_flag = 0, padding_bits = 0, inst_bitrate_flag = 0;
int dts_flag = -1, cts_flag = -1; int dts_flag = -1, cts_flag = -1;
int64_t dts = AV_NOPTS_VALUE, cts = AV_NOPTS_VALUE; 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) if (sl->use_au_start)
au_start_flag = bitstream_read_bit(&bc); au_start_flag = bitstream_read_bit(&bc);

@ -41,7 +41,7 @@ flac_header (AVFormatContext * s, int idx)
if (os->buf[os->pstart] == 0xff) if (os->buf[os->pstart] == 0xff)
return 0; 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 */ bitstream_skip(&bc, 1); /* metadata_last */
mdt = bitstream_read(&bc, 7); mdt = bitstream_read(&bc, 7);

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

@ -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 * [2] http://www.wireshark.org/docs/dfref/r/rdt.html and
* http://anonsvn.wireshark.org/viewvc/trunk/epan/dissectors/packet-rdt.c * 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); len_included = bitstream_read_bit(&bc);
need_reliable = bitstream_read_bit(&bc); need_reliable = bitstream_read_bit(&bc);
set_id = bitstream_read(&bc, 5); set_id = bitstream_read(&bc, 5);

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

@ -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) if (len < data->au_headers_length_bytes)
return AVERROR_INVALIDDATA; 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...) */ /* XXX: Wrong if optional additional sections are present (cts, dts etc...) */
au_header_size = data->sizelength + data->indexlength; au_header_size = data->sizelength + data->indexlength;

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

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

Loading…
Cancel
Save