g2meet: Convert to the new bitstream reader

Signed-off-by: Anton Khirnov <anton@khirnov.net>
This commit is contained in:
Alexandra Hájková 2016-04-10 11:16:15 +02:00 committed by Anton Khirnov
parent b37b681f77
commit 799703c3ea
1 changed files with 15 additions and 15 deletions

View File

@ -31,10 +31,10 @@
#include "libavutil/intreadwrite.h" #include "libavutil/intreadwrite.h"
#include "avcodec.h" #include "avcodec.h"
#include "bitstream.h"
#include "blockdsp.h" #include "blockdsp.h"
#include "bytestream.h" #include "bytestream.h"
#include "elsdec.h" #include "elsdec.h"
#include "get_bits.h"
#include "idctdsp.h" #include "idctdsp.h"
#include "internal.h" #include "internal.h"
#include "jpegtables.h" #include "jpegtables.h"
@ -236,7 +236,7 @@ static void jpg_unescape(const uint8_t *src, int src_size,
*dst_size = dst - dst_start; *dst_size = dst - dst_start;
} }
static int jpg_decode_block(JPGContext *c, GetBitContext *gb, static int jpg_decode_block(JPGContext *c, BitstreamContext *bc,
int plane, int16_t *block) int plane, int16_t *block)
{ {
int dc, val, pos; int dc, val, pos;
@ -244,18 +244,18 @@ static int jpg_decode_block(JPGContext *c, GetBitContext *gb,
const uint8_t *qmat = is_chroma ? chroma_quant : luma_quant; const uint8_t *qmat = is_chroma ? chroma_quant : luma_quant;
c->bdsp.clear_block(block); c->bdsp.clear_block(block);
dc = get_vlc2(gb, c->dc_vlc[is_chroma].table, 9, 3); dc = bitstream_read_vlc(bc, c->dc_vlc[is_chroma].table, 9, 3);
if (dc < 0) if (dc < 0)
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
if (dc) if (dc)
dc = get_xbits(gb, dc); dc = bitstream_read_xbits(bc, dc);
dc = dc * qmat[0] + c->prev_dc[plane]; dc = dc * qmat[0] + c->prev_dc[plane];
block[0] = dc; block[0] = dc;
c->prev_dc[plane] = dc; c->prev_dc[plane] = dc;
pos = 0; pos = 0;
while (pos < 63) { while (pos < 63) {
val = get_vlc2(gb, c->ac_vlc[is_chroma].table, 9, 3); val = bitstream_read_vlc(bc, c->ac_vlc[is_chroma].table, 9, 3);
if (val < 0) if (val < 0)
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
pos += val >> 4; pos += val >> 4;
@ -265,7 +265,7 @@ static int jpg_decode_block(JPGContext *c, GetBitContext *gb,
if (val) { if (val) {
int nbits = val; int nbits = val;
val = get_xbits(gb, nbits); val = bitstream_read_xbits(bc, nbits);
val *= qmat[ff_zigzag_direct[pos]]; val *= qmat[ff_zigzag_direct[pos]];
block[c->scantable.permutated[pos]] = val; block[c->scantable.permutated[pos]] = val;
} }
@ -286,7 +286,7 @@ static int jpg_decode_data(JPGContext *c, int width, int height,
const uint8_t *mask, int mask_stride, int num_mbs, const uint8_t *mask, int mask_stride, int num_mbs,
int swapuv) int swapuv)
{ {
GetBitContext gb; BitstreamContext bc;
int mb_w, mb_h, mb_x, mb_y, i, j; int mb_w, mb_h, mb_x, mb_y, i, j;
int bx, by; int bx, by;
int unesc_size; int unesc_size;
@ -298,7 +298,7 @@ static int jpg_decode_data(JPGContext *c, int width, int height,
return ret; return ret;
jpg_unescape(src, src_size, c->buf, &unesc_size); jpg_unescape(src, src_size, c->buf, &unesc_size);
memset(c->buf + unesc_size, 0, AV_INPUT_BUFFER_PADDING_SIZE); memset(c->buf + unesc_size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
init_get_bits(&gb, c->buf, unesc_size * 8); bitstream_init(&bc, c->buf, unesc_size * 8);
width = FFALIGN(width, 16); width = FFALIGN(width, 16);
mb_w = width >> 4; mb_w = width >> 4;
@ -325,14 +325,14 @@ static int jpg_decode_data(JPGContext *c, int width, int height,
if (mask && !mask[mb_x * 2 + i + j * mask_stride]) if (mask && !mask[mb_x * 2 + i + j * mask_stride])
continue; continue;
num_mbs--; num_mbs--;
if ((ret = jpg_decode_block(c, &gb, 0, if ((ret = jpg_decode_block(c, &bc, 0,
c->block[i + j * 2])) != 0) c->block[i + j * 2])) != 0)
return ret; return ret;
c->idsp.idct(c->block[i + j * 2]); c->idsp.idct(c->block[i + j * 2]);
} }
} }
for (i = 1; i < 3; i++) { for (i = 1; i < 3; i++) {
if ((ret = jpg_decode_block(c, &gb, i, c->block[i + 3])) != 0) if ((ret = jpg_decode_block(c, &bc, i, c->block[i + 3])) != 0)
return ret; return ret;
c->idsp.idct(c->block[i + 3]); c->idsp.idct(c->block[i + 3]);
} }
@ -1011,11 +1011,11 @@ static void kempf_restore_buf(const uint8_t *src, int len,
int width, int height, int width, int height,
const uint8_t *pal, int npal, int tidx) const uint8_t *pal, int npal, int tidx)
{ {
GetBitContext gb; BitstreamContext bc;
int i, j, nb, col; int i, j, nb, col;
int align_width = FFALIGN(width, 16); int align_width = FFALIGN(width, 16);
init_get_bits(&gb, src, len * 8); bitstream_init(&bc, src, len * 8);
if (npal <= 2) nb = 1; if (npal <= 2) nb = 1;
else if (npal <= 4) nb = 2; else if (npal <= 4) nb = 2;
@ -1023,16 +1023,16 @@ static void kempf_restore_buf(const uint8_t *src, int len,
else nb = 8; else nb = 8;
for (j = 0; j < height; j++, dst += stride, jpeg_tile += tile_stride) { for (j = 0; j < height; j++, dst += stride, jpeg_tile += tile_stride) {
if (get_bits(&gb, 8)) if (bitstream_read(&bc, 8))
continue; continue;
for (i = 0; i < width; i++) { for (i = 0; i < width; i++) {
col = get_bits(&gb, nb); col = bitstream_read(&bc, nb);
if (col != tidx) if (col != tidx)
memcpy(dst + i * 3, pal + col * 3, 3); memcpy(dst + i * 3, pal + col * 3, 3);
else else
memcpy(dst + i * 3, jpeg_tile + i * 3, 3); memcpy(dst + i * 3, jpeg_tile + i * 3, 3);
} }
skip_bits_long(&gb, nb * (align_width - width)); bitstream_skip(&bc, nb * (align_width - width));
} }
} }