diff options
author | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2024-06-03 05:07:44 +0200 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2024-06-20 18:58:38 +0200 |
commit | 010951239c6de2d32d6572d1390cdaf8f6c63452 (patch) | |
tree | da35b8220ee940039c13f488af0b7960c3bb6f32 /libavcodec/mpeg12.c | |
parent | e7d6300c10834b782a2e2b274d4a9f1fc4cf8efe (diff) | |
download | ffmpeg-010951239c6de2d32d6572d1390cdaf8f6c63452.tar.gz |
avcodec/mpeg12dec: Use VLC symbol table
Possible by using MB_TYPE_CODEC_SPECIFIC for MB_TYPE_ZERO_MV
and due to the MB_TYPE_*_MV flags fitting into an int16_t.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavcodec/mpeg12.c')
-rw-r--r-- | libavcodec/mpeg12.c | 42 |
1 files changed, 33 insertions, 9 deletions
diff --git a/libavcodec/mpeg12.c b/libavcodec/mpeg12.c index 62d7fd1814..444ea83f3c 100644 --- a/libavcodec/mpeg12.c +++ b/libavcodec/mpeg12.c @@ -31,14 +31,12 @@ #include "libavutil/avassert.h" #include "libavutil/thread.h" -#include "avcodec.h" #include "mpegvideo.h" -#include "mpeg12.h" #include "mpeg12codecs.h" #include "mpeg12data.h" #include "mpeg12dec.h" +#include "mpegutils.h" #include "rl.h" -#include "startcode.h" static const uint8_t table_mb_ptype[7][2] = { { 3, 5 }, // 0x01 MB_INTRA @@ -64,6 +62,30 @@ static const uint8_t table_mb_btype[11][2] = { { 2, 5 }, // 0x1E MB_QUANT|MB_FOR|MB_BACK|MB_PAT }; +static const int16_t ptype2mb_type[7] = { + MB_TYPE_INTRA, + MB_TYPE_FORWARD_MV | MB_TYPE_CBP | MB_TYPE_ZERO_MV | MB_TYPE_16x16, + MB_TYPE_FORWARD_MV, + MB_TYPE_FORWARD_MV | MB_TYPE_CBP, + MB_TYPE_QUANT | MB_TYPE_INTRA, + MB_TYPE_QUANT | MB_TYPE_FORWARD_MV | MB_TYPE_CBP | MB_TYPE_ZERO_MV | MB_TYPE_16x16, + MB_TYPE_QUANT | MB_TYPE_FORWARD_MV | MB_TYPE_CBP, +}; + +static const int16_t btype2mb_type[11] = { + MB_TYPE_INTRA, + MB_TYPE_BACKWARD_MV, + MB_TYPE_BACKWARD_MV | MB_TYPE_CBP, + MB_TYPE_FORWARD_MV, + MB_TYPE_FORWARD_MV | MB_TYPE_CBP, + MB_TYPE_BIDIR_MV, + MB_TYPE_BIDIR_MV | MB_TYPE_CBP, + MB_TYPE_QUANT | MB_TYPE_INTRA, + MB_TYPE_QUANT | MB_TYPE_BACKWARD_MV | MB_TYPE_CBP, + MB_TYPE_QUANT | MB_TYPE_FORWARD_MV | MB_TYPE_CBP, + MB_TYPE_QUANT | MB_TYPE_BIDIR_MV | MB_TYPE_CBP, +}; + av_cold void ff_init_2d_vlc_rl(const uint16_t table_vlc[][2], RL_VLC_ELEM rl_vlc[], const int8_t table_run[], const uint8_t table_level[], int n, unsigned static_size, int flags) @@ -146,12 +168,14 @@ static av_cold void mpeg12_init_vlcs(void) &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); + VLC_INIT_STATIC_SPARSE_TABLE(ff_mb_ptype_vlc, MB_PTYPE_VLC_BITS, 7, + &table_mb_ptype[0][1], 2, 1, + &table_mb_ptype[0][0], 2, 1, + ptype2mb_type, 2, 2, 0); + VLC_INIT_STATIC_SPARSE_TABLE(ff_mb_btype_vlc, MB_BTYPE_VLC_BITS, 11, + &table_mb_btype[0][1], 2, 1, + &table_mb_btype[0][0], 2, 1, + btype2mb_type, 2, 2, 0); ff_init_2d_vlc_rl(ff_mpeg1_vlc_table, ff_mpeg1_rl_vlc, ff_mpeg12_run, ff_mpeg12_level, MPEG12_RL_NB_ELEMS, |