mirror of
https://gitee.com/openharmony/third_party_ffmpeg
synced 2024-11-24 19:59:46 +00:00
mimic: Convert to the new bitstream reader
This commit is contained in:
parent
cdc6727c3e
commit
6c916192f3
@ -24,9 +24,9 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include "avcodec.h"
|
||||
#include "bitstream.h"
|
||||
#include "blockdsp.h"
|
||||
#include "internal.h"
|
||||
#include "get_bits.h"
|
||||
#include "bytestream.h"
|
||||
#include "bswapdsp.h"
|
||||
#include "hpeldsp.h"
|
||||
@ -51,7 +51,7 @@ typedef struct MimicContext {
|
||||
|
||||
DECLARE_ALIGNED(16, int16_t, dct_block)[64];
|
||||
|
||||
GetBitContext gb;
|
||||
BitstreamContext bc;
|
||||
ScanTable scantable;
|
||||
BlockDSPContext bdsp;
|
||||
BswapDSPContext bbdsp;
|
||||
@ -232,14 +232,14 @@ static int vlc_decode_block(MimicContext *ctx, int num_coeffs, int qscale)
|
||||
|
||||
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++) {
|
||||
uint32_t vlc, num_bits;
|
||||
int value;
|
||||
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 */
|
||||
return 0;
|
||||
if (vlc == -1)
|
||||
@ -252,7 +252,7 @@ static int vlc_decode_block(MimicContext *ctx, int num_coeffs, int qscale)
|
||||
if (pos >= 64)
|
||||
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
|
||||
* a factor of 4 was added to the input */
|
||||
@ -286,13 +286,13 @@ static int decode(MimicContext *ctx, int quality, int num_coeffs,
|
||||
for (x = 0; x < ctx->num_hblocks[plane]; x++) {
|
||||
/* Check for a change condition in the current block.
|
||||
* - iframes always change.
|
||||
* - Luma plane changes on get_bits1 == 0
|
||||
* - Chroma planes change on get_bits1 == 1 */
|
||||
if (is_iframe || get_bits1(&ctx->gb) == is_chroma) {
|
||||
* - Luma plane changes on bitstream_read_bit == 0
|
||||
* - Chroma planes change on bitstream_read_bit == 1 */
|
||||
if (is_iframe || bitstream_read_bit(&ctx->bc) == is_chroma) {
|
||||
/* 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. */
|
||||
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,
|
||||
qscale)) < 0) {
|
||||
av_log(ctx->avctx, AV_LOG_ERROR, "Error decoding "
|
||||
@ -301,7 +301,7 @@ static int decode(MimicContext *ctx, int quality, int num_coeffs,
|
||||
}
|
||||
ctx->idsp.idct_put(dst, stride, ctx->dct_block);
|
||||
} else {
|
||||
unsigned int backref = get_bits(&ctx->gb, 4);
|
||||
unsigned int backref = bitstream_read(&ctx->bc, 4);
|
||||
int index = (ctx->cur_index + backref) & 15;
|
||||
uint8_t *p = ctx->frames[index].f->data[0];
|
||||
|
||||
@ -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);
|
||||
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);
|
||||
ff_thread_report_progress(&ctx->frames[ctx->cur_index], INT_MAX, 0);
|
||||
|
Loading…
Reference in New Issue
Block a user