@@ -115,43 +115,43 @@ void ff_mpeg1_clean_buffers(MpegEncContext *s)
/******************************************/
/* decoding */
-VLC ff_mv_vlc;
+VLCElem ff_mv_vlc[266];
-VLC ff_dc_lum_vlc;
-VLC ff_dc_chroma_vlc;
+VLCElem ff_dc_lum_vlc[512];
+VLCElem ff_dc_chroma_vlc[514];
-VLC ff_mbincr_vlc;
-VLC ff_mb_ptype_vlc;
-VLC ff_mb_btype_vlc;
-VLC ff_mb_pat_vlc;
+VLCElem ff_mbincr_vlc[538];
+VLCElem ff_mb_ptype_vlc[64];
+VLCElem ff_mb_btype_vlc[64];
+VLCElem ff_mb_pat_vlc[512];
RL_VLC_ELEM ff_mpeg1_rl_vlc[680];
RL_VLC_ELEM ff_mpeg2_rl_vlc[674];
static av_cold void mpeg12_init_vlcs(void)
{
- VLC_INIT_STATIC(&ff_dc_lum_vlc, DC_VLC_BITS, 12,
- ff_mpeg12_vlc_dc_lum_bits, 1, 1,
- ff_mpeg12_vlc_dc_lum_code, 2, 2, 512);
- VLC_INIT_STATIC(&ff_dc_chroma_vlc, DC_VLC_BITS, 12,
- ff_mpeg12_vlc_dc_chroma_bits, 1, 1,
- ff_mpeg12_vlc_dc_chroma_code, 2, 2, 514);
- VLC_INIT_STATIC(&ff_mv_vlc, MV_VLC_BITS, 17,
- &ff_mpeg12_mbMotionVectorTable[0][1], 2, 1,
- &ff_mpeg12_mbMotionVectorTable[0][0], 2, 1, 266);
- VLC_INIT_STATIC(&ff_mbincr_vlc, MBINCR_VLC_BITS, 36,
- &ff_mpeg12_mbAddrIncrTable[0][1], 2, 1,
- &ff_mpeg12_mbAddrIncrTable[0][0], 2, 1, 538);
- VLC_INIT_STATIC(&ff_mb_pat_vlc, MB_PAT_VLC_BITS, 64,
- &ff_mpeg12_mbPatTable[0][1], 2, 1,
- &ff_mpeg12_mbPatTable[0][0], 2, 1, 512);
-
- VLC_INIT_STATIC(&ff_mb_ptype_vlc, MB_PTYPE_VLC_BITS, 7,
- &table_mb_ptype[0][1], 2, 1,
- &table_mb_ptype[0][0], 2, 1, 64);
- VLC_INIT_STATIC(&ff_mb_btype_vlc, MB_BTYPE_VLC_BITS, 11,
- &table_mb_btype[0][1], 2, 1,
- &table_mb_btype[0][0], 2, 1, 64);
+ VLC_INIT_STATIC_TABLE(ff_dc_lum_vlc, DC_VLC_BITS, 12,
+ ff_mpeg12_vlc_dc_lum_bits, 1, 1,
+ ff_mpeg12_vlc_dc_lum_code, 2, 2, 0);
+ VLC_INIT_STATIC_TABLE(ff_dc_chroma_vlc, DC_VLC_BITS, 12,
+ ff_mpeg12_vlc_dc_chroma_bits, 1, 1,
+ ff_mpeg12_vlc_dc_chroma_code, 2, 2, 0);
+ VLC_INIT_STATIC_TABLE(ff_mv_vlc, MV_VLC_BITS, 17,
+ &ff_mpeg12_mbMotionVectorTable[0][1], 2, 1,
+ &ff_mpeg12_mbMotionVectorTable[0][0], 2, 1, 0);
+ VLC_INIT_STATIC_TABLE(ff_mbincr_vlc, MBINCR_VLC_BITS, 36,
+ &ff_mpeg12_mbAddrIncrTable[0][1], 2, 1,
+ &ff_mpeg12_mbAddrIncrTable[0][0], 2, 1, 0);
+ VLC_INIT_STATIC_TABLE(ff_mb_pat_vlc, MB_PAT_VLC_BITS, 64,
+ &ff_mpeg12_mbPatTable[0][1], 2, 1,
+ &ff_mpeg12_mbPatTable[0][0], 2, 1, 0);
+
+ VLC_INIT_STATIC_TABLE(ff_mb_ptype_vlc, MB_PTYPE_VLC_BITS, 7,
+ &table_mb_ptype[0][1], 2, 1,
+ &table_mb_ptype[0][0], 2, 1, 0);
+ VLC_INIT_STATIC_TABLE(ff_mb_btype_vlc, MB_BTYPE_VLC_BITS, 11,
+ &table_mb_btype[0][1], 2, 1,
+ &table_mb_btype[0][0], 2, 1, 0);
ff_init_2d_vlc_rl(ff_mpeg1_vlc_table, ff_mpeg1_rl_vlc, ff_mpeg12_run,
ff_mpeg12_level, MPEG12_RL_NB_ELEMS,
@@ -117,7 +117,7 @@ static int mpeg_decode_motion(MpegEncContext *s, int fcode, int pred)
{
int code, sign, val, shift;
- code = get_vlc2(&s->gb, ff_mv_vlc.table, MV_VLC_BITS, 2);
+ code = get_vlc2(&s->gb, ff_mv_vlc, MV_VLC_BITS, 2);
if (code == 0)
return pred;
if (code < 0)
@@ -710,7 +710,7 @@ static int mpeg_decode_mb(MpegEncContext *s, int16_t block[12][64])
}
break;
case AV_PICTURE_TYPE_P:
- mb_type = get_vlc2(&s->gb, ff_mb_ptype_vlc.table, MB_PTYPE_VLC_BITS, 1);
+ mb_type = get_vlc2(&s->gb, ff_mb_ptype_vlc, MB_PTYPE_VLC_BITS, 1);
if (mb_type < 0) {
av_log(s->avctx, AV_LOG_ERROR,
"Invalid mb type in P-frame at %d %d\n", s->mb_x, s->mb_y);
@@ -719,7 +719,7 @@ static int mpeg_decode_mb(MpegEncContext *s, int16_t block[12][64])
mb_type = ptype2mb_type[mb_type];
break;
case AV_PICTURE_TYPE_B:
- mb_type = get_vlc2(&s->gb, ff_mb_btype_vlc.table, MB_BTYPE_VLC_BITS, 1);
+ mb_type = get_vlc2(&s->gb, ff_mb_btype_vlc, MB_BTYPE_VLC_BITS, 1);
if (mb_type < 0) {
av_log(s->avctx, AV_LOG_ERROR,
"Invalid mb type in B-frame at %d %d\n", s->mb_x, s->mb_y);
@@ -981,7 +981,7 @@ static int mpeg_decode_mb(MpegEncContext *s, int16_t block[12][64])
if (HAS_CBP(mb_type)) {
s->bdsp.clear_blocks(s->block[0]);
- cbp = get_vlc2(&s->gb, ff_mb_pat_vlc.table, MB_PAT_VLC_BITS, 1);
+ cbp = get_vlc2(&s->gb, ff_mb_pat_vlc, MB_PAT_VLC_BITS, 1);
if (mb_block_count > 6) {
cbp *= 1 << mb_block_count - 6;
cbp |= get_bits(&s->gb, mb_block_count - 6);
@@ -1723,7 +1723,7 @@ static int mpeg_decode_slice(MpegEncContext *s, int mb_y,
skip_bits1(&s->gb);
} else {
while (get_bits_left(&s->gb) > 0) {
- int code = get_vlc2(&s->gb, ff_mbincr_vlc.table,
+ int code = get_vlc2(&s->gb, ff_mbincr_vlc,
MBINCR_VLC_BITS, 2);
if (code < 0) {
av_log(s->avctx, AV_LOG_ERROR, "first mb_incr damaged\n");
@@ -1892,7 +1892,7 @@ static int mpeg_decode_slice(MpegEncContext *s, int mb_y,
/* read increment again */
s->mb_skip_run = 0;
for (;;) {
- int code = get_vlc2(&s->gb, ff_mbincr_vlc.table,
+ int code = get_vlc2(&s->gb, ff_mbincr_vlc,
MBINCR_VLC_BITS, 2);
if (code < 0) {
av_log(s->avctx, AV_LOG_ERROR, "mb incr damaged\n");
@@ -30,9 +30,9 @@ static inline int decode_dc(GetBitContext *gb, int component)
int code, diff;
if (component == 0) {
- code = get_vlc2(gb, ff_dc_lum_vlc.table, DC_VLC_BITS, 2);
+ code = get_vlc2(gb, ff_dc_lum_vlc, DC_VLC_BITS, 2);
} else {
- code = get_vlc2(gb, ff_dc_chroma_vlc.table, DC_VLC_BITS, 2);
+ code = get_vlc2(gb, ff_dc_chroma_vlc, DC_VLC_BITS, 2);
}
if (code == 0) {
diff = 0;
@@ -39,13 +39,13 @@
#define MB_PTYPE_VLC_BITS 6
#define MB_BTYPE_VLC_BITS 6
-extern VLC ff_dc_lum_vlc;
-extern VLC ff_dc_chroma_vlc;
-extern VLC ff_mbincr_vlc;
-extern VLC ff_mb_ptype_vlc;
-extern VLC ff_mb_btype_vlc;
-extern VLC ff_mb_pat_vlc;
-extern VLC ff_mv_vlc;
+extern VLCElem ff_dc_lum_vlc[];
+extern VLCElem ff_dc_chroma_vlc[];
+extern VLCElem ff_mbincr_vlc[];
+extern VLCElem ff_mb_ptype_vlc[];
+extern VLCElem ff_mb_btype_vlc[];
+extern VLCElem ff_mb_pat_vlc[];
+extern VLCElem ff_mv_vlc[];
void ff_mpeg12_init_vlcs(void);
Everything besides VLC.table is basically write-only and even VLC.table can be removed by accessing the underlying tables directly. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> --- libavcodec/mpeg12.c | 58 +++++++++++++++++++++--------------------- libavcodec/mpeg12dec.c | 12 ++++----- libavcodec/mpeg12dec.h | 4 +-- libavcodec/mpeg12vlc.h | 14 +++++----- 4 files changed, 44 insertions(+), 44 deletions(-)