|
|
@ -418,7 +418,7 @@ static void h263_decode_dquant(MpegEncContext *s){ |
|
|
|
static int h263_decode_block(MpegEncContext * s, int16_t * block, |
|
|
|
static int h263_decode_block(MpegEncContext * s, int16_t * block, |
|
|
|
int n, int coded) |
|
|
|
int n, int coded) |
|
|
|
{ |
|
|
|
{ |
|
|
|
int code, level, i, j, last, run; |
|
|
|
int level, i, j, last, run; |
|
|
|
RLTable *rl = &ff_h263_rl_inter; |
|
|
|
RLTable *rl = &ff_h263_rl_inter; |
|
|
|
const uint8_t *scan_table; |
|
|
|
const uint8_t *scan_table; |
|
|
|
GetBitContext gb= s->gb; |
|
|
|
GetBitContext gb= s->gb; |
|
|
@ -479,40 +479,66 @@ static int h263_decode_block(MpegEncContext * s, int16_t * block, |
|
|
|
return 0; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
} |
|
|
|
retry: |
|
|
|
retry: |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
OPEN_READER(re, &s->gb); |
|
|
|
for(;;) { |
|
|
|
for(;;) { |
|
|
|
code = get_vlc2(&s->gb, rl->vlc.table, TEX_VLC_BITS, 2); |
|
|
|
UPDATE_CACHE(re, &s->gb); |
|
|
|
if (code < 0){ |
|
|
|
GET_RL_VLC(level, run, re, &s->gb, rl->rl_vlc[0], TEX_VLC_BITS, 2, 0); |
|
|
|
|
|
|
|
if (run == 66 && level){ |
|
|
|
av_log(s->avctx, AV_LOG_ERROR, "illegal ac vlc code at %dx%d\n", s->mb_x, s->mb_y); |
|
|
|
av_log(s->avctx, AV_LOG_ERROR, "illegal ac vlc code at %dx%d\n", s->mb_x, s->mb_y); |
|
|
|
return -1; |
|
|
|
return -1; |
|
|
|
} |
|
|
|
} |
|
|
|
if (code == rl->n) { |
|
|
|
if (run == 66) { |
|
|
|
/* escape */ |
|
|
|
/* escape */ |
|
|
|
if (CONFIG_FLV_DECODER && s->h263_flv > 1) { |
|
|
|
if (CONFIG_FLV_DECODER && s->h263_flv > 1) { |
|
|
|
ff_flv2_decode_ac_esc(&s->gb, &level, &run, &last); |
|
|
|
int is11 = SHOW_UBITS(re, &s->gb, 1); |
|
|
|
|
|
|
|
SKIP_CACHE(re, &s->gb, 1); |
|
|
|
|
|
|
|
last = SHOW_UBITS(re, &s->gb, 1); |
|
|
|
|
|
|
|
SKIP_CACHE(re, &s->gb, 1); |
|
|
|
|
|
|
|
run = SHOW_UBITS(re, &s->gb, 6); |
|
|
|
|
|
|
|
if (is11) { |
|
|
|
|
|
|
|
SKIP_COUNTER(re, &s->gb, 6); |
|
|
|
|
|
|
|
UPDATE_CACHE(re, &s->gb); |
|
|
|
|
|
|
|
level = SHOW_SBITS(re, &s->gb, 11); |
|
|
|
|
|
|
|
SKIP_COUNTER(re, &s->gb, 1 + 1 + 6 + 11); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
SKIP_CACHE(re, &s->gb, 6); |
|
|
|
|
|
|
|
level = SHOW_SBITS(re, &s->gb, 7); |
|
|
|
|
|
|
|
SKIP_COUNTER(re, &s->gb, 1 + 1 + 6 + 7); |
|
|
|
|
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
last = get_bits1(&s->gb); |
|
|
|
last = SHOW_UBITS(re, &s->gb, 1); |
|
|
|
run = get_bits(&s->gb, 6); |
|
|
|
SKIP_CACHE(re, &s->gb, 1); |
|
|
|
level = (int8_t)get_bits(&s->gb, 8); |
|
|
|
run = SHOW_UBITS(re, &s->gb, 6); |
|
|
|
|
|
|
|
SKIP_CACHE(re, &s->gb, 6); |
|
|
|
|
|
|
|
level = (int8_t)SHOW_UBITS(re, &s->gb, 8); |
|
|
|
|
|
|
|
SKIP_COUNTER(re, &s->gb, 1 + 6 + 8); |
|
|
|
if(level == -128){ |
|
|
|
if(level == -128){ |
|
|
|
|
|
|
|
UPDATE_CACHE(re, &s->gb); |
|
|
|
if (s->codec_id == AV_CODEC_ID_RV10) { |
|
|
|
if (s->codec_id == AV_CODEC_ID_RV10) { |
|
|
|
/* XXX: should patch encoder too */ |
|
|
|
/* XXX: should patch encoder too */ |
|
|
|
level = get_sbits(&s->gb, 12); |
|
|
|
level = SHOW_SBITS(re, &s->gb, 12); |
|
|
|
|
|
|
|
SKIP_COUNTER(re, &s->gb, 12); |
|
|
|
}else{ |
|
|
|
}else{ |
|
|
|
level = get_bits(&s->gb, 5); |
|
|
|
level = SHOW_UBITS(re, &s->gb, 5); |
|
|
|
level |= get_sbits(&s->gb, 6)<<5; |
|
|
|
SKIP_CACHE(re, &s->gb, 5); |
|
|
|
|
|
|
|
level |= SHOW_SBITS(re, &s->gb, 6)<<5; |
|
|
|
|
|
|
|
SKIP_COUNTER(re, &s->gb, 5 + 6); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
run = rl->table_run[code]; |
|
|
|
run--; |
|
|
|
level = rl->table_level[code]; |
|
|
|
last = run >= 192; |
|
|
|
last = code >= rl->last; |
|
|
|
run &= 63; |
|
|
|
if (get_bits1(&s->gb)) |
|
|
|
if (SHOW_UBITS(re, &s->gb, 1)) |
|
|
|
level = -level; |
|
|
|
level = -level; |
|
|
|
|
|
|
|
SKIP_COUNTER(re, &s->gb, 1); |
|
|
|
} |
|
|
|
} |
|
|
|
i += run; |
|
|
|
i += run; |
|
|
|
if (i >= 64){ |
|
|
|
if (i >= 64){ |
|
|
|
if(s->alt_inter_vlc && rl == &ff_h263_rl_inter && !s->mb_intra){ |
|
|
|
if(s->alt_inter_vlc && rl == &ff_h263_rl_inter && !s->mb_intra){ |
|
|
|
|
|
|
|
CLOSE_READER(re, &s->gb); |
|
|
|
//Looks like a hack but no, it's the way it is supposed to work ...
|
|
|
|
//Looks like a hack but no, it's the way it is supposed to work ...
|
|
|
|
rl = &ff_rl_intra_aic; |
|
|
|
rl = &ff_rl_intra_aic; |
|
|
|
i = 0; |
|
|
|
i = 0; |
|
|
@ -529,6 +555,8 @@ retry: |
|
|
|
break; |
|
|
|
break; |
|
|
|
i++; |
|
|
|
i++; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
CLOSE_READER(re, &s->gb); |
|
|
|
|
|
|
|
} |
|
|
|
not_coded: |
|
|
|
not_coded: |
|
|
|
if (s->mb_intra && s->h263_aic) { |
|
|
|
if (s->mb_intra && s->h263_aic) { |
|
|
|
ff_h263_pred_acdc(s, block, n); |
|
|
|
ff_h263_pred_acdc(s, block, n); |
|
|
|