[FFmpeg-cvslog] avcodec/vc1: Avoid superfluous VLC structures
Andreas Rheinhardt
git at videolan.org
Tue Oct 31 22:15:49 EET 2023
ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Sun Sep 24 17:14:07 2023 +0200| [e5dcde620d5617fbfdc1e8a699415b742245638f] | committer: Andreas Rheinhardt
avcodec/vc1: Avoid superfluous VLC structures
For all VLCs here, the number of bits of the VLC is
write-only, because it is hardcoded at the call site.
Therefore one can replace these VLC structures with
the only thing that is actually used: The pointer
to the VLCElem table. And in some cases one can even
avoid this.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e5dcde620d5617fbfdc1e8a699415b742245638f
---
libavcodec/vc1.c | 60 ++++++++---------
libavcodec/vc1.h | 10 +--
libavcodec/vc1_block.c | 74 ++++++++++-----------
libavcodec/vc1data.c | 36 +++++-----
libavcodec/vc1data.h | 36 +++++-----
libavcodec/vc1dec.c | 174 ++++++++++++++++++++-----------------------------
6 files changed, 180 insertions(+), 210 deletions(-)
diff --git a/libavcodec/vc1.c b/libavcodec/vc1.c
index 795c6db541..e234192fdd 100644
--- a/libavcodec/vc1.c
+++ b/libavcodec/vc1.c
@@ -104,7 +104,7 @@ static int bitplane_decoding(uint8_t* data, int *raw_flag, VC1Context *v)
height = v->s.mb_height >> v->field_mode;
stride = v->s.mb_stride;
invert = get_bits1(gb);
- imode = get_vlc2(gb, ff_vc1_imode_vlc.table, VC1_IMODE_VLC_BITS, 1);
+ imode = get_vlc2(gb, ff_vc1_imode_vlc, VC1_IMODE_VLC_BITS, 1);
*raw_flag = 0;
switch (imode) {
@@ -126,7 +126,7 @@ static int bitplane_decoding(uint8_t* data, int *raw_flag, VC1Context *v)
y = offset = 0;
// decode bitplane as one long line
for (; y < height * width; y += 2) {
- code = get_vlc2(gb, ff_vc1_norm2_vlc.table, VC1_NORM2_VLC_BITS, 1);
+ code = get_vlc2(gb, ff_vc1_norm2_vlc, VC1_NORM2_VLC_BITS, 1);
*planep++ = code & 1;
offset++;
if (offset == width) {
@@ -146,7 +146,7 @@ static int bitplane_decoding(uint8_t* data, int *raw_flag, VC1Context *v)
if (!(height % 3) && (width % 3)) { // use 2x3 decoding
for (y = 0; y < height; y += 3) {
for (x = width & 1; x < width; x += 2) {
- code = get_vlc2(gb, ff_vc1_norm6_vlc.table, VC1_NORM6_VLC_BITS, 2);
+ code = get_vlc2(gb, ff_vc1_norm6_vlc, VC1_NORM6_VLC_BITS, 2);
if (code < 0) {
av_log(v->s.avctx, AV_LOG_DEBUG, "invalid NORM-6 VLC\n");
return -1;
@@ -166,7 +166,7 @@ static int bitplane_decoding(uint8_t* data, int *raw_flag, VC1Context *v)
planep += (height & 1) * stride;
for (y = height & 1; y < height; y += 2) {
for (x = width % 3; x < width; x += 3) {
- code = get_vlc2(gb, ff_vc1_norm6_vlc.table, VC1_NORM6_VLC_BITS, 2);
+ code = get_vlc2(gb, ff_vc1_norm6_vlc, VC1_NORM6_VLC_BITS, 2);
if (code < 0) {
av_log(v->s.avctx, AV_LOG_DEBUG, "invalid NORM-6 VLC\n");
return -1;
@@ -765,7 +765,7 @@ int ff_vc1_parse_frame_header(VC1Context *v, GetBitContext* gb)
/* Hopefully this is correct for P-frames */
v->s.mv_table_index = get_bits(gb, 2); //but using ff_vc1_ tables
v->cbptab = get_bits(gb, 2);
- v->cbpcy_vlc = &ff_vc1_cbpcy_p_vlc[v->cbptab];
+ v->cbpcy_vlc = ff_vc1_cbpcy_p_vlc[v->cbptab];
if (v->dquant) {
av_log(v->s.avctx, AV_LOG_DEBUG, "VOP DQuant info\n");
@@ -804,7 +804,7 @@ int ff_vc1_parse_frame_header(VC1Context *v, GetBitContext* gb)
v->s.mv_table_index = get_bits(gb, 2);
v->cbptab = get_bits(gb, 2);
- v->cbpcy_vlc = &ff_vc1_cbpcy_p_vlc[v->cbptab];
+ v->cbpcy_vlc = ff_vc1_cbpcy_p_vlc[v->cbptab];
if (v->dquant) {
av_log(v->s.avctx, AV_LOG_DEBUG, "VOP DQuant info\n");
@@ -1061,19 +1061,19 @@ int ff_vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb)
"Imode: %i, Invert: %i\n", status>>1, status&1);
v->mbmodetab = get_bits(gb, 2);
if (v->fourmvswitch)
- v->mbmode_vlc = &ff_vc1_intfr_4mv_mbmode_vlc[v->mbmodetab];
+ v->mbmode_vlc = ff_vc1_intfr_4mv_mbmode_vlc[v->mbmodetab];
else
- v->mbmode_vlc = &ff_vc1_intfr_non4mv_mbmode_vlc[v->mbmodetab];
+ v->mbmode_vlc = ff_vc1_intfr_non4mv_mbmode_vlc[v->mbmodetab];
v->imvtab = get_bits(gb, 2);
- v->imv_vlc = &ff_vc1_1ref_mvdata_vlc[v->imvtab];
+ v->imv_vlc = ff_vc1_1ref_mvdata_vlc[v->imvtab];
// interlaced p-picture cbpcy range is [1, 63]
v->icbptab = get_bits(gb, 3);
- v->cbpcy_vlc = &ff_vc1_icbpcy_vlc[v->icbptab];
+ v->cbpcy_vlc = ff_vc1_icbpcy_vlc[v->icbptab];
v->twomvbptab = get_bits(gb, 2);
- v->twomvbp_vlc = &ff_vc1_2mv_block_pattern_vlc[v->twomvbptab];
+ v->twomvbp_vlc = ff_vc1_2mv_block_pattern_vlc[v->twomvbptab];
if (v->fourmvswitch) {
v->fourmvbptab = get_bits(gb, 2);
- v->fourmvbp_vlc = &ff_vc1_4mv_block_pattern_vlc[v->fourmvbptab];
+ v->fourmvbp_vlc = ff_vc1_4mv_block_pattern_vlc[v->fourmvbptab];
}
}
}
@@ -1158,7 +1158,7 @@ int ff_vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb)
/* Hopefully this is correct for P-frames */
v->s.mv_table_index = get_bits(gb, 2); //but using ff_vc1_ tables
v->cbptab = get_bits(gb, 2);
- v->cbpcy_vlc = &ff_vc1_cbpcy_p_vlc[v->cbptab];
+ v->cbpcy_vlc = ff_vc1_cbpcy_p_vlc[v->cbptab];
} else if (v->fcm == ILACE_FRAME) { // frame interlaced
v->qs_last = v->s.quarter_sample;
v->s.quarter_sample = 1;
@@ -1167,18 +1167,18 @@ int ff_vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb)
v->mbmodetab = get_bits(gb, 3);
v->imvtab = get_bits(gb, 2 + v->numref);
if (!v->numref)
- v->imv_vlc = &ff_vc1_1ref_mvdata_vlc[v->imvtab];
+ v->imv_vlc = ff_vc1_1ref_mvdata_vlc[v->imvtab];
else
- v->imv_vlc = &ff_vc1_2ref_mvdata_vlc[v->imvtab];
+ v->imv_vlc = ff_vc1_2ref_mvdata_vlc[v->imvtab];
v->icbptab = get_bits(gb, 3);
- v->cbpcy_vlc = &ff_vc1_icbpcy_vlc[v->icbptab];
+ v->cbpcy_vlc = ff_vc1_icbpcy_vlc[v->icbptab];
if ((v->mv_mode == MV_PMODE_INTENSITY_COMP &&
v->mv_mode2 == MV_PMODE_MIXED_MV) || v->mv_mode == MV_PMODE_MIXED_MV) {
v->fourmvbptab = get_bits(gb, 2);
- v->fourmvbp_vlc = &ff_vc1_4mv_block_pattern_vlc[v->fourmvbptab];
- v->mbmode_vlc = &ff_vc1_if_mmv_mbmode_vlc[v->mbmodetab];
+ v->fourmvbp_vlc = ff_vc1_4mv_block_pattern_vlc[v->fourmvbptab];
+ v->mbmode_vlc = ff_vc1_if_mmv_mbmode_vlc[v->mbmodetab];
} else {
- v->mbmode_vlc = &ff_vc1_if_1mv_mbmode_vlc[v->mbmodetab];
+ v->mbmode_vlc = ff_vc1_if_1mv_mbmode_vlc[v->mbmodetab];
}
}
if (v->dquant) {
@@ -1234,16 +1234,16 @@ int ff_vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb)
"Imode: %i, Invert: %i\n", status>>1, status&1);
v->mbmodetab = get_bits(gb, 3);
if (v->mv_mode == MV_PMODE_MIXED_MV)
- v->mbmode_vlc = &ff_vc1_if_mmv_mbmode_vlc[v->mbmodetab];
+ v->mbmode_vlc = ff_vc1_if_mmv_mbmode_vlc[v->mbmodetab];
else
- v->mbmode_vlc = &ff_vc1_if_1mv_mbmode_vlc[v->mbmodetab];
+ v->mbmode_vlc = ff_vc1_if_1mv_mbmode_vlc[v->mbmodetab];
v->imvtab = get_bits(gb, 3);
- v->imv_vlc = &ff_vc1_2ref_mvdata_vlc[v->imvtab];
+ v->imv_vlc = ff_vc1_2ref_mvdata_vlc[v->imvtab];
v->icbptab = get_bits(gb, 3);
- v->cbpcy_vlc = &ff_vc1_icbpcy_vlc[v->icbptab];
+ v->cbpcy_vlc = ff_vc1_icbpcy_vlc[v->icbptab];
if (v->mv_mode == MV_PMODE_MIXED_MV) {
v->fourmvbptab = get_bits(gb, 2);
- v->fourmvbp_vlc = &ff_vc1_4mv_block_pattern_vlc[v->fourmvbptab];
+ v->fourmvbp_vlc = ff_vc1_4mv_block_pattern_vlc[v->fourmvbptab];
}
v->numref = 1; // interlaced field B pictures are always 2-ref
} else if (v->fcm == ILACE_FRAME) {
@@ -1268,16 +1268,16 @@ int ff_vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb)
av_log(v->s.avctx, AV_LOG_DEBUG, "MB Skip plane encoding: "
"Imode: %i, Invert: %i\n", status>>1, status&1);
v->mbmodetab = get_bits(gb, 2);
- v->mbmode_vlc = &ff_vc1_intfr_non4mv_mbmode_vlc[v->mbmodetab];
+ v->mbmode_vlc = ff_vc1_intfr_non4mv_mbmode_vlc[v->mbmodetab];
v->imvtab = get_bits(gb, 2);
- v->imv_vlc = &ff_vc1_1ref_mvdata_vlc[v->imvtab];
+ v->imv_vlc = ff_vc1_1ref_mvdata_vlc[v->imvtab];
// interlaced p/b-picture cbpcy range is [1, 63]
v->icbptab = get_bits(gb, 3);
- v->cbpcy_vlc = &ff_vc1_icbpcy_vlc[v->icbptab];
+ v->cbpcy_vlc = ff_vc1_icbpcy_vlc[v->icbptab];
v->twomvbptab = get_bits(gb, 2);
- v->twomvbp_vlc = &ff_vc1_2mv_block_pattern_vlc[v->twomvbptab];
+ v->twomvbp_vlc = ff_vc1_2mv_block_pattern_vlc[v->twomvbptab];
v->fourmvbptab = get_bits(gb, 2);
- v->fourmvbp_vlc = &ff_vc1_4mv_block_pattern_vlc[v->fourmvbptab];
+ v->fourmvbp_vlc = ff_vc1_4mv_block_pattern_vlc[v->fourmvbptab];
} else {
v->mv_mode = get_bits1(gb) ? MV_PMODE_1MV : MV_PMODE_1MV_HPEL_BILIN;
v->qs_last = v->s.quarter_sample;
@@ -1295,7 +1295,7 @@ int ff_vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb)
"Imode: %i, Invert: %i\n", status>>1, status&1);
v->s.mv_table_index = get_bits(gb, 2);
v->cbptab = get_bits(gb, 2);
- v->cbpcy_vlc = &ff_vc1_cbpcy_p_vlc[v->cbptab];
+ v->cbpcy_vlc = ff_vc1_cbpcy_p_vlc[v->cbptab];
}
if (v->dquant) {
diff --git a/libavcodec/vc1.h b/libavcodec/vc1.h
index 3b6be78141..0e01458c89 100644
--- a/libavcodec/vc1.h
+++ b/libavcodec/vc1.h
@@ -279,7 +279,7 @@ typedef struct VC1Context{
*/
uint8_t mvrange; ///< Extended MV range flag
uint8_t pquantizer; ///< Uniform (over sequence) quantizer in use
- VLC *cbpcy_vlc; ///< CBPCY VLC table
+ const VLCElem *cbpcy_vlc; ///< CBPCY VLC table
int tt_index; ///< Index for Transform Type tables (to decode TTMB)
uint8_t* mv_type_mb_plane; ///< bitplane for mv_type == (4MV)
uint8_t* direct_mb_plane; ///< bitplane for "direct" MBs
@@ -334,10 +334,10 @@ typedef struct VC1Context{
int intcomp;
uint8_t lumscale2; ///< for interlaced field P picture
uint8_t lumshift2;
- VLC* mbmode_vlc;
- VLC* imv_vlc;
- VLC* twomvbp_vlc;
- VLC* fourmvbp_vlc;
+ const VLCElem *mbmode_vlc;
+ const VLCElem *imv_vlc;
+ const VLCElem *twomvbp_vlc;
+ const VLCElem *fourmvbp_vlc;
uint8_t twomvbp;
uint8_t fourmvbp;
uint8_t* fieldtx_plane;
diff --git a/libavcodec/vc1_block.c b/libavcodec/vc1_block.c
index 751ea57617..a6ee4922f9 100644
--- a/libavcodec/vc1_block.c
+++ b/libavcodec/vc1_block.c
@@ -227,7 +227,7 @@ static void vc1_put_blocks_clamped(VC1Context *v, int put_signed)
* @param _dmv_y Vertical differential for decoded MV
*/
#define GET_MVDATA(_dmv_x, _dmv_y) \
- index = 1 + get_vlc2(gb, ff_vc1_mv_diff_vlc[s->mv_table_index].table, \
+ index = 1 + get_vlc2(gb, ff_vc1_mv_diff_vlc[s->mv_table_index], \
VC1_MV_DIFF_VLC_BITS, 2); \
if (index > 36) { \
mb_has_coeffs = 1; \
@@ -282,7 +282,7 @@ static av_always_inline void get_mvdata_interlaced(VC1Context *v, int *dmv_x,
}
extend_x = v->dmvrange & 1;
extend_y = (v->dmvrange >> 1) & 1;
- index = get_vlc2(gb, v->imv_vlc->table, bits, 3);
+ index = get_vlc2(gb, v->imv_vlc, bits, 3);
if (index == esc) {
*dmv_x = get_bits(gb, v->k_x);
*dmv_y = get_bits(gb, v->k_y);
@@ -519,7 +519,7 @@ static int vc1_decode_ac_coeff(VC1Context *v, int *last, int *skip,
GetBitContext *gb = &v->s.gb;
int index, run, level, lst, sign;
- index = get_vlc2(gb, ff_vc1_ac_coeff_table[codingset].table, AC_VLC_BITS, 3);
+ index = get_vlc2(gb, ff_vc1_ac_coeff_table[codingset], AC_VLC_BITS, 3);
if (index < 0)
return index;
if (index != ff_vc1_ac_sizes[codingset] - 1) {
@@ -530,7 +530,7 @@ static int vc1_decode_ac_coeff(VC1Context *v, int *last, int *skip,
} else {
int escape = decode210(gb);
if (escape != 2) {
- index = get_vlc2(gb, ff_vc1_ac_coeff_table[codingset].table, AC_VLC_BITS, 3);
+ index = get_vlc2(gb, ff_vc1_ac_coeff_table[codingset], AC_VLC_BITS, 3);
if (index >= ff_vc1_ac_sizes[codingset] - 1U)
return AVERROR_INVALIDDATA;
run = vc1_index_decode_table[codingset][index][0];
@@ -1124,10 +1124,10 @@ static int vc1_decode_p_block(VC1Context *v, int16_t block[64], int n,
s->bdsp.clear_block(block);
if (ttmb == -1) {
- ttblk = ff_vc1_ttblk_to_tt[v->tt_index][get_vlc2(gb, ff_vc1_ttblk_vlc[v->tt_index].table, VC1_TTBLK_VLC_BITS, 1)];
+ ttblk = ff_vc1_ttblk_to_tt[v->tt_index][get_vlc2(gb, ff_vc1_ttblk_vlc[v->tt_index], VC1_TTBLK_VLC_BITS, 1)];
}
if (ttblk == TT_4X4) {
- subblkpat = ~(get_vlc2(gb, ff_vc1_subblkpat_vlc[v->tt_index].table, VC1_SUBBLKPAT_VLC_BITS, 1) + 1);
+ subblkpat = ~(get_vlc2(gb, ff_vc1_subblkpat_vlc[v->tt_index], VC1_SUBBLKPAT_VLC_BITS, 1) + 1);
}
if ((ttblk != TT_8X8 && ttblk != TT_4X4)
&& ((v->ttmbf || (ttmb != -1 && (ttmb & 8) && !first_block))
@@ -1328,7 +1328,7 @@ static int vc1_decode_p_mb(VC1Context *v)
} else if (mb_has_coeffs) {
if (s->mb_intra)
s->ac_pred = get_bits1(gb);
- cbp = get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2);
+ cbp = get_vlc2(&v->s.gb, v->cbpcy_vlc, VC1_CBPCY_P_VLC_BITS, 2);
GET_MQUANT();
} else {
mquant = v->pq;
@@ -1337,7 +1337,7 @@ static int vc1_decode_p_mb(VC1Context *v)
s->current_picture.qscale_table[mb_pos] = mquant;
if (!v->ttmbf && !s->mb_intra && mb_has_coeffs)
- ttmb = get_vlc2(gb, ff_vc1_ttmb_vlc[v->tt_index].table,
+ ttmb = get_vlc2(gb, ff_vc1_ttmb_vlc[v->tt_index],
VC1_TTMB_VLC_BITS, 2);
if (!s->mb_intra) ff_vc1_mc_1mv(v, 0);
dst_idx = 0;
@@ -1393,7 +1393,7 @@ static int vc1_decode_p_mb(VC1Context *v)
int intra_count = 0, coded_inter = 0;
int is_intra[6], is_coded[6];
/* Get CBPCY */
- cbp = get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2);
+ cbp = get_vlc2(&v->s.gb, v->cbpcy_vlc, VC1_CBPCY_P_VLC_BITS, 2);
for (i = 0; i < 6; i++) {
val = ((cbp >> (5 - i)) & 1);
s->dc_val[0][s->block_index[i]] = 0;
@@ -1445,7 +1445,7 @@ static int vc1_decode_p_mb(VC1Context *v)
s->ac_pred = 0;
}
if (!v->ttmbf && coded_inter)
- ttmb = get_vlc2(gb, ff_vc1_ttmb_vlc[v->tt_index].table, VC1_TTMB_VLC_BITS, 2);
+ ttmb = get_vlc2(gb, ff_vc1_ttmb_vlc[v->tt_index], VC1_TTMB_VLC_BITS, 2);
for (i = 0; i < 6; i++) {
dst_idx += i >> 2;
off = (i & 4) ? 0 : ((i & 1) * 8 + (i & 2) * 4 * s->linesize);
@@ -1539,9 +1539,9 @@ static int vc1_decode_p_mb_intfr(VC1Context *v)
skipped = v->s.mbskip_table[mb_pos];
if (!skipped) {
if (v->fourmvswitch)
- idx_mbmode = get_vlc2(gb, v->mbmode_vlc->table, VC1_INTFR_4MV_MBMODE_VLC_BITS, 2); // try getting this done
+ idx_mbmode = get_vlc2(gb, v->mbmode_vlc, VC1_INTFR_4MV_MBMODE_VLC_BITS, 2); // try getting this done
else
- idx_mbmode = get_vlc2(gb, v->mbmode_vlc->table, VC1_INTFR_NON4MV_MBMODE_VLC_BITS, 2); // in a single line
+ idx_mbmode = get_vlc2(gb, v->mbmode_vlc, VC1_INTFR_NON4MV_MBMODE_VLC_BITS, 2); // in a single line
switch (ff_vc1_mbmode_intfrp[v->fourmvswitch][idx_mbmode][0]) {
/* store the motion vector type in a flag (useful later) */
case MV_PMODE_INTFR_4MV:
@@ -1583,7 +1583,7 @@ static int vc1_decode_p_mb_intfr(VC1Context *v)
fieldtx = v->fieldtx_plane[mb_pos] = get_bits1(gb);
mb_has_coeffs = get_bits1(gb);
if (mb_has_coeffs)
- cbp = 1 + get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2);
+ cbp = 1 + get_vlc2(&v->s.gb, v->cbpcy_vlc, VC1_CBPCY_P_VLC_BITS, 2);
v->s.ac_pred = v->acpred_plane[mb_pos] = get_bits1(gb);
GET_MQUANT();
s->current_picture.qscale_table[mb_pos] = mquant;
@@ -1617,13 +1617,13 @@ static int vc1_decode_p_mb_intfr(VC1Context *v)
} else { // inter MB
mb_has_coeffs = ff_vc1_mbmode_intfrp[v->fourmvswitch][idx_mbmode][3];
if (mb_has_coeffs)
- cbp = 1 + get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2);
+ cbp = 1 + get_vlc2(&v->s.gb, v->cbpcy_vlc, VC1_CBPCY_P_VLC_BITS, 2);
if (ff_vc1_mbmode_intfrp[v->fourmvswitch][idx_mbmode][0] == MV_PMODE_INTFR_2MV_FIELD) {
- v->twomvbp = get_vlc2(gb, v->twomvbp_vlc->table, VC1_2MV_BLOCK_PATTERN_VLC_BITS, 1);
+ v->twomvbp = get_vlc2(gb, v->twomvbp_vlc, VC1_2MV_BLOCK_PATTERN_VLC_BITS, 1);
} else {
if ((ff_vc1_mbmode_intfrp[v->fourmvswitch][idx_mbmode][0] == MV_PMODE_INTFR_4MV)
|| (ff_vc1_mbmode_intfrp[v->fourmvswitch][idx_mbmode][0] == MV_PMODE_INTFR_4MV_FIELD)) {
- v->fourmvbp = get_vlc2(gb, v->fourmvbp_vlc->table, VC1_4MV_BLOCK_PATTERN_VLC_BITS, 1);
+ v->fourmvbp = get_vlc2(gb, v->fourmvbp_vlc, VC1_4MV_BLOCK_PATTERN_VLC_BITS, 1);
}
}
s->mb_intra = v->is_intra[s->mb_x] = 0;
@@ -1672,7 +1672,7 @@ static int vc1_decode_p_mb_intfr(VC1Context *v)
GET_MQUANT(); // p. 227
s->current_picture.qscale_table[mb_pos] = mquant;
if (!v->ttmbf && cbp)
- ttmb = get_vlc2(gb, ff_vc1_ttmb_vlc[v->tt_index].table, VC1_TTMB_VLC_BITS, 2);
+ ttmb = get_vlc2(gb, ff_vc1_ttmb_vlc[v->tt_index], VC1_TTMB_VLC_BITS, 2);
for (i = 0; i < 6; i++) {
s->dc_val[0][s->block_index[i]] = 0;
dst_idx += i >> 2;
@@ -1742,7 +1742,7 @@ static int vc1_decode_p_mb_intfi(VC1Context *v)
mquant = v->pq; /* Lossy initialization */
- idx_mbmode = get_vlc2(gb, v->mbmode_vlc->table, VC1_IF_MBMODE_VLC_BITS, 2);
+ idx_mbmode = get_vlc2(gb, v->mbmode_vlc, VC1_IF_MBMODE_VLC_BITS, 2);
if (idx_mbmode <= 1) { // intra MB
v->is_intra[s->mb_x] = 0x3f; // Set the bitfield to all 1.
s->mb_intra = 1;
@@ -1757,7 +1757,7 @@ static int vc1_decode_p_mb_intfi(VC1Context *v)
v->s.ac_pred = v->acpred_plane[mb_pos] = get_bits1(gb);
mb_has_coeffs = idx_mbmode & 1;
if (mb_has_coeffs)
- cbp = 1 + get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_ICBPCY_VLC_BITS, 2);
+ cbp = 1 + get_vlc2(&v->s.gb, v->cbpcy_vlc, VC1_ICBPCY_VLC_BITS, 2);
dst_idx = 0;
for (i = 0; i < 6; i++) {
v->a_avail = v->c_avail = 0;
@@ -1792,7 +1792,7 @@ static int vc1_decode_p_mb_intfi(VC1Context *v)
ff_vc1_mc_1mv(v, 0);
mb_has_coeffs = !(idx_mbmode & 2);
} else { // 4-MV
- v->fourmvbp = get_vlc2(gb, v->fourmvbp_vlc->table, VC1_4MV_BLOCK_PATTERN_VLC_BITS, 1);
+ v->fourmvbp = get_vlc2(gb, v->fourmvbp_vlc, VC1_4MV_BLOCK_PATTERN_VLC_BITS, 1);
for (i = 0; i < 4; i++) {
dmv_x = dmv_y = pred_flag = 0;
if (v->fourmvbp & (8 >> i))
@@ -1804,13 +1804,13 @@ static int vc1_decode_p_mb_intfi(VC1Context *v)
mb_has_coeffs = idx_mbmode & 1;
}
if (mb_has_coeffs)
- cbp = 1 + get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2);
+ cbp = 1 + get_vlc2(&v->s.gb, v->cbpcy_vlc, VC1_CBPCY_P_VLC_BITS, 2);
if (cbp) {
GET_MQUANT();
}
s->current_picture.qscale_table[mb_pos] = mquant;
if (!v->ttmbf && cbp) {
- ttmb = get_vlc2(gb, ff_vc1_ttmb_vlc[v->tt_index].table, VC1_TTMB_VLC_BITS, 2);
+ ttmb = get_vlc2(gb, ff_vc1_ttmb_vlc[v->tt_index], VC1_TTMB_VLC_BITS, 2);
}
dst_idx = 0;
for (i = 0; i < 6; i++) {
@@ -1914,12 +1914,12 @@ static int vc1_decode_b_mb(VC1Context *v)
return 0;
}
if (direct) {
- cbp = get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2);
+ cbp = get_vlc2(&v->s.gb, v->cbpcy_vlc, VC1_CBPCY_P_VLC_BITS, 2);
GET_MQUANT();
s->mb_intra = 0;
s->current_picture.qscale_table[mb_pos] = mquant;
if (!v->ttmbf)
- ttmb = get_vlc2(gb, ff_vc1_ttmb_vlc[v->tt_index].table, VC1_TTMB_VLC_BITS, 2);
+ ttmb = get_vlc2(gb, ff_vc1_ttmb_vlc[v->tt_index], VC1_TTMB_VLC_BITS, 2);
dmv_x[0] = dmv_y[0] = dmv_x[1] = dmv_y[1] = 0;
ff_vc1_pred_b_mv(v, dmv_x, dmv_y, direct, bmvtype);
vc1_b_mc(v, dmv_x, dmv_y, direct, bmvtype);
@@ -1952,11 +1952,11 @@ static int vc1_decode_b_mb(VC1Context *v)
}
if (s->mb_intra)
s->ac_pred = get_bits1(gb);
- cbp = get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2);
+ cbp = get_vlc2(&v->s.gb, v->cbpcy_vlc, VC1_CBPCY_P_VLC_BITS, 2);
GET_MQUANT();
s->current_picture.qscale_table[mb_pos] = mquant;
if (!v->ttmbf && !s->mb_intra && mb_has_coeffs)
- ttmb = get_vlc2(gb, ff_vc1_ttmb_vlc[v->tt_index].table, VC1_TTMB_VLC_BITS, 2);
+ ttmb = get_vlc2(gb, ff_vc1_ttmb_vlc[v->tt_index], VC1_TTMB_VLC_BITS, 2);
}
}
dst_idx = 0;
@@ -2025,7 +2025,7 @@ static int vc1_decode_b_mb_intfi(VC1Context *v)
mquant = v->pq; /* Lossy initialization */
s->mb_intra = 0;
- idx_mbmode = get_vlc2(gb, v->mbmode_vlc->table, VC1_IF_MBMODE_VLC_BITS, 2);
+ idx_mbmode = get_vlc2(gb, v->mbmode_vlc, VC1_IF_MBMODE_VLC_BITS, 2);
if (idx_mbmode <= 1) { // intra MB
v->is_intra[s->mb_x] = 0x3f; // Set the bitfield to all 1.
s->mb_intra = 1;
@@ -2040,7 +2040,7 @@ static int vc1_decode_b_mb_intfi(VC1Context *v)
v->s.ac_pred = v->acpred_plane[mb_pos] = get_bits1(gb);
mb_has_coeffs = idx_mbmode & 1;
if (mb_has_coeffs)
- cbp = 1 + get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_ICBPCY_VLC_BITS, 2);
+ cbp = 1 + get_vlc2(&v->s.gb, v->cbpcy_vlc, VC1_ICBPCY_VLC_BITS, 2);
dst_idx = 0;
for (i = 0; i < 6; i++) {
v->a_avail = v->c_avail = 0;
@@ -2118,7 +2118,7 @@ static int vc1_decode_b_mb_intfi(VC1Context *v)
if (fwd)
bmvtype = BMV_TYPE_FORWARD;
v->bmvtype = bmvtype;
- v->fourmvbp = get_vlc2(gb, v->fourmvbp_vlc->table, VC1_4MV_BLOCK_PATTERN_VLC_BITS, 1);
+ v->fourmvbp = get_vlc2(gb, v->fourmvbp_vlc, VC1_4MV_BLOCK_PATTERN_VLC_BITS, 1);
for (i = 0; i < 4; i++) {
dmv_x[0] = dmv_y[0] = pred_flag[0] = 0;
dmv_x[1] = dmv_y[1] = pred_flag[1] = 0;
@@ -2134,13 +2134,13 @@ static int vc1_decode_b_mb_intfi(VC1Context *v)
mb_has_coeffs = idx_mbmode & 1;
}
if (mb_has_coeffs)
- cbp = 1 + get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2);
+ cbp = 1 + get_vlc2(&v->s.gb, v->cbpcy_vlc, VC1_CBPCY_P_VLC_BITS, 2);
if (cbp) {
GET_MQUANT();
}
s->current_picture.qscale_table[mb_pos] = mquant;
if (!v->ttmbf && cbp) {
- ttmb = get_vlc2(gb, ff_vc1_ttmb_vlc[v->tt_index].table, VC1_TTMB_VLC_BITS, 2);
+ ttmb = get_vlc2(gb, ff_vc1_ttmb_vlc[v->tt_index], VC1_TTMB_VLC_BITS, 2);
}
dst_idx = 0;
for (i = 0; i < 6; i++) {
@@ -2200,7 +2200,7 @@ static int vc1_decode_b_mb_intfr(VC1Context *v)
skipped = v->s.mbskip_table[mb_pos];
if (!skipped) {
- idx_mbmode = get_vlc2(gb, v->mbmode_vlc->table, VC1_INTFR_NON4MV_MBMODE_VLC_BITS, 2);
+ idx_mbmode = get_vlc2(gb, v->mbmode_vlc, VC1_INTFR_NON4MV_MBMODE_VLC_BITS, 2);
if (ff_vc1_mbmode_intfrp[0][idx_mbmode][0] == MV_PMODE_INTFR_2MV_FIELD) {
twomv = 1;
v->blk_mv_type[s->block_index[0]] = 1;
@@ -2228,7 +2228,7 @@ static int vc1_decode_b_mb_intfr(VC1Context *v)
fieldtx = v->fieldtx_plane[mb_pos] = get_bits1(gb);
mb_has_coeffs = get_bits1(gb);
if (mb_has_coeffs)
- cbp = 1 + get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2);
+ cbp = 1 + get_vlc2(&v->s.gb, v->cbpcy_vlc, VC1_CBPCY_P_VLC_BITS, 2);
v->s.ac_pred = v->acpred_plane[mb_pos] = get_bits1(gb);
GET_MQUANT();
s->current_picture.qscale_table[mb_pos] = mquant;
@@ -2323,12 +2323,12 @@ static int vc1_decode_b_mb_intfr(VC1Context *v)
if (!skipped) { // inter MB
mb_has_coeffs = ff_vc1_mbmode_intfrp[0][idx_mbmode][3];
if (mb_has_coeffs)
- cbp = 1 + get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2);
+ cbp = 1 + get_vlc2(&v->s.gb, v->cbpcy_vlc, VC1_CBPCY_P_VLC_BITS, 2);
if (!direct) {
if (bmvtype == BMV_TYPE_INTERPOLATED && twomv) {
- v->fourmvbp = get_vlc2(gb, v->fourmvbp_vlc->table, VC1_4MV_BLOCK_PATTERN_VLC_BITS, 1);
+ v->fourmvbp = get_vlc2(gb, v->fourmvbp_vlc, VC1_4MV_BLOCK_PATTERN_VLC_BITS, 1);
} else if (bmvtype == BMV_TYPE_INTERPOLATED || twomv) {
- v->twomvbp = get_vlc2(gb, v->twomvbp_vlc->table, VC1_2MV_BLOCK_PATTERN_VLC_BITS, 1);
+ v->twomvbp = get_vlc2(gb, v->twomvbp_vlc, VC1_2MV_BLOCK_PATTERN_VLC_BITS, 1);
}
}
@@ -2438,7 +2438,7 @@ static int vc1_decode_b_mb_intfr(VC1Context *v)
GET_MQUANT(); // p. 227
s->current_picture.qscale_table[mb_pos] = mquant;
if (!v->ttmbf && cbp)
- ttmb = get_vlc2(gb, ff_vc1_ttmb_vlc[v->tt_index].table, VC1_TTMB_VLC_BITS, 2);
+ ttmb = get_vlc2(gb, ff_vc1_ttmb_vlc[v->tt_index], VC1_TTMB_VLC_BITS, 2);
for (i = 0; i < 6; i++) {
s->dc_val[0][s->block_index[i]] = 0;
dst_idx += i >> 2;
diff --git a/libavcodec/vc1data.c b/libavcodec/vc1data.c
index 5ebf20a0f0..4046ea042f 100644
--- a/libavcodec/vc1data.c
+++ b/libavcodec/vc1data.c
@@ -102,26 +102,26 @@ const uint8_t ff_vc1_pquant_table[3][32] = {
* @todo TODO move this into the context
*/
//@{
-VLC ff_vc1_imode_vlc;
-VLC ff_vc1_norm2_vlc;
-VLC ff_vc1_norm6_vlc;
+VLCElem ff_vc1_imode_vlc[1 << VC1_IMODE_VLC_BITS];
+VLCElem ff_vc1_norm2_vlc[1 << VC1_NORM2_VLC_BITS];
+VLCElem ff_vc1_norm6_vlc[556];
/* Could be optimized, one table only needs 8 bits */
-VLC ff_vc1_ttmb_vlc[3];
-VLC ff_vc1_mv_diff_vlc[4];
-VLC ff_vc1_cbpcy_p_vlc[4];
-VLC ff_vc1_icbpcy_vlc[8];
-VLC ff_vc1_4mv_block_pattern_vlc[4];
-VLC ff_vc1_2mv_block_pattern_vlc[4];
-VLC ff_vc1_ttblk_vlc[3];
-VLC ff_vc1_subblkpat_vlc[3];
-VLC ff_vc1_intfr_4mv_mbmode_vlc[4];
-VLC ff_vc1_intfr_non4mv_mbmode_vlc[4];
-VLC ff_vc1_if_mmv_mbmode_vlc[8];
-VLC ff_vc1_if_1mv_mbmode_vlc[8];
-VLC ff_vc1_1ref_mvdata_vlc[4];
-VLC ff_vc1_2ref_mvdata_vlc[8];
+const VLCElem *ff_vc1_ttmb_vlc[3];
+const VLCElem *ff_vc1_mv_diff_vlc[4];
+const VLCElem *ff_vc1_cbpcy_p_vlc[4];
+const VLCElem *ff_vc1_icbpcy_vlc[8];
+const VLCElem *ff_vc1_4mv_block_pattern_vlc[4];
+const VLCElem *ff_vc1_2mv_block_pattern_vlc[4];
+const VLCElem *ff_vc1_ttblk_vlc[3];
+const VLCElem *ff_vc1_subblkpat_vlc[3];
+const VLCElem *ff_vc1_intfr_4mv_mbmode_vlc[4];
+const VLCElem *ff_vc1_intfr_non4mv_mbmode_vlc[4];
+const VLCElem *ff_vc1_if_mmv_mbmode_vlc[8];
+const VLCElem *ff_vc1_if_1mv_mbmode_vlc[8];
+const VLCElem *ff_vc1_1ref_mvdata_vlc[4];
+const VLCElem *ff_vc1_2ref_mvdata_vlc[8];
-VLC ff_vc1_ac_coeff_table[8];
+const VLCElem *ff_vc1_ac_coeff_table[8];
//@}
diff --git a/libavcodec/vc1data.h b/libavcodec/vc1data.h
index 0900469ab2..e71593d023 100644
--- a/libavcodec/vc1data.h
+++ b/libavcodec/vc1data.h
@@ -56,42 +56,42 @@ extern const uint8_t ff_vc1_mbmode_intfrp[2][15][4];
*/
//@{
#define VC1_IMODE_VLC_BITS 4
-extern VLC ff_vc1_imode_vlc;
+extern VLCElem ff_vc1_imode_vlc[1 << VC1_IMODE_VLC_BITS];
#define VC1_NORM2_VLC_BITS 3
-extern VLC ff_vc1_norm2_vlc;
+extern VLCElem ff_vc1_norm2_vlc[1 << VC1_NORM2_VLC_BITS];
#define VC1_NORM6_VLC_BITS 9
-extern VLC ff_vc1_norm6_vlc;
+extern VLCElem ff_vc1_norm6_vlc[556];
/* Could be optimized, one table only needs 8 bits */
#define VC1_TTMB_VLC_BITS 9 //12
-extern VLC ff_vc1_ttmb_vlc[3];
+extern const VLCElem *ff_vc1_ttmb_vlc[3];
#define VC1_MV_DIFF_VLC_BITS 9 //15
-extern VLC ff_vc1_mv_diff_vlc[4];
+extern const VLCElem *ff_vc1_mv_diff_vlc[4];
#define VC1_CBPCY_P_VLC_BITS 9 //14
-extern VLC ff_vc1_cbpcy_p_vlc[4];
+extern const VLCElem *ff_vc1_cbpcy_p_vlc[4];
#define VC1_ICBPCY_VLC_BITS 9
-extern VLC ff_vc1_icbpcy_vlc[8];
+extern const VLCElem *ff_vc1_icbpcy_vlc[8];
#define VC1_4MV_BLOCK_PATTERN_VLC_BITS 6
-extern VLC ff_vc1_4mv_block_pattern_vlc[4];
+extern const VLCElem *ff_vc1_4mv_block_pattern_vlc[4];
#define VC1_2MV_BLOCK_PATTERN_VLC_BITS 3
-extern VLC ff_vc1_2mv_block_pattern_vlc[4];
+extern const VLCElem *ff_vc1_2mv_block_pattern_vlc[4];
#define VC1_TTBLK_VLC_BITS 5
-extern VLC ff_vc1_ttblk_vlc[3];
+extern const VLCElem *ff_vc1_ttblk_vlc[3];
#define VC1_SUBBLKPAT_VLC_BITS 6
-extern VLC ff_vc1_subblkpat_vlc[3];
+extern const VLCElem *ff_vc1_subblkpat_vlc[3];
#define VC1_INTFR_4MV_MBMODE_VLC_BITS 9
-extern VLC ff_vc1_intfr_4mv_mbmode_vlc[4];
+extern const VLCElem *ff_vc1_intfr_4mv_mbmode_vlc[4];
#define VC1_INTFR_NON4MV_MBMODE_VLC_BITS 6
-extern VLC ff_vc1_intfr_non4mv_mbmode_vlc[4];
+extern const VLCElem *ff_vc1_intfr_non4mv_mbmode_vlc[4];
#define VC1_IF_MMV_MBMODE_VLC_BITS 5
-extern VLC ff_vc1_if_mmv_mbmode_vlc[8];
+extern const VLCElem *ff_vc1_if_mmv_mbmode_vlc[8];
#define VC1_IF_1MV_MBMODE_VLC_BITS 5
-extern VLC ff_vc1_if_1mv_mbmode_vlc[8];
+extern const VLCElem *ff_vc1_if_1mv_mbmode_vlc[8];
#define VC1_1REF_MVDATA_VLC_BITS 9
-extern VLC ff_vc1_1ref_mvdata_vlc[4];
+extern const VLCElem *ff_vc1_1ref_mvdata_vlc[4];
#define VC1_2REF_MVDATA_VLC_BITS 9
-extern VLC ff_vc1_2ref_mvdata_vlc[8];
+extern const VLCElem *ff_vc1_2ref_mvdata_vlc[8];
-extern VLC ff_vc1_ac_coeff_table[8];
+extern const VLCElem *ff_vc1_ac_coeff_table[8];
#define VC1_IF_MBMODE_VLC_BITS 5 // as a placeholder for VC1_IF_MMV_MBMODE_VLC_BITS
// or VC1_IF_1MV_MBMODE_VLC_BITS since they are the same
diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c
index 534128d6ee..871944d781 100644
--- a/libavcodec/vc1dec.c
+++ b/libavcodec/vc1dec.c
@@ -469,122 +469,92 @@ av_cold void ff_vc1_init_transposed_scantables(VC1Context *v)
v->top_blk_sh = 3;
}
-static const uint16_t vlc_offs[] = {
- 0, 520, 552, 616, 1128, 1160, 1224, 1740, 1772, 1836, 1900, 2436,
- 2986, 3050, 3610, 4154, 4218, 4746, 5326, 5390, 5902, 6554, 7658, 8342,
- 9304, 9988, 10630, 11234, 12174, 13006, 13560, 14232, 14786, 15432, 16350, 17522,
- 20372, 21818, 22330, 22394, 23166, 23678, 23742, 24820, 25332, 25396, 26460, 26980,
- 27048, 27592, 27600, 27608, 27616, 27624, 28224, 28258, 28290, 28802, 28834, 28866,
- 29378, 29412, 29444, 29960, 29994, 30026, 30538, 30572, 30604, 31120, 31154, 31186,
- 31714, 31746, 31778, 32306, 32340, 32372
-};
-
static av_cold void vc1_init_static(void)
{
static VLCElem vlc_table[32372];
-
- VLC_INIT_STATIC(&ff_vc1_norm2_vlc, VC1_NORM2_VLC_BITS, 4,
- vc1_norm2_bits, 1, 1,
- vc1_norm2_codes, 1, 1, 1 << VC1_NORM2_VLC_BITS);
- VLC_INIT_STATIC(&ff_vc1_norm6_vlc, VC1_NORM6_VLC_BITS, 64,
- vc1_norm6_bits, 1, 1,
- vc1_norm6_codes, 2, 2, 556);
- VLC_INIT_STATIC(&ff_vc1_imode_vlc, VC1_IMODE_VLC_BITS, 7,
- vc1_imode_bits, 1, 1,
- vc1_imode_codes, 1, 1, 1 << VC1_IMODE_VLC_BITS);
+ VLCInitState state = VLC_INIT_STATE(vlc_table);
+
+ VLC_INIT_STATIC_TABLE(ff_vc1_norm2_vlc, VC1_NORM2_VLC_BITS, 4,
+ vc1_norm2_bits, 1, 1,
+ vc1_norm2_codes, 1, 1, 0);
+ VLC_INIT_STATIC_TABLE(ff_vc1_norm6_vlc, VC1_NORM6_VLC_BITS, 64,
+ vc1_norm6_bits, 1, 1,
+ vc1_norm6_codes, 2, 2, 0);
+ VLC_INIT_STATIC_TABLE(ff_vc1_imode_vlc, VC1_IMODE_VLC_BITS, 7,
+ vc1_imode_bits, 1, 1,
+ vc1_imode_codes, 1, 1, 0);
for (int i = 0; i < 3; i++) {
- ff_vc1_ttmb_vlc[i].table = &vlc_table[vlc_offs[i * 3 + 0]];
- ff_vc1_ttmb_vlc[i].table_allocated = vlc_offs[i * 3 + 1] - vlc_offs[i * 3 + 0];
- vlc_init(&ff_vc1_ttmb_vlc[i], VC1_TTMB_VLC_BITS, 16,
- vc1_ttmb_bits[i], 1, 1,
- vc1_ttmb_codes[i], 2, 2, VLC_INIT_USE_STATIC);
- ff_vc1_ttblk_vlc[i].table = &vlc_table[vlc_offs[i * 3 + 1]];
- ff_vc1_ttblk_vlc[i].table_allocated = vlc_offs[i * 3 + 2] - vlc_offs[i * 3 + 1];
- vlc_init(&ff_vc1_ttblk_vlc[i], VC1_TTBLK_VLC_BITS, 8,
- vc1_ttblk_bits[i], 1, 1,
- vc1_ttblk_codes[i], 1, 1, VLC_INIT_USE_STATIC);
- ff_vc1_subblkpat_vlc[i].table = &vlc_table[vlc_offs[i * 3 + 2]];
- ff_vc1_subblkpat_vlc[i].table_allocated = vlc_offs[i * 3 + 3] - vlc_offs[i * 3 + 2];
- vlc_init(&ff_vc1_subblkpat_vlc[i], VC1_SUBBLKPAT_VLC_BITS, 15,
- vc1_subblkpat_bits[i], 1, 1,
- vc1_subblkpat_codes[i], 1, 1, VLC_INIT_USE_STATIC);
- }
- for (int i = 0; i < 4; i++) {
- ff_vc1_4mv_block_pattern_vlc[i].table = &vlc_table[vlc_offs[i * 3 + 9]];
- ff_vc1_4mv_block_pattern_vlc[i].table_allocated = vlc_offs[i * 3 + 10] - vlc_offs[i * 3 + 9];
- vlc_init(&ff_vc1_4mv_block_pattern_vlc[i], VC1_4MV_BLOCK_PATTERN_VLC_BITS, 16,
- vc1_4mv_block_pattern_bits[i], 1, 1,
- vc1_4mv_block_pattern_codes[i], 1, 1, VLC_INIT_USE_STATIC);
- ff_vc1_cbpcy_p_vlc[i].table = &vlc_table[vlc_offs[i * 3 + 10]];
- ff_vc1_cbpcy_p_vlc[i].table_allocated = vlc_offs[i * 3 + 11] - vlc_offs[i * 3 + 10];
- vlc_init(&ff_vc1_cbpcy_p_vlc[i], VC1_CBPCY_P_VLC_BITS, 64,
- vc1_cbpcy_p_bits[i], 1, 1,
- vc1_cbpcy_p_codes[i], 2, 2, VLC_INIT_USE_STATIC);
- ff_vc1_mv_diff_vlc[i].table = &vlc_table[vlc_offs[i * 3 + 11]];
- ff_vc1_mv_diff_vlc[i].table_allocated = vlc_offs[i * 3 + 12] - vlc_offs[i * 3 + 11];
- vlc_init(&ff_vc1_mv_diff_vlc[i], VC1_MV_DIFF_VLC_BITS, 73,
- vc1_mv_diff_bits[i], 1, 1,
- vc1_mv_diff_codes[i], 2, 2, VLC_INIT_USE_STATIC);
- }
- for (int i = 0; i < 8; i++) {
- ff_vc1_ac_coeff_table[i].table = &vlc_table[vlc_offs[i * 2 + 21]];
- ff_vc1_ac_coeff_table[i].table_allocated = vlc_offs[i * 2 + 22] - vlc_offs[i * 2 + 21];
- vlc_init(&ff_vc1_ac_coeff_table[i], AC_VLC_BITS, ff_vc1_ac_sizes[i],
- &vc1_ac_tables[i][0][1], 8, 4,
- &vc1_ac_tables[i][0][0], 8, 4, VLC_INIT_USE_STATIC);
- /* initialize interlaced MVDATA tables (2-Ref) */
- ff_vc1_2ref_mvdata_vlc[i].table = &vlc_table[vlc_offs[i * 2 + 22]];
- ff_vc1_2ref_mvdata_vlc[i].table_allocated = vlc_offs[i * 2 + 23] - vlc_offs[i * 2 + 22];
- vlc_init(&ff_vc1_2ref_mvdata_vlc[i], VC1_2REF_MVDATA_VLC_BITS, 126,
- vc1_2ref_mvdata_bits[i], 1, 1,
- vc1_2ref_mvdata_codes[i], 4, 4, VLC_INIT_USE_STATIC);
+ ff_vc1_ttmb_vlc[i] =
+ ff_vlc_init_tables(&state, VC1_TTMB_VLC_BITS, 16,
+ vc1_ttmb_bits[i], 1, 1,
+ vc1_ttmb_codes[i], 2, 2, 0);
+ ff_vc1_ttblk_vlc[i] =
+ ff_vlc_init_tables(&state, VC1_TTBLK_VLC_BITS, 8,
+ vc1_ttblk_bits[i], 1, 1,
+ vc1_ttblk_codes[i], 1, 1, 0);
+ ff_vc1_subblkpat_vlc[i] =
+ ff_vlc_init_tables(&state, VC1_SUBBLKPAT_VLC_BITS, 15,
+ vc1_subblkpat_bits[i], 1, 1,
+ vc1_subblkpat_codes[i], 1, 1, 0);
}
for (int i = 0; i < 4; i++) {
+ ff_vc1_4mv_block_pattern_vlc[i] =
+ ff_vlc_init_tables(&state, VC1_4MV_BLOCK_PATTERN_VLC_BITS, 16,
+ vc1_4mv_block_pattern_bits[i], 1, 1,
+ vc1_4mv_block_pattern_codes[i], 1, 1, 0);
+ ff_vc1_cbpcy_p_vlc[i] =
+ ff_vlc_init_tables(&state, VC1_CBPCY_P_VLC_BITS, 64,
+ vc1_cbpcy_p_bits[i], 1, 1,
+ vc1_cbpcy_p_codes[i], 2, 2, 0);
+ ff_vc1_mv_diff_vlc[i] =
+ ff_vlc_init_tables(&state, VC1_MV_DIFF_VLC_BITS, 73,
+ vc1_mv_diff_bits[i], 1, 1,
+ vc1_mv_diff_codes[i], 2, 2, 0);
/* initialize 4MV MBMODE VLC tables for interlaced frame P picture */
- ff_vc1_intfr_4mv_mbmode_vlc[i].table = &vlc_table[vlc_offs[i * 3 + 37]];
- ff_vc1_intfr_4mv_mbmode_vlc[i].table_allocated = vlc_offs[i * 3 + 38] - vlc_offs[i * 3 + 37];
- vlc_init(&ff_vc1_intfr_4mv_mbmode_vlc[i], VC1_INTFR_4MV_MBMODE_VLC_BITS, 15,
- vc1_intfr_4mv_mbmode_bits[i], 1, 1,
- vc1_intfr_4mv_mbmode_codes[i], 2, 2, VLC_INIT_USE_STATIC);
+ ff_vc1_intfr_4mv_mbmode_vlc[i] =
+ ff_vlc_init_tables(&state, VC1_INTFR_4MV_MBMODE_VLC_BITS, 15,
+ vc1_intfr_4mv_mbmode_bits[i], 1, 1,
+ vc1_intfr_4mv_mbmode_codes[i], 2, 2, 0);
/* initialize NON-4MV MBMODE VLC tables for the same */
- ff_vc1_intfr_non4mv_mbmode_vlc[i].table = &vlc_table[vlc_offs[i * 3 + 38]];
- ff_vc1_intfr_non4mv_mbmode_vlc[i].table_allocated = vlc_offs[i * 3 + 39] - vlc_offs[i * 3 + 38];
- vlc_init(&ff_vc1_intfr_non4mv_mbmode_vlc[i], VC1_INTFR_NON4MV_MBMODE_VLC_BITS, 9,
- vc1_intfr_non4mv_mbmode_bits[i], 1, 1,
- vc1_intfr_non4mv_mbmode_codes[i], 1, 1, VLC_INIT_USE_STATIC);
+ ff_vc1_intfr_non4mv_mbmode_vlc[i] =
+ ff_vlc_init_tables(&state, VC1_INTFR_NON4MV_MBMODE_VLC_BITS, 9,
+ vc1_intfr_non4mv_mbmode_bits[i], 1, 1,
+ vc1_intfr_non4mv_mbmode_codes[i], 1, 1, 0);
/* initialize interlaced MVDATA tables (1-Ref) */
- ff_vc1_1ref_mvdata_vlc[i].table = &vlc_table[vlc_offs[i * 3 + 39]];
- ff_vc1_1ref_mvdata_vlc[i].table_allocated = vlc_offs[i * 3 + 40] - vlc_offs[i * 3 + 39];
- vlc_init(&ff_vc1_1ref_mvdata_vlc[i], VC1_1REF_MVDATA_VLC_BITS, 72,
- vc1_1ref_mvdata_bits[i], 1, 1,
- vc1_1ref_mvdata_codes[i], 4, 4, VLC_INIT_USE_STATIC);
- }
- for (int i = 0; i < 4; i++) {
+ ff_vc1_1ref_mvdata_vlc[i] =
+ ff_vlc_init_tables(&state, VC1_1REF_MVDATA_VLC_BITS, 72,
+ vc1_1ref_mvdata_bits[i], 1, 1,
+ vc1_1ref_mvdata_codes[i], 4, 4, 0);
/* Initialize 2MV Block pattern VLC tables */
- ff_vc1_2mv_block_pattern_vlc[i].table = &vlc_table[vlc_offs[i + 49]];
- ff_vc1_2mv_block_pattern_vlc[i].table_allocated = vlc_offs[i + 50] - vlc_offs[i + 49];
- vlc_init(&ff_vc1_2mv_block_pattern_vlc[i], VC1_2MV_BLOCK_PATTERN_VLC_BITS, 4,
- vc1_2mv_block_pattern_bits[i], 1, 1,
- vc1_2mv_block_pattern_codes[i], 1, 1, VLC_INIT_USE_STATIC);
+ ff_vc1_2mv_block_pattern_vlc[i] =
+ ff_vlc_init_tables(&state, VC1_2MV_BLOCK_PATTERN_VLC_BITS, 4,
+ vc1_2mv_block_pattern_bits[i], 1, 1,
+ vc1_2mv_block_pattern_codes[i], 1, 1, 0);
}
for (int i = 0; i < 8; i++) {
+ ff_vc1_ac_coeff_table[i] =
+ ff_vlc_init_tables(&state, AC_VLC_BITS, ff_vc1_ac_sizes[i],
+ &vc1_ac_tables[i][0][1], 8, 4,
+ &vc1_ac_tables[i][0][0], 8, 4, 0);
+ /* initialize interlaced MVDATA tables (2-Ref) */
+ ff_vc1_2ref_mvdata_vlc[i] =
+ ff_vlc_init_tables(&state, VC1_2REF_MVDATA_VLC_BITS, 126,
+ vc1_2ref_mvdata_bits[i], 1, 1,
+ vc1_2ref_mvdata_codes[i], 4, 4, 0);
/* Initialize interlaced CBPCY VLC tables (Table 124 - Table 131) */
- ff_vc1_icbpcy_vlc[i].table = &vlc_table[vlc_offs[i * 3 + 53]];
- ff_vc1_icbpcy_vlc[i].table_allocated = vlc_offs[i * 3 + 54] - vlc_offs[i * 3 + 53];
- vlc_init(&ff_vc1_icbpcy_vlc[i], VC1_ICBPCY_VLC_BITS, 63,
- vc1_icbpcy_p_bits[i], 1, 1,
- vc1_icbpcy_p_codes[i], 2, 2, VLC_INIT_USE_STATIC);
+ ff_vc1_icbpcy_vlc[i] =
+ ff_vlc_init_tables(&state, VC1_ICBPCY_VLC_BITS, 63,
+ vc1_icbpcy_p_bits[i], 1, 1,
+ vc1_icbpcy_p_codes[i], 2, 2, 0);
/* Initialize interlaced field picture MBMODE VLC tables */
- ff_vc1_if_mmv_mbmode_vlc[i].table = &vlc_table[vlc_offs[i * 3 + 54]];
- ff_vc1_if_mmv_mbmode_vlc[i].table_allocated = vlc_offs[i * 3 + 55] - vlc_offs[i * 3 + 54];
- vlc_init(&ff_vc1_if_mmv_mbmode_vlc[i], VC1_IF_MMV_MBMODE_VLC_BITS, 8,
- vc1_if_mmv_mbmode_bits[i], 1, 1,
- vc1_if_mmv_mbmode_codes[i], 1, 1, VLC_INIT_USE_STATIC);
- ff_vc1_if_1mv_mbmode_vlc[i].table = &vlc_table[vlc_offs[i * 3 + 55]];
- ff_vc1_if_1mv_mbmode_vlc[i].table_allocated = vlc_offs[i * 3 + 56] - vlc_offs[i * 3 + 55];
- vlc_init(&ff_vc1_if_1mv_mbmode_vlc[i], VC1_IF_1MV_MBMODE_VLC_BITS, 6,
- vc1_if_1mv_mbmode_bits[i], 1, 1,
- vc1_if_1mv_mbmode_codes[i], 1, 1, VLC_INIT_USE_STATIC);
+ ff_vc1_if_mmv_mbmode_vlc[i] =
+ ff_vlc_init_tables(&state, VC1_IF_MMV_MBMODE_VLC_BITS, 8,
+ vc1_if_mmv_mbmode_bits[i], 1, 1,
+ vc1_if_mmv_mbmode_codes[i], 1, 1, 0);
+ ff_vc1_if_1mv_mbmode_vlc[i] =
+ ff_vlc_init_tables(&state, VC1_IF_1MV_MBMODE_VLC_BITS, 6,
+ vc1_if_1mv_mbmode_bits[i], 1, 1,
+ vc1_if_1mv_mbmode_codes[i], 1, 1, 0);
}
ff_msmp4_vc1_vlcs_init_once();
}
More information about the ffmpeg-cvslog
mailing list