Commit c3defda0 authored by Alexandra Hájková's avatar Alexandra Hájková Committed by Diego Biurrun

indeo: Convert to the new bitstream reader

parent f5b7bd2a
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
#define BITSTREAM_READER_LE #define BITSTREAM_READER_LE
#include "avcodec.h" #include "avcodec.h"
#include "get_bits.h" #include "bitstream.h"
#include "indeo2data.h" #include "indeo2data.h"
#include "internal.h" #include "internal.h"
#include "mathops.h" #include "mathops.h"
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
typedef struct Ir2Context{ typedef struct Ir2Context{
AVCodecContext *avctx; AVCodecContext *avctx;
AVFrame *picture; AVFrame *picture;
GetBitContext gb; BitstreamContext bc;
int decode_delta; int decode_delta;
} Ir2Context; } Ir2Context;
...@@ -44,9 +44,9 @@ typedef struct Ir2Context{ ...@@ -44,9 +44,9 @@ typedef struct Ir2Context{
static VLC ir2_vlc; static VLC ir2_vlc;
/* Indeo 2 codes are in range 0x01..0x7F and 0x81..0x90 */ /* Indeo 2 codes are in range 0x01..0x7F and 0x81..0x90 */
static inline int ir2_get_code(GetBitContext *gb) static inline int ir2_get_code(BitstreamContext *bc)
{ {
return get_vlc2(gb, ir2_vlc.table, CODE_VLC_BITS, 1) + 1; return bitstream_read_vlc(bc, ir2_vlc.table, CODE_VLC_BITS, 1) + 1;
} }
static int ir2_decode_plane(Ir2Context *ctx, int width, int height, uint8_t *dst, static int ir2_decode_plane(Ir2Context *ctx, int width, int height, uint8_t *dst,
...@@ -63,7 +63,7 @@ static int ir2_decode_plane(Ir2Context *ctx, int width, int height, uint8_t *dst ...@@ -63,7 +63,7 @@ static int ir2_decode_plane(Ir2Context *ctx, int width, int height, uint8_t *dst
/* first line contain absolute values, other lines contain deltas */ /* first line contain absolute values, other lines contain deltas */
while (out < width) { while (out < width) {
c = ir2_get_code(&ctx->gb); c = ir2_get_code(&ctx->bc);
if (c >= 0x80) { /* we have a run */ if (c >= 0x80) { /* we have a run */
c -= 0x7F; c -= 0x7F;
if (out + c*2 > width) if (out + c*2 > width)
...@@ -80,7 +80,7 @@ static int ir2_decode_plane(Ir2Context *ctx, int width, int height, uint8_t *dst ...@@ -80,7 +80,7 @@ static int ir2_decode_plane(Ir2Context *ctx, int width, int height, uint8_t *dst
for (j = 1; j < height; j++) { for (j = 1; j < height; j++) {
out = 0; out = 0;
while (out < width) { while (out < width) {
c = ir2_get_code(&ctx->gb); c = ir2_get_code(&ctx->bc);
if (c >= 0x80) { /* we have a skip */ if (c >= 0x80) { /* we have a skip */
c -= 0x7F; c -= 0x7F;
if (out + c*2 > width) if (out + c*2 > width)
...@@ -119,7 +119,7 @@ static int ir2_decode_plane_inter(Ir2Context *ctx, int width, int height, uint8_ ...@@ -119,7 +119,7 @@ static int ir2_decode_plane_inter(Ir2Context *ctx, int width, int height, uint8_
for (j = 0; j < height; j++) { for (j = 0; j < height; j++) {
out = 0; out = 0;
while (out < width) { while (out < width) {
c = ir2_get_code(&ctx->gb); c = ir2_get_code(&ctx->bc);
if (c >= 0x80) { /* we have a skip */ if (c >= 0x80) { /* we have a skip */
c -= 0x7F; c -= 0x7F;
out += c * 2; out += c * 2;
...@@ -171,7 +171,7 @@ static int ir2_decode_frame(AVCodecContext *avctx, ...@@ -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
init_get_bits(&s->gb, buf + start, (buf_size - start) * 8); bitstream_init(&s->bc, buf + start, (buf_size - start) * 8);
ltab = buf[0x22] & 3; ltab = buf[0x22] & 3;
ctab = buf[0x22] >> 2; ctab = buf[0x22] >> 2;
......
...@@ -31,9 +31,10 @@ ...@@ -31,9 +31,10 @@
#include "libavutil/imgutils.h" #include "libavutil/imgutils.h"
#include "libavutil/intreadwrite.h" #include "libavutil/intreadwrite.h"
#include "avcodec.h" #include "avcodec.h"
#include "bitstream.h"
#include "bytestream.h" #include "bytestream.h"
#include "get_bits.h"
#include "hpeldsp.h" #include "hpeldsp.h"
#include "internal.h" #include "internal.h"
...@@ -83,7 +84,7 @@ typedef struct Indeo3DecodeContext { ...@@ -83,7 +84,7 @@ typedef struct Indeo3DecodeContext {
AVCodecContext *avctx; AVCodecContext *avctx;
HpelDSPContext hdsp; HpelDSPContext hdsp;
GetBitContext gb; BitstreamContext bc;
int need_resync; int need_resync;
int skip_bits; int skip_bits;
const uint8_t *next_cell_data; const uint8_t *next_cell_data;
...@@ -725,8 +726,8 @@ enum { ...@@ -725,8 +726,8 @@ enum {
ctx->need_resync = 1 ctx->need_resync = 1
#define RESYNC_BITSTREAM \ #define RESYNC_BITSTREAM \
if (ctx->need_resync && !(get_bits_count(&ctx->gb) & 7)) { \ if (ctx->need_resync && !(bitstream_tell(&ctx->bc) & 7)) { \
skip_bits_long(&ctx->gb, ctx->skip_bits); \ bitstream_skip(&ctx->bc, ctx->skip_bits); \
ctx->skip_bits = 0; \ ctx->skip_bits = 0; \
ctx->need_resync = 0; \ ctx->need_resync = 0; \
} }
...@@ -773,7 +774,7 @@ static int parse_bintree(Indeo3DecodeContext *ctx, AVCodecContext *avctx, ...@@ -773,7 +774,7 @@ static int parse_bintree(Indeo3DecodeContext *ctx, AVCodecContext *avctx,
while (1) { /* loop until return */ while (1) { /* loop until return */
RESYNC_BITSTREAM; RESYNC_BITSTREAM;
switch (code = get_bits(&ctx->gb, 2)) { switch (code = bitstream_read(&ctx->bc, 2)) {
case H_SPLIT: case H_SPLIT:
case V_SPLIT: case V_SPLIT:
if (parse_bintree(ctx, avctx, plane, code, &curr_cell, depth - 1, strip_width)) if (parse_bintree(ctx, avctx, plane, code, &curr_cell, depth - 1, strip_width))
...@@ -785,7 +786,7 @@ static int parse_bintree(Indeo3DecodeContext *ctx, AVCodecContext *avctx, ...@@ -785,7 +786,7 @@ static int parse_bintree(Indeo3DecodeContext *ctx, AVCodecContext *avctx,
curr_cell.tree = 1; /* enter the VQ tree */ curr_cell.tree = 1; /* enter the VQ tree */
} else { /* VQ tree NULL code */ } else { /* VQ tree NULL code */
RESYNC_BITSTREAM; RESYNC_BITSTREAM;
code = get_bits(&ctx->gb, 2); code = bitstream_read(&ctx->bc, 2);
if (code >= 2) { if (code >= 2) {
av_log(avctx, AV_LOG_ERROR, "Invalid VQ_NULL code: %d\n", code); av_log(avctx, AV_LOG_ERROR, "Invalid VQ_NULL code: %d\n", code);
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
...@@ -805,7 +806,7 @@ static int parse_bintree(Indeo3DecodeContext *ctx, AVCodecContext *avctx, ...@@ -805,7 +806,7 @@ static int parse_bintree(Indeo3DecodeContext *ctx, AVCodecContext *avctx,
unsigned mv_idx; unsigned mv_idx;
/* get motion vector index and setup the pointer to the mv set */ /* get motion vector index and setup the pointer to the mv set */
if (!ctx->need_resync) if (!ctx->need_resync)
ctx->next_cell_data = &ctx->gb.buffer[(get_bits_count(&ctx->gb) + 7) >> 3]; ctx->next_cell_data = &ctx->bc.buffer[(bitstream_tell(&ctx->bc) + 7) >> 3];
mv_idx = *(ctx->next_cell_data++); mv_idx = *(ctx->next_cell_data++);
if (mv_idx >= ctx->num_vectors) { if (mv_idx >= ctx->num_vectors) {
av_log(avctx, AV_LOG_ERROR, "motion vector index out of range\n"); av_log(avctx, AV_LOG_ERROR, "motion vector index out of range\n");
...@@ -816,7 +817,7 @@ static int parse_bintree(Indeo3DecodeContext *ctx, AVCodecContext *avctx, ...@@ -816,7 +817,7 @@ static int parse_bintree(Indeo3DecodeContext *ctx, AVCodecContext *avctx,
UPDATE_BITPOS(8); UPDATE_BITPOS(8);
} else { /* VQ tree DATA code */ } else { /* VQ tree DATA code */
if (!ctx->need_resync) if (!ctx->need_resync)
ctx->next_cell_data = &ctx->gb.buffer[(get_bits_count(&ctx->gb) + 7) >> 3]; ctx->next_cell_data = &ctx->bc.buffer[(bitstream_tell(&ctx->bc) + 7) >> 3];
CHECK_CELL CHECK_CELL
bytes_used = decode_cell(ctx, avctx, plane, &curr_cell, bytes_used = decode_cell(ctx, avctx, plane, &curr_cell,
...@@ -856,7 +857,7 @@ static int decode_plane(Indeo3DecodeContext *ctx, AVCodecContext *avctx, ...@@ -856,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 */
init_get_bits(&ctx->gb, &data[num_vectors * 2], (data_size - num_vectors * 2) << 3); bitstream_init(&ctx->bc, &data[num_vectors * 2], (data_size - num_vectors * 2) << 3);
ctx->skip_bits = 0; ctx->skip_bits = 0;
ctx->need_resync = 0; ctx->need_resync = 0;
......
This diff is collapsed.
This diff is collapsed.
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
#define BITSTREAM_READER_LE #define BITSTREAM_READER_LE
#include "avcodec.h" #include "avcodec.h"
#include "get_bits.h" #include "bitstream.h"
#include "internal.h" #include "internal.h"
#include "mathops.h" #include "mathops.h"
#include "ivi.h" #include "ivi.h"
...@@ -225,7 +225,7 @@ static int ivi_huff_desc_cmp(const IVIHuffDesc *desc1, ...@@ -225,7 +225,7 @@ static int ivi_huff_desc_cmp(const IVIHuffDesc *desc1,
memcmp(desc1->xbits, desc2->xbits, desc1->num_rows); memcmp(desc1->xbits, desc2->xbits, desc1->num_rows);
} }
int ff_ivi_dec_huff_desc(GetBitContext *gb, int desc_coded, int which_tab, int ff_ivi_dec_huff_desc(BitstreamContext *bc, int desc_coded, int which_tab,
IVIHuffTab *huff_tab, AVCodecContext *avctx) IVIHuffTab *huff_tab, AVCodecContext *avctx)
{ {
int i, result; int i, result;
...@@ -238,17 +238,17 @@ int ff_ivi_dec_huff_desc(GetBitContext *gb, int desc_coded, int which_tab, ...@@ -238,17 +238,17 @@ int ff_ivi_dec_huff_desc(GetBitContext *gb, int desc_coded, int which_tab,
return 0; return 0;
} }
huff_tab->tab_sel = get_bits(gb, 3); huff_tab->tab_sel = bitstream_read(bc, 3);
if (huff_tab->tab_sel == 7) { if (huff_tab->tab_sel == 7) {
/* custom huffman table (explicitly encoded) */ /* custom huffman table (explicitly encoded) */
new_huff.num_rows = get_bits(gb, 4); new_huff.num_rows = bitstream_read(bc, 4);
if (!new_huff.num_rows) { if (!new_huff.num_rows) {
av_log(avctx, AV_LOG_ERROR, "Empty custom Huffman table!\n"); av_log(avctx, AV_LOG_ERROR, "Empty custom Huffman table!\n");
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} }
for (i = 0; i < new_huff.num_rows; i++) for (i = 0; i < new_huff.num_rows; i++)
new_huff.xbits[i] = get_bits(gb, 4); new_huff.xbits[i] = bitstream_read(bc, 4);
/* Have we got the same custom table? Rebuild if not. */ /* Have we got the same custom table? Rebuild if not. */
if (ivi_huff_desc_cmp(&new_huff, &huff_tab->cust_desc)) { if (ivi_huff_desc_cmp(&new_huff, &huff_tab->cust_desc)) {
...@@ -461,22 +461,22 @@ av_cold int ff_ivi_init_tiles(IVIPlaneDesc *planes, ...@@ -461,22 +461,22 @@ av_cold int ff_ivi_init_tiles(IVIPlaneDesc *planes,
* if (tile_data_size >= 255) than this field four is byte long: 0xFF X1 X2 X3 * if (tile_data_size >= 255) than this field four is byte long: 0xFF X1 X2 X3
* where X1-X3 is size of the tile data * where X1-X3 is size of the tile data
* *
* @param[in,out] gb the GetBit context * @param[in,out] bc the Bitstream context
* @return size of the tile data in bytes * @return size of the tile data in bytes
*/ */
static int ivi_dec_tile_data_size(GetBitContext *gb) static int ivi_dec_tile_data_size(BitstreamContext *bc)
{ {
int len; int len;
len = 0; len = 0;
if (get_bits1(gb)) { if (bitstream_read_bit(bc)) {
len = get_bits(gb, 8); len = bitstream_read(bc, 8);
if (len == 255) if (len == 255)
len = get_bits_long(gb, 24); len = bitstream_read(bc, 24);
} }
/* align the bitstream reader on the byte boundary */ /* align the bitstream reader on the byte boundary */
align_get_bits(gb); bitstream_align(bc);
return len; return len;
} }
...@@ -500,7 +500,7 @@ static int ivi_dc_transform(IVIBandDesc *band, int *prev_dc, int buf_offs, ...@@ -500,7 +500,7 @@ static int ivi_dc_transform(IVIBandDesc *band, int *prev_dc, int buf_offs,
return 0; return 0;
} }
static int ivi_decode_coded_blocks(GetBitContext *gb, IVIBandDesc *band, static int ivi_decode_coded_blocks(BitstreamContext *bc, IVIBandDesc *band,
ivi_mc_func mc, ivi_mc_avg_func mc_avg, ivi_mc_func mc, ivi_mc_avg_func mc_avg,
int mv_x, int mv_y, int mv_x, int mv_y,
int mv_x2, int mv_y2, int mv_x2, int mv_y2,
...@@ -536,16 +536,15 @@ static int ivi_decode_coded_blocks(GetBitContext *gb, IVIBandDesc *band, ...@@ -536,16 +536,15 @@ static int ivi_decode_coded_blocks(GetBitContext *gb, IVIBandDesc *band,
/* zero column flags */ /* zero column flags */
memset(col_flags, 0, sizeof(col_flags)); memset(col_flags, 0, sizeof(col_flags));
while (scan_pos <= num_coeffs) { while (scan_pos <= num_coeffs) {
sym = get_vlc2(gb, band->blk_vlc.tab->table, sym = bitstream_read_vlc(bc, band->blk_vlc.tab->table, IVI_VLC_BITS, 1);
IVI_VLC_BITS, 1);
if (sym == rvmap->eob_sym) if (sym == rvmap->eob_sym)
break; /* End of block */ break; /* End of block */
/* Escape - run/val explicitly coded using 3 vlc codes */ /* Escape - run/val explicitly coded using 3 vlc codes */
if (sym == rvmap->esc_sym) { if (sym == rvmap->esc_sym) {
run = get_vlc2(gb, band->blk_vlc.tab->table, IVI_VLC_BITS, 1) + 1; run = bitstream_read_vlc(bc, band->blk_vlc.tab->table, IVI_VLC_BITS, 1) + 1;
lo = get_vlc2(gb, band->blk_vlc.tab->table, IVI_VLC_BITS, 1); lo = bitstream_read_vlc(bc, band->blk_vlc.tab->table, IVI_VLC_BITS, 1);
hi = get_vlc2(gb, band->blk_vlc.tab->table, IVI_VLC_BITS, 1); hi = bitstream_read_vlc(bc, band->blk_vlc.tab->table, IVI_VLC_BITS, 1);
/* merge them and convert into signed val */ /* merge them and convert into signed val */
val = IVI_TOSIGNED((hi << 6) | lo); val = IVI_TOSIGNED((hi << 6) | lo);
} else { } else {
...@@ -601,12 +600,12 @@ static int ivi_decode_coded_blocks(GetBitContext *gb, IVIBandDesc *band, ...@@ -601,12 +600,12 @@ static int ivi_decode_coded_blocks(GetBitContext *gb, IVIBandDesc *band,
* dequantize them, apply inverse transform and motion compensation * dequantize them, apply inverse transform and motion compensation
* in order to reconstruct the picture. * in order to reconstruct the picture.
* *
* @param[in,out] gb the GetBit context * @param[in,out] bc the Bitstream context
* @param[in] band pointer to the band descriptor * @param[in] band pointer to the band descriptor
* @param[in] tile pointer to the tile descriptor * @param[in] tile pointer to the tile descriptor
* @return result code: 0 - OK, -1 = error (corrupted blocks data) * @return result code: 0 - OK, -1 = error (corrupted blocks data)
*/ */
static int ivi_decode_blocks(GetBitContext *gb, IVIBandDesc *band, static int ivi_decode_blocks(BitstreamContext *bc, IVIBandDesc *band,
IVITile *tile, AVCodecContext *avctx) IVITile *tile, AVCodecContext *avctx)
{ {
int mbn, blk, num_blocks, blk_size, ret, is_intra; int mbn, blk, num_blocks, blk_size, ret, is_intra;
...@@ -710,7 +709,7 @@ static int ivi_decode_blocks(GetBitContext *gb, IVIBandDesc *band, ...@@ -710,7 +709,7 @@ static int ivi_decode_blocks(GetBitContext *gb, IVIBandDesc *band,
} }
if (cbp & 1) { /* block coded ? */ if (cbp & 1) { /* block coded ? */
ret = ivi_decode_coded_blocks(gb, band, mc_with_delta_func, ret = ivi_decode_coded_blocks(bc, band, mc_with_delta_func,
mc_avg_with_delta_func, mc_avg_with_delta_func,
mv_x, mv_y, mv_x2, mv_y2, mv_x, mv_y, mv_x2, mv_y2,
&prev_dc, is_intra, &prev_dc, is_intra,
...@@ -739,7 +738,7 @@ static int ivi_decode_blocks(GetBitContext *gb, IVIBandDesc *band, ...@@ -739,7 +738,7 @@ static int ivi_decode_blocks(GetBitContext *gb, IVIBandDesc *band,
}// for blk }// for blk
}// for mbn }// for mbn
align_get_bits(gb); bitstream_align(bc);
return 0; return 0;
} }
...@@ -925,7 +924,7 @@ static int decode_band(IVI45DecContext *ctx, ...@@ -925,7 +924,7 @@ static int decode_band(IVI45DecContext *ctx,
band->ref_buf = band->bufs[ctx->ref_buf]; band->ref_buf = band->bufs[ctx->ref_buf];
band->b_ref_buf = 0; band->b_ref_buf = 0;
} }
band->data_ptr = ctx->frame_data + (get_bits_count(&ctx->gb) >> 3); band->data_ptr = ctx->frame_data + (bitstream_tell(&ctx->bc) >> 3);
result = ctx->decode_band_hdr(ctx, band, avctx); result = ctx->decode_band_hdr(ctx, band, avctx);
if (result) { if (result) {
...@@ -949,7 +948,7 @@ static int decode_band(IVI45DecContext *ctx, ...@@ -949,7 +948,7 @@ static int decode_band(IVI45DecContext *ctx,
FFSWAP(int16_t, band->rv_map->valtab[idx1], band->rv_map->valtab[idx2]); FFSWAP(int16_t, band->rv_map->valtab[idx1], band->rv_map->valtab[idx2]);
} }
pos = get_bits_count(&ctx->gb); pos = bitstream_tell(&ctx->bc);
for (t = 0; t < band->num_tiles; t++) { for (t = 0; t < band->num_tiles; t++) {
tile = &band->tiles[t]; tile = &band->tiles[t];
...@@ -959,7 +958,7 @@ static int decode_band(IVI45DecContext *ctx, ...@@ -959,7 +958,7 @@ static int decode_band(IVI45DecContext *ctx,
band->mb_size, tile->mb_size); band->mb_size, tile->mb_size);
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} }
tile->is_empty = get_bits1(&ctx->gb); tile->is_empty = bitstream_read_bit(&ctx->bc);
if (tile->is_empty) { if (tile->is_empty) {
result = ivi_process_empty_tile(avctx, band, tile, result = ivi_process_empty_tile(avctx, band, tile,
(ctx->planes[0].bands[0].mb_size >> 3) - (band->mb_size >> 3)); (ctx->planes[0].bands[0].mb_size >> 3) - (band->mb_size >> 3));
...@@ -967,7 +966,7 @@ static int decode_band(IVI45DecContext *ctx, ...@@ -967,7 +966,7 @@ static int decode_band(IVI45DecContext *ctx,
break; break;
ff_dlog(avctx, "Empty tile encountered!\n"); ff_dlog(avctx, "Empty tile encountered!\n");
} else { } else {
tile->data_size = ivi_dec_tile_data_size(&ctx->gb); tile->data_size = ivi_dec_tile_data_size(&ctx->bc);
if (!tile->data_size) { if (!tile->data_size) {
av_log(avctx, AV_LOG_ERROR, "Tile data size is zero!\n"); av_log(avctx, AV_LOG_ERROR, "Tile data size is zero!\n");
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
...@@ -977,14 +976,14 @@ static int decode_band(IVI45DecContext *ctx, ...@@ -977,14 +976,14 @@ static int decode_band(IVI45DecContext *ctx,
if (result < 0) if (result < 0)
break; break;
result = ivi_decode_blocks(&ctx->gb, band, tile, avctx); result = ivi_decode_blocks(&ctx->bc, band, tile, avctx);
if (result < 0) { if (result < 0) {
av_log(avctx, AV_LOG_ERROR, av_log(avctx, AV_LOG_ERROR,
"Corrupted tile data encountered!\n"); "Corrupted tile data encountered!\n");
break; break;
} }
if (((get_bits_count(&ctx->gb) - pos) >> 3) != tile->data_size) { if (((bitstream_tell(&ctx->bc) - pos) >> 3) != tile->data_size) {
av_log(avctx, AV_LOG_ERROR, av_log(avctx, AV_LOG_ERROR,
"Tile data_size mismatch!\n"); "Tile data_size mismatch!\n");
result = AVERROR_INVALIDDATA; result = AVERROR_INVALIDDATA;
...@@ -1016,7 +1015,7 @@ static int decode_band(IVI45DecContext *ctx, ...@@ -1016,7 +1015,7 @@ static int decode_band(IVI45DecContext *ctx,
} }
#endif #endif
align_get_bits(&ctx->gb); bitstream_align(&ctx->bc);
return result; return result;
} }
...@@ -1030,7 +1029,7 @@ int ff_ivi_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, ...@@ -1030,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;
init_get_bits(&ctx->gb, buf, buf_size * 8); bitstream_init(&ctx->bc, buf, buf_size * 8);
ctx->frame_data = buf; ctx->frame_data = buf;
ctx->frame_size = buf_size; ctx->frame_size = buf_size;
...@@ -1122,14 +1121,14 @@ int ff_ivi_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, ...@@ -1122,14 +1121,14 @@ int ff_ivi_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
if (ctx->is_indeo4 && ctx->frame_type == IVI4_FRAMETYPE_INTRA) { if (ctx->is_indeo4 && ctx->frame_type == IVI4_FRAMETYPE_INTRA) {
int left; int left;
while (get_bits(&ctx->gb, 8)); // skip version string while (bitstream_read(&ctx->bc, 8)); // skip version string
left = get_bits_count(&ctx->gb) & 0x18; left = bitstream_tell(&ctx->bc) & 0x18;
skip_bits_long(&ctx->gb, 64 - left); bitstream_skip(&ctx->bc, 64 - left);
if (get_bits_left(&ctx->gb) > 18 && if (bitstream_bits_left(&ctx->bc) > 18 &&
show_bits_long(&ctx->gb, 21) == 0xBFFF8) { // syncheader + inter type bitstream_peek(&ctx->bc, 21) == 0xBFFF8) { // syncheader + inter type
AVPacket pkt; AVPacket pkt;
pkt.data = avpkt->data + (get_bits_count(&ctx->gb) >> 3); pkt.data = avpkt->data + (bitstream_tell(&ctx->bc) >> 3);
pkt.size = get_bits_left(&ctx->gb) >> 3; pkt.size = bitstream_bits_left(&ctx->bc) >> 3;
ff_ivi_decode_frame(avctx, ctx->p_frame, &ctx->got_p_frame, &pkt); ff_ivi_decode_frame(avctx, ctx->p_frame, &ctx->got_p_frame, &pkt);
} }
} }
......
...@@ -29,10 +29,11 @@ ...@@ -29,10 +29,11 @@
#ifndef AVCODEC_IVI_H #ifndef AVCODEC_IVI_H
#define AVCODEC_IVI_H #define AVCODEC_IVI_H
#include "avcodec.h"
#include "get_bits.h"
#include <stdint.h> #include <stdint.h>
#include "avcodec.h"
#include "bitstream.h"
/** /**
* Indeo 4 frame types. * Indeo 4 frame types.
*/ */
...@@ -210,7 +211,7 @@ typedef struct IVIPicConfig { ...@@ -210,7 +211,7 @@ typedef struct IVIPicConfig {
} IVIPicConfig; } IVIPicConfig;
typedef struct IVI45DecContext { typedef struct IVI45DecContext {
GetBitContext gb; BitstreamContext bc;
RVMapDesc rvmap_tabs[9]; ///< local corrected copy of the static rvmap tables RVMapDesc rvmap_tabs[9]; ///< local corrected copy of the static rvmap tables
uint32_t frame_num; uint32_t frame_num;
...@@ -302,14 +303,14 @@ void ff_ivi_init_static_vlc(void); ...@@ -302,14 +303,14 @@ void ff_ivi_init_static_vlc(void);
* Decode a huffman codebook descriptor from the bitstream * Decode a huffman codebook descriptor from the bitstream
* and select specified huffman table. * and select specified huffman table.
* *
* @param[in,out] gb the GetBit context * @param[in,out] bc the Bitstream context
* @param[in] desc_coded flag signalling if table descriptor was coded * @param[in] desc_coded flag signalling if table descriptor was coded
* @param[in] which_tab codebook purpose (IVI_MB_HUFF or IVI_BLK_HUFF) * @param[in] which_tab codebook purpose (IVI_MB_HUFF or IVI_BLK_HUFF)
* @param[out] huff_tab pointer to the descriptor of the selected table * @param[out] huff_tab pointer to the descriptor of the selected table
* @param[in] avctx AVCodecContext pointer * @param[in] avctx AVCodecContext pointer
* @return zero on success, negative value otherwise * @return zero on success, negative value otherwise
*/ */
int ff_ivi_dec_huff_desc(GetBitContext *gb, int desc_coded, int which_tab, int ff_ivi_dec_huff_desc(BitstreamContext *bc, int desc_coded, int which_tab,
IVIHuffTab *huff_tab, AVCodecContext *avctx); IVIHuffTab *huff_tab, AVCodecContext *avctx);
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment