#include "libavutil/imgutils.h"
#include "libavutil/intreadwrite.h"
+
#include "avcodec.h"
+#include "bitstream.h"
#include "bytestream.h"
-#include "get_bits.h"
#include "hpeldsp.h"
#include "internal.h"
/* Some constants for parsing frame bitstream flags. */
-#define BS_8BIT_PEL (1 << 1) ///< 8bit pixel bitdepth indicator
+#define BS_8BIT_PEL (1 << 1) ///< 8-bit pixel bitdepth indicator
#define BS_KEYFRAME (1 << 2) ///< intra frame indicator
#define BS_MV_Y_HALF (1 << 4) ///< vertical mv halfpel resolution indicator
#define BS_MV_X_HALF (1 << 5) ///< horizontal mv halfpel resolution indicator
uint8_t *pixels[2]; ///< pointer to the actual pixel data of the buffers above
uint32_t width;
uint32_t height;
- uint32_t pitch;
+ ptrdiff_t pitch;
} Plane;
#define CELL_STACK_MAX 20
AVCodecContext *avctx;
HpelDSPContext hdsp;
- GetBitContext gb;
+ BitstreamContext bc;
int need_resync;
int skip_bits;
const uint8_t *next_cell_data;
AVCodecContext *avctx)
{
int p, luma_width, luma_height, chroma_width, chroma_height;
- int luma_pitch, chroma_pitch, luma_size, chroma_size;
+ int luma_size, chroma_size;
+ ptrdiff_t luma_pitch, chroma_pitch;
luma_width = ctx->width;
luma_height = ctx->height;
}
-/* Fill n lines with 64bit pixel value pix */
+/* Fill n lines with 64-bit pixel value pix */
static inline void fill_64(uint8_t *dst, const uint64_t pix, int32_t n,
int32_t row_offset)
{
static int decode_cell_data(Indeo3DecodeContext *ctx, Cell *cell,
uint8_t *block, uint8_t *ref_block,
- int pitch, int h_zoom, int v_zoom, int mode,
+ ptrdiff_t row_offset, int h_zoom, int v_zoom, int mode,
const vqEntry *delta[2], int swap_quads[2],
const uint8_t **data_ptr, const uint8_t *last_ptr)
{
unsigned int dyad1, dyad2;
uint64_t pix64;
int skip_flag = 0, is_top_of_cell, is_first_row = 1;
- int row_offset, blk_row_offset, line_offset;
+ int blk_row_offset, line_offset;
- row_offset = pitch;
blk_row_offset = (row_offset << (2 + v_zoom)) - (cell->width << 2);
line_offset = v_zoom ? row_offset : 0;
ctx->need_resync = 1
#define RESYNC_BITSTREAM \
- if (ctx->need_resync && !(get_bits_count(&ctx->gb) & 7)) { \
- skip_bits_long(&ctx->gb, ctx->skip_bits); \
+ if (ctx->need_resync && !(bitstream_tell(&ctx->bc) & 7)) { \
+ bitstream_skip(&ctx->bc, ctx->skip_bits); \
ctx->skip_bits = 0; \
ctx->need_resync = 0; \
}
while (1) { /* loop until return */
RESYNC_BITSTREAM;
- switch (code = get_bits(&ctx->gb, 2)) {
+ switch (code = bitstream_read(&ctx->bc, 2)) {
case H_SPLIT:
case V_SPLIT:
if (parse_bintree(ctx, avctx, plane, code, &curr_cell, depth - 1, strip_width))
curr_cell.tree = 1; /* enter the VQ tree */
} else { /* VQ tree NULL code */
RESYNC_BITSTREAM;
- code = get_bits(&ctx->gb, 2);
+ code = bitstream_read(&ctx->bc, 2);
if (code >= 2) {
av_log(avctx, AV_LOG_ERROR, "Invalid VQ_NULL code: %d\n", code);
return AVERROR_INVALIDDATA;
unsigned mv_idx;
/* get motion vector index and setup the pointer to the mv set */
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++);
if (mv_idx >= ctx->num_vectors) {
av_log(avctx, AV_LOG_ERROR, "motion vector index out of range\n");
UPDATE_BITPOS(8);
} else { /* VQ tree DATA code */
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
bytes_used = decode_cell(ctx, avctx, plane, &curr_cell,
break;
}
}//while
-
- return 0;
}
ctx->mc_vectors = num_vectors ? data : 0;
/* 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->need_resync = 0;
if (width != ctx->width || height != ctx->height) {
int res;
- av_dlog(avctx, "Frame dimensions changed!\n");
+ ff_dlog(avctx, "Frame dimensions changed!\n");
if (width < 16 || width > 640 ||
height < 16 || height > 480 ||
* @param[in] dst_height output plane height
*/
static void output_plane(const Plane *plane, int buf_sel, uint8_t *dst,
- int dst_pitch, int dst_height)
+ ptrdiff_t dst_pitch, int dst_height)
{
int x,y;
const uint8_t *src = plane->pixels[buf_sel];
- uint32_t pitch = plane->pitch;
+ ptrdiff_t pitch = plane->pitch;
dst_height = FFMIN(dst_height, plane->height);
for (y = 0; y < dst_height; y++) {
.init = decode_init,
.close = decode_close,
.decode = decode_frame,
- .capabilities = CODEC_CAP_DR1,
+ .capabilities = AV_CODEC_CAP_DR1,
};