aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2023-09-26 19:51:45 +0200
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2023-10-31 21:44:48 +0100
commit7e2120c4d955a99d004a2ac9b690233027fae1fb (patch)
treea7f66dbc0ef73a72e69e86a333b5b19d63c08042 /libavcodec
parentc9aa80c313911b9ac44ab8099bdcc612796c6b90 (diff)
downloadffmpeg-7e2120c4d955a99d004a2ac9b690233027fae1fb.tar.gz
avcodec/mpeg12: Avoid unnecessary VLC structures
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>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/mpeg12.c58
-rw-r--r--libavcodec/mpeg12dec.c12
-rw-r--r--libavcodec/mpeg12dec.h4
-rw-r--r--libavcodec/mpeg12vlc.h14
4 files changed, 44 insertions, 44 deletions
diff --git a/libavcodec/mpeg12.c b/libavcodec/mpeg12.c
index 70033ec725..8d88820c46 100644
--- a/libavcodec/mpeg12.c
+++ b/libavcodec/mpeg12.c
@@ -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,
diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index 982c25c3fd..020b7b7564 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -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)
@@ -470,7 +470,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);
@@ -479,7 +479,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);
@@ -736,7 +736,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);
@@ -1422,7 +1422,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");
@@ -1591,7 +1591,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");
diff --git a/libavcodec/mpeg12dec.h b/libavcodec/mpeg12dec.h
index 4c015d3096..4641179149 100644
--- a/libavcodec/mpeg12dec.h
+++ b/libavcodec/mpeg12dec.h
@@ -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;
diff --git a/libavcodec/mpeg12vlc.h b/libavcodec/mpeg12vlc.h
index 3ed35968f6..53f53947c3 100644
--- a/libavcodec/mpeg12vlc.h
+++ b/libavcodec/mpeg12vlc.h
@@ -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);