mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-02-14 22:22:59 +02:00
clearvideo: Convert to the new bitstream reader
This commit is contained in:
parent
189157c3fc
commit
d0ce0634e0
@ -25,8 +25,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "avcodec.h"
|
#include "avcodec.h"
|
||||||
|
#include "bitstream.h"
|
||||||
#include "bytestream.h"
|
#include "bytestream.h"
|
||||||
#include "get_bits.h"
|
|
||||||
#include "idctdsp.h"
|
#include "idctdsp.h"
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
@ -123,7 +123,7 @@ typedef struct CLVContext {
|
|||||||
AVCodecContext *avctx;
|
AVCodecContext *avctx;
|
||||||
IDCTDSPContext idsp;
|
IDCTDSPContext idsp;
|
||||||
AVFrame *pic;
|
AVFrame *pic;
|
||||||
GetBitContext gb;
|
BitstreamContext bc;
|
||||||
int mb_width, mb_height;
|
int mb_width, mb_height;
|
||||||
VLC dc_vlc, ac_vlc;
|
VLC dc_vlc, ac_vlc;
|
||||||
int luma_dc_quant, chroma_dc_quant, ac_quant;
|
int luma_dc_quant, chroma_dc_quant, ac_quant;
|
||||||
@ -135,11 +135,11 @@ typedef struct CLVContext {
|
|||||||
static inline int decode_block(CLVContext *ctx, int16_t *blk, int has_ac,
|
static inline int decode_block(CLVContext *ctx, int16_t *blk, int has_ac,
|
||||||
int ac_quant)
|
int ac_quant)
|
||||||
{
|
{
|
||||||
GetBitContext *gb = &ctx->gb;
|
BitstreamContext *bc = &ctx->bc;
|
||||||
int idx = 1, last = 0, val, skip;
|
int idx = 1, last = 0, val, skip;
|
||||||
|
|
||||||
memset(blk, 0, sizeof(*blk) * 64);
|
memset(blk, 0, sizeof(*blk) * 64);
|
||||||
blk[0] = get_vlc2(gb, ctx->dc_vlc.table, 9, 3);
|
blk[0] = bitstream_read_vlc(bc, ctx->dc_vlc.table, 9, 3);
|
||||||
if (blk[0] < 0)
|
if (blk[0] < 0)
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
blk[0] -= 63;
|
blk[0] -= 63;
|
||||||
@ -148,19 +148,19 @@ static inline int decode_block(CLVContext *ctx, int16_t *blk, int has_ac,
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
while (idx < 64 && !last) {
|
while (idx < 64 && !last) {
|
||||||
val = get_vlc2(gb, ctx->ac_vlc.table, 9, 2);
|
val = bitstream_read_vlc(bc, ctx->ac_vlc.table, 9, 2);
|
||||||
if (val < 0)
|
if (val < 0)
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
if (val != 0x1BFF) {
|
if (val != 0x1BFF) {
|
||||||
last = val >> 12;
|
last = val >> 12;
|
||||||
skip = (val >> 4) & 0xFF;
|
skip = (val >> 4) & 0xFF;
|
||||||
val &= 0xF;
|
val &= 0xF;
|
||||||
if (get_bits1(gb))
|
if (bitstream_read_bit(bc))
|
||||||
val = -val;
|
val = -val;
|
||||||
} else {
|
} else {
|
||||||
last = get_bits1(gb);
|
last = bitstream_read_bit(bc);
|
||||||
skip = get_bits(gb, 6);
|
skip = bitstream_read(bc, 6);
|
||||||
val = get_sbits(gb, 8);
|
val = bitstream_read_signed(bc, 8);
|
||||||
}
|
}
|
||||||
if (val) {
|
if (val) {
|
||||||
int aval = FFABS(val), sign = val < 0;
|
int aval = FFABS(val), sign = val < 0;
|
||||||
@ -229,7 +229,7 @@ static int decode_mb(CLVContext *c, int x, int y)
|
|||||||
int i, has_ac[6], off;
|
int i, has_ac[6], off;
|
||||||
|
|
||||||
for (i = 0; i < 6; i++)
|
for (i = 0; i < 6; i++)
|
||||||
has_ac[i] = get_bits1(&c->gb);
|
has_ac[i] = bitstream_read_bit(&c->bc);
|
||||||
|
|
||||||
off = x * 16 + y * 16 * c->pic->linesize[0];
|
off = x * 16 + y * 16 * c->pic->linesize[0];
|
||||||
for (i = 0; i < 4; i++) {
|
for (i = 0; i < 4; i++) {
|
||||||
@ -301,8 +301,8 @@ static int clv_decode_frame(AVCodecContext *avctx, void *data,
|
|||||||
c->luma_dc_quant = 32;
|
c->luma_dc_quant = 32;
|
||||||
c->chroma_dc_quant = 32;
|
c->chroma_dc_quant = 32;
|
||||||
|
|
||||||
if ((ret = init_get_bits8(&c->gb, buf + bytestream2_tell(&gb),
|
if ((ret = bitstream_init8(&c->bc, buf + bytestream2_tell(&gb),
|
||||||
buf_size - bytestream2_tell(&gb))) < 0)
|
buf_size - bytestream2_tell(&gb))) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
for (i = 0; i < 3; i++)
|
for (i = 0; i < 3; i++)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user