|
|
|
@ -132,7 +132,6 @@ static void x8_reset_vlc_tables(IntraX8Context *w) |
|
|
|
|
|
|
|
|
|
static inline void x8_select_ac_table(IntraX8Context *const w, int mode) |
|
|
|
|
{ |
|
|
|
|
MpegEncContext *const s = w->s; |
|
|
|
|
int table_index; |
|
|
|
|
|
|
|
|
|
assert(mode < 4); |
|
|
|
@ -140,7 +139,7 @@ static inline void x8_select_ac_table(IntraX8Context *const w, int mode) |
|
|
|
|
if (w->j_ac_vlc[mode]) |
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
table_index = get_bits(&s->gb, 3); |
|
|
|
|
table_index = get_bits(w->gb, 3); |
|
|
|
|
// 2 modes use same tables
|
|
|
|
|
w->j_ac_vlc[mode] = &j_ac_vlc[w->quant < 13][mode >> 1][table_index]; |
|
|
|
|
|
|
|
|
@ -149,16 +148,14 @@ static inline void x8_select_ac_table(IntraX8Context *const w, int mode) |
|
|
|
|
|
|
|
|
|
static inline int x8_get_orient_vlc(IntraX8Context *w) |
|
|
|
|
{ |
|
|
|
|
MpegEncContext *const s = w->s; |
|
|
|
|
|
|
|
|
|
if (!w->j_orient_vlc) { |
|
|
|
|
int table_index = get_bits(&s->gb, 1 + (w->quant < 13)); |
|
|
|
|
int table_index = get_bits(w->gb, 1 + (w->quant < 13)); |
|
|
|
|
w->j_orient_vlc = &j_orient_vlc[w->quant < 13][table_index]; |
|
|
|
|
} |
|
|
|
|
assert(w->j_orient_vlc); |
|
|
|
|
assert(w->j_orient_vlc->table); |
|
|
|
|
|
|
|
|
|
return get_vlc2(&s->gb, w->j_orient_vlc->table, OR_VLC_BITS, OR_VLC_MTD); |
|
|
|
|
return get_vlc2(w->gb, w->j_orient_vlc->table, OR_VLC_BITS, OR_VLC_MTD); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#define extra_bits(eb) (eb) // 3 bits
|
|
|
|
@ -211,11 +208,10 @@ static const uint32_t ac_decode_table[] = { |
|
|
|
|
static void x8_get_ac_rlf(IntraX8Context *const w, const int mode, |
|
|
|
|
int *const run, int *const level, int *const final) |
|
|
|
|
{ |
|
|
|
|
MpegEncContext *const s = w->s; |
|
|
|
|
int i, e; |
|
|
|
|
|
|
|
|
|
// x8_select_ac_table(w, mode);
|
|
|
|
|
i = get_vlc2(&s->gb, w->j_ac_vlc[mode]->table, AC_VLC_BITS, AC_VLC_MTD); |
|
|
|
|
i = get_vlc2(w->gb, w->j_ac_vlc[mode]->table, AC_VLC_BITS, AC_VLC_MTD); |
|
|
|
|
|
|
|
|
|
if (i < 46) { // [0-45]
|
|
|
|
|
int t, l; |
|
|
|
@ -254,7 +250,7 @@ static void x8_get_ac_rlf(IntraX8Context *const w, const int mode, |
|
|
|
|
i -= 46; |
|
|
|
|
sm = ac_decode_table[i]; |
|
|
|
|
|
|
|
|
|
e = get_bits(&s->gb, sm & 0xF); |
|
|
|
|
e = get_bits(w->gb, sm & 0xF); |
|
|
|
|
sm >>= 8; // 3bits
|
|
|
|
|
mask = sm & 0xff; |
|
|
|
|
sm >>= 8; // 1bit
|
|
|
|
@ -271,13 +267,13 @@ static void x8_get_ac_rlf(IntraX8Context *const w, const int mode, |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
(*final) = !(i & 1); |
|
|
|
|
e = get_bits(&s->gb, 5); // get the extra bits
|
|
|
|
|
e = get_bits(w->gb, 5); // get the extra bits
|
|
|
|
|
(*run) = crazy_mix_runlevel[e] >> 4; |
|
|
|
|
(*level) = crazy_mix_runlevel[e] & 0x0F; |
|
|
|
|
} else { |
|
|
|
|
(*level) = get_bits(&s->gb, 7 - 3 * (i & 1)); |
|
|
|
|
(*run) = get_bits(&s->gb, 6); |
|
|
|
|
(*final) = get_bits1(&s->gb); |
|
|
|
|
(*level) = get_bits(w->gb, 7 - 3 * (i & 1)); |
|
|
|
|
(*run) = get_bits(w->gb, 6); |
|
|
|
|
(*final) = get_bits1(w->gb); |
|
|
|
|
} |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
@ -292,19 +288,18 @@ static const uint8_t dc_index_offset[] = { |
|
|
|
|
static int x8_get_dc_rlf(IntraX8Context *const w, const int mode, |
|
|
|
|
int *const level, int *const final) |
|
|
|
|
{ |
|
|
|
|
MpegEncContext *const s = w->s; |
|
|
|
|
int i, e, c; |
|
|
|
|
|
|
|
|
|
assert(mode < 3); |
|
|
|
|
if (!w->j_dc_vlc[mode]) { |
|
|
|
|
int table_index = get_bits(&s->gb, 3); |
|
|
|
|
int table_index = get_bits(w->gb, 3); |
|
|
|
|
// 4 modes, same table
|
|
|
|
|
w->j_dc_vlc[mode] = &j_dc_vlc[w->quant < 13][table_index]; |
|
|
|
|
} |
|
|
|
|
assert(w->j_dc_vlc); |
|
|
|
|
assert(w->j_dc_vlc[mode]->table); |
|
|
|
|
|
|
|
|
|
i = get_vlc2(&s->gb, w->j_dc_vlc[mode]->table, DC_VLC_BITS, DC_VLC_MTD); |
|
|
|
|
i = get_vlc2(w->gb, w->j_dc_vlc[mode]->table, DC_VLC_BITS, DC_VLC_MTD); |
|
|
|
|
|
|
|
|
|
/* (i >= 17) { i -= 17; final =1; } */ |
|
|
|
|
c = i > 16; |
|
|
|
@ -318,7 +313,7 @@ static int x8_get_dc_rlf(IntraX8Context *const w, const int mode, |
|
|
|
|
c = (i + 1) >> 1; // hackish way to calculate dc_extra_sbits[]
|
|
|
|
|
c -= c > 1; |
|
|
|
|
|
|
|
|
|
e = get_bits(&s->gb, c); // get the extra bits
|
|
|
|
|
e = get_bits(w->gb, c); // get the extra bits
|
|
|
|
|
i = dc_index_offset[i] + (e >> 1); |
|
|
|
|
|
|
|
|
|
e = -(e & 1); // 0, 0xffffff
|
|
|
|
@ -647,7 +642,7 @@ static int x8_decode_intra_mb(IntraX8Context *const w, const int chroma) |
|
|
|
|
level = (level + 1) * w->dquant; |
|
|
|
|
level += w->qsum; |
|
|
|
|
|
|
|
|
|
sign = -get_bits1(&s->gb); |
|
|
|
|
sign = -get_bits1(w->gb); |
|
|
|
|
level = (level ^ sign) - sign; |
|
|
|
|
|
|
|
|
|
if (use_quant_matrix) |
|
|
|
@ -775,18 +770,20 @@ av_cold void ff_intrax8_common_end(IntraX8Context *w) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int ff_intrax8_decode_picture(IntraX8Context *const w, Picture *pict, |
|
|
|
|
GetBitContext *gb, |
|
|
|
|
int dquant, int quant_offset, int loopfilter) |
|
|
|
|
{ |
|
|
|
|
MpegEncContext *const s = w->s; |
|
|
|
|
int mb_xy; |
|
|
|
|
assert(s); |
|
|
|
|
w->use_quant_matrix = get_bits1(&s->gb); |
|
|
|
|
|
|
|
|
|
w->gb = gb; |
|
|
|
|
w->dquant = dquant; |
|
|
|
|
w->quant = dquant >> 1; |
|
|
|
|
w->qsum = quant_offset; |
|
|
|
|
w->frame = pict->f; |
|
|
|
|
w->loopfilter = loopfilter; |
|
|
|
|
w->use_quant_matrix = get_bits1(w->gb); |
|
|
|
|
|
|
|
|
|
w->divide_quant_dc_luma = ((1 << 16) + (w->quant >> 1)) / w->quant; |
|
|
|
|
if (w->quant < 5) { |
|
|
|
|