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

mimic: Convert to the new bitstream reader

parent cdc6727c
...@@ -24,9 +24,9 @@ ...@@ -24,9 +24,9 @@
#include <stdint.h> #include <stdint.h>
#include "avcodec.h" #include "avcodec.h"
#include "bitstream.h"
#include "blockdsp.h" #include "blockdsp.h"
#include "internal.h" #include "internal.h"
#include "get_bits.h"
#include "bytestream.h" #include "bytestream.h"
#include "bswapdsp.h" #include "bswapdsp.h"
#include "hpeldsp.h" #include "hpeldsp.h"
...@@ -51,7 +51,7 @@ typedef struct MimicContext { ...@@ -51,7 +51,7 @@ typedef struct MimicContext {
DECLARE_ALIGNED(16, int16_t, dct_block)[64]; DECLARE_ALIGNED(16, int16_t, dct_block)[64];
GetBitContext gb; BitstreamContext bc;
ScanTable scantable; ScanTable scantable;
BlockDSPContext bdsp; BlockDSPContext bdsp;
BswapDSPContext bbdsp; BswapDSPContext bbdsp;
...@@ -232,14 +232,14 @@ static int vlc_decode_block(MimicContext *ctx, int num_coeffs, int qscale) ...@@ -232,14 +232,14 @@ static int vlc_decode_block(MimicContext *ctx, int num_coeffs, int qscale)
ctx->bdsp.clear_block(block); ctx->bdsp.clear_block(block);
block[0] = get_bits(&ctx->gb, 8) << 3; block[0] = bitstream_read(&ctx->bc, 8) << 3;
for (pos = 1; pos < num_coeffs; pos++) { for (pos = 1; pos < num_coeffs; pos++) {
uint32_t vlc, num_bits; uint32_t vlc, num_bits;
int value; int value;
int coeff; int coeff;
vlc = get_vlc2(&ctx->gb, ctx->vlc.table, ctx->vlc.bits, 3); vlc = bitstream_read_vlc(&ctx->bc, ctx->vlc.table, ctx->vlc.bits, 3);
if (!vlc) /* end-of-block code */ if (!vlc) /* end-of-block code */
return 0; return 0;
if (vlc == -1) if (vlc == -1)
...@@ -252,7 +252,7 @@ static int vlc_decode_block(MimicContext *ctx, int num_coeffs, int qscale) ...@@ -252,7 +252,7 @@ static int vlc_decode_block(MimicContext *ctx, int num_coeffs, int qscale)
if (pos >= 64) if (pos >= 64)
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
value = get_bits(&ctx->gb, num_bits); value = bitstream_read(&ctx->bc, num_bits);
/* Libav's IDCT behaves somewhat different from the original code, so /* Libav's IDCT behaves somewhat different from the original code, so
* a factor of 4 was added to the input */ * a factor of 4 was added to the input */
...@@ -286,13 +286,13 @@ static int decode(MimicContext *ctx, int quality, int num_coeffs, ...@@ -286,13 +286,13 @@ static int decode(MimicContext *ctx, int quality, int num_coeffs,
for (x = 0; x < ctx->num_hblocks[plane]; x++) { for (x = 0; x < ctx->num_hblocks[plane]; x++) {
/* Check for a change condition in the current block. /* Check for a change condition in the current block.
* - iframes always change. * - iframes always change.
* - Luma plane changes on get_bits1 == 0 * - Luma plane changes on bitstream_read_bit == 0
* - Chroma planes change on get_bits1 == 1 */ * - Chroma planes change on bitstream_read_bit == 1 */
if (is_iframe || get_bits1(&ctx->gb) == is_chroma) { if (is_iframe || bitstream_read_bit(&ctx->bc) == is_chroma) {
/* Luma planes may use a backreference from the 15 last /* Luma planes may use a backreference from the 15 last
* frames preceding the previous. (get_bits1 == 1) * frames preceding the previous. (bitstream_read_bit == 1)
* Chroma planes don't use backreferences. */ * Chroma planes don't use backreferences. */
if (is_chroma || is_iframe || !get_bits1(&ctx->gb)) { if (is_chroma || is_iframe || !bitstream_read_bit(&ctx->bc)) {
if ((ret = vlc_decode_block(ctx, num_coeffs, if ((ret = vlc_decode_block(ctx, num_coeffs,
qscale)) < 0) { qscale)) < 0) {
av_log(ctx->avctx, AV_LOG_ERROR, "Error decoding " av_log(ctx->avctx, AV_LOG_ERROR, "Error decoding "
...@@ -301,7 +301,7 @@ static int decode(MimicContext *ctx, int quality, int num_coeffs, ...@@ -301,7 +301,7 @@ static int decode(MimicContext *ctx, int quality, int num_coeffs,
} }
ctx->idsp.idct_put(dst, stride, ctx->dct_block); ctx->idsp.idct_put(dst, stride, ctx->dct_block);
} else { } else {
unsigned int backref = get_bits(&ctx->gb, 4); unsigned int backref = bitstream_read(&ctx->bc, 4);
int index = (ctx->cur_index + backref) & 15; int index = (ctx->cur_index + backref) & 15;
uint8_t *p = ctx->frames[index].f->data[0]; uint8_t *p = ctx->frames[index].f->data[0];
...@@ -426,7 +426,7 @@ static int mimic_decode_frame(AVCodecContext *avctx, void *data, ...@@ -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);
init_get_bits(&ctx->gb, ctx->swap_buf, swap_buf_size << 3); bitstream_init(&ctx->bc, ctx->swap_buf, swap_buf_size << 3);
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);
......
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