asvdec: cosmetics, reformat

This commit is contained in:
Anton Khirnov 2012-11-14 14:49:44 +01:00
parent bdfa24514e
commit c3a76c3dec

View File

@ -46,7 +46,8 @@ static VLC dc_ccp_vlc;
static VLC ac_ccp_vlc; static VLC ac_ccp_vlc;
static VLC asv2_level_vlc; static VLC asv2_level_vlc;
static av_cold void init_vlcs(ASV1Context *a){ static av_cold void init_vlcs(ASV1Context *a)
{
static int done = 0; static int done = 0;
if (!done) { if (!done) {
@ -71,25 +72,33 @@ static av_cold void init_vlcs(ASV1Context *a){
} }
//FIXME write a reversed bitstream reader to avoid the double reverse //FIXME write a reversed bitstream reader to avoid the double reverse
static inline int asv2_get_bits(GetBitContext *gb, int n){ static inline int asv2_get_bits(GetBitContext *gb, int n)
{
return ff_reverse[get_bits(gb, n) << (8-n)]; return ff_reverse[get_bits(gb, n) << (8-n)];
} }
static inline int asv1_get_level(GetBitContext *gb){ static inline int asv1_get_level(GetBitContext *gb)
{
int code = get_vlc2(gb, level_vlc.table, VLC_BITS, 1); int code = get_vlc2(gb, level_vlc.table, VLC_BITS, 1);
if(code==3) return get_sbits(gb, 8); if (code == 3)
else return code - 3; return get_sbits(gb, 8);
else
return code - 3;
} }
static inline int asv2_get_level(GetBitContext *gb){ static inline int asv2_get_level(GetBitContext *gb)
{
int code = get_vlc2(gb, asv2_level_vlc.table, ASV2_LEVEL_VLC_BITS, 1); int code = get_vlc2(gb, asv2_level_vlc.table, ASV2_LEVEL_VLC_BITS, 1);
if(code==31) return (int8_t)asv2_get_bits(gb, 8); if (code == 31)
else return code - 31; return (int8_t)asv2_get_bits(gb, 8);
else
return code - 31;
} }
static inline int asv1_decode_block(ASV1Context *a, DCTELEM block[64]){ static inline int asv1_decode_block(ASV1Context *a, DCTELEM block[64])
{
int i; int i;
block[0] = 8 * get_bits(&a->gb, 8); block[0] = 8 * get_bits(&a->gb, 8);
@ -98,23 +107,29 @@ static inline int asv1_decode_block(ASV1Context *a, DCTELEM block[64]){
const int ccp = get_vlc2(&a->gb, ccp_vlc.table, VLC_BITS, 1); const int ccp = get_vlc2(&a->gb, ccp_vlc.table, VLC_BITS, 1);
if (ccp) { if (ccp) {
if(ccp == 16) break; if (ccp == 16)
break;
if (ccp < 0 || i >= 10) { if (ccp < 0 || i >= 10) {
av_log(a->avctx, AV_LOG_ERROR, "coded coeff pattern damaged\n"); av_log(a->avctx, AV_LOG_ERROR, "coded coeff pattern damaged\n");
return -1; return -1;
} }
if(ccp&8) block[a->scantable.permutated[4*i+0]]= (asv1_get_level(&a->gb) * a->intra_matrix[4*i+0])>>4; if (ccp & 8)
if(ccp&4) block[a->scantable.permutated[4*i+1]]= (asv1_get_level(&a->gb) * a->intra_matrix[4*i+1])>>4; block[a->scantable.permutated[4 * i + 0]] = (asv1_get_level(&a->gb) * a->intra_matrix[4 * i + 0]) >> 4;
if(ccp&2) block[a->scantable.permutated[4*i+2]]= (asv1_get_level(&a->gb) * a->intra_matrix[4*i+2])>>4; if (ccp & 4)
if(ccp&1) block[a->scantable.permutated[4*i+3]]= (asv1_get_level(&a->gb) * a->intra_matrix[4*i+3])>>4; block[a->scantable.permutated[4 * i + 1]] = (asv1_get_level(&a->gb) * a->intra_matrix[4 * i + 1]) >> 4;
if (ccp & 2)
block[a->scantable.permutated[4 * i + 2]] = (asv1_get_level(&a->gb) * a->intra_matrix[4 * i + 2]) >> 4;
if (ccp & 1)
block[a->scantable.permutated[4 * i + 3]] = (asv1_get_level(&a->gb) * a->intra_matrix[4 * i + 3]) >> 4;
} }
} }
return 0; return 0;
} }
static inline int asv2_decode_block(ASV1Context *a, DCTELEM block[64]){ static inline int asv2_decode_block(ASV1Context *a, DCTELEM block[64])
{
int i, count, ccp; int i, count, ccp;
count = asv2_get_bits(&a->gb, 4); count = asv2_get_bits(&a->gb, 4);
@ -123,26 +138,34 @@ static inline int asv2_decode_block(ASV1Context *a, DCTELEM block[64]){
ccp = get_vlc2(&a->gb, dc_ccp_vlc.table, VLC_BITS, 1); ccp = get_vlc2(&a->gb, dc_ccp_vlc.table, VLC_BITS, 1);
if (ccp) { if (ccp) {
if(ccp&4) block[a->scantable.permutated[1]]= (asv2_get_level(&a->gb) * a->intra_matrix[1])>>4; if (ccp & 4)
if(ccp&2) block[a->scantable.permutated[2]]= (asv2_get_level(&a->gb) * a->intra_matrix[2])>>4; block[a->scantable.permutated[1]] = (asv2_get_level(&a->gb) * a->intra_matrix[1]) >> 4;
if(ccp&1) block[a->scantable.permutated[3]]= (asv2_get_level(&a->gb) * a->intra_matrix[3])>>4; if (ccp & 2)
block[a->scantable.permutated[2]] = (asv2_get_level(&a->gb) * a->intra_matrix[2]) >> 4;
if (ccp & 1)
block[a->scantable.permutated[3]] = (asv2_get_level(&a->gb) * a->intra_matrix[3]) >> 4;
} }
for (i = 1; i < count + 1; i++) { for (i = 1; i < count + 1; i++) {
const int ccp = get_vlc2(&a->gb, ac_ccp_vlc.table, VLC_BITS, 1); const int ccp = get_vlc2(&a->gb, ac_ccp_vlc.table, VLC_BITS, 1);
if (ccp) { if (ccp) {
if(ccp&8) block[a->scantable.permutated[4*i+0]]= (asv2_get_level(&a->gb) * a->intra_matrix[4*i+0])>>4; if (ccp & 8)
if(ccp&4) block[a->scantable.permutated[4*i+1]]= (asv2_get_level(&a->gb) * a->intra_matrix[4*i+1])>>4; block[a->scantable.permutated[4*i + 0]] = (asv2_get_level(&a->gb) * a->intra_matrix[4*i + 0]) >> 4;
if(ccp&2) block[a->scantable.permutated[4*i+2]]= (asv2_get_level(&a->gb) * a->intra_matrix[4*i+2])>>4; if (ccp & 4)
if(ccp&1) block[a->scantable.permutated[4*i+3]]= (asv2_get_level(&a->gb) * a->intra_matrix[4*i+3])>>4; block[a->scantable.permutated[4*i + 1]] = (asv2_get_level(&a->gb) * a->intra_matrix[4*i + 1]) >> 4;
if (ccp & 2)
block[a->scantable.permutated[4*i + 2]] = (asv2_get_level(&a->gb) * a->intra_matrix[4*i + 2]) >> 4;
if (ccp & 1)
block[a->scantable.permutated[4*i + 3]] = (asv2_get_level(&a->gb) * a->intra_matrix[4*i + 3]) >> 4;
} }
} }
return 0; return 0;
} }
static inline int decode_mb(ASV1Context *a, DCTELEM block[6][64]){ static inline int decode_mb(ASV1Context *a, DCTELEM block[6][64])
{
int i; int i;
a->dsp.clear_blocks(block[0]); a->dsp.clear_blocks(block[0]);
@ -161,7 +184,8 @@ static inline int decode_mb(ASV1Context *a, DCTELEM block[6][64]){
return 0; return 0;
} }
static inline void idct_put(ASV1Context *a, int mb_x, int mb_y){ static inline void idct_put(ASV1Context *a, int mb_x, int mb_y)
{
DCTELEM (*block)[64] = a->block; DCTELEM (*block)[64] = a->block;
int linesize = a->picture.linesize[0]; int linesize = a->picture.linesize[0];
@ -184,9 +208,9 @@ static int decode_frame(AVCodecContext *avctx,
void *data, int *got_frame, void *data, int *got_frame,
AVPacket *avpkt) AVPacket *avpkt)
{ {
ASV1Context * const a = avctx->priv_data;
const uint8_t *buf = avpkt->data; const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size; int buf_size = avpkt->size;
ASV1Context * const a = avctx->priv_data;
AVFrame *picture = data; AVFrame *picture = data;
AVFrame * const p = &a->picture; AVFrame * const p = &a->picture;
int mb_x, mb_y; int mb_x, mb_y;
@ -254,11 +278,12 @@ static int decode_frame(AVCodecContext *avctx,
return (get_bits_count(&a->gb) + 31) / 32 * 4; return (get_bits_count(&a->gb) + 31) / 32 * 4;
} }
static av_cold int decode_init(AVCodecContext *avctx){ static av_cold int decode_init(AVCodecContext *avctx)
{
ASV1Context * const a = avctx->priv_data; ASV1Context * const a = avctx->priv_data;
AVFrame *p = &a->picture; AVFrame *p = &a->picture;
int i;
const int scale = avctx->codec_id == AV_CODEC_ID_ASV1 ? 1 : 2; const int scale = avctx->codec_id == AV_CODEC_ID_ASV1 ? 1 : 2;
int i;
ff_asv_common_init(avctx); ff_asv_common_init(avctx);
init_vlcs(a); init_vlcs(a);
@ -288,7 +313,8 @@ static av_cold int decode_init(AVCodecContext *avctx){
return 0; return 0;
} }
static av_cold int decode_end(AVCodecContext *avctx){ static av_cold int decode_end(AVCodecContext *avctx)
{
ASV1Context * const a = avctx->priv_data; ASV1Context * const a = avctx->priv_data;
av_freep(&a->bitstream_buffer); av_freep(&a->bitstream_buffer);