avcodec/msmpeg4dec: Factor initializing VLCs shared with VC-1 out

It will be useful in the following commits.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
Andreas Rheinhardt 2022-10-30 13:24:10 +01:00
parent 8f7bf45895
commit 83dfc21a21
3 changed files with 33 additions and 17 deletions

View File

@ -30,6 +30,10 @@
#include "h263data.h"
#include "mpeg4videodata.h"
#include "msmpeg4data.h"
#include "rl.h"
#include "vlc.h"
#include "libavutil/attributes.h"
#include "libavutil/thread.h"
uint32_t ff_v2_dc_lum_table[512][2];
uint32_t ff_v2_dc_chroma_table[512][2];
@ -38,6 +42,32 @@ VLC ff_msmp4_mb_i_vlc;
VLC ff_msmp4_dc_luma_vlc[2];
VLC ff_msmp4_dc_chroma_vlc[2];
static av_cold void msmp4_vc1_vlcs_init(void)
{
INIT_VLC_STATIC(&ff_msmp4_dc_luma_vlc[0], MSMP4_DC_VLC_BITS, 120,
&ff_table0_dc_lum[0][1], 8, 4,
&ff_table0_dc_lum[0][0], 8, 4, 1158);
INIT_VLC_STATIC(&ff_msmp4_dc_chroma_vlc[0], MSMP4_DC_VLC_BITS, 120,
&ff_table0_dc_chroma[0][1], 8, 4,
&ff_table0_dc_chroma[0][0], 8, 4, 1118);
INIT_VLC_STATIC(&ff_msmp4_dc_luma_vlc[1], MSMP4_DC_VLC_BITS, 120,
&ff_table1_dc_lum[0][1], 8, 4,
&ff_table1_dc_lum[0][0], 8, 4, 1476);
INIT_VLC_STATIC(&ff_msmp4_dc_chroma_vlc[1], MSMP4_DC_VLC_BITS, 120,
&ff_table1_dc_chroma[0][1], 8, 4,
&ff_table1_dc_chroma[0][0], 8, 4, 1216);
INIT_VLC_STATIC(&ff_msmp4_mb_i_vlc, MSMP4_MB_INTRA_VLC_BITS, 64,
&ff_msmp4_mb_i_table[0][1], 4, 2,
&ff_msmp4_mb_i_table[0][0], 4, 2, 536);
}
av_cold void ff_msmp4_vc1_vlcs_init_once(void)
{
static AVOnce init_static_once = AV_ONCE_INIT;
ff_thread_once(&init_static_once, msmp4_vc1_vlcs_init);
}
/* intra picture macroblock coded block pattern */
const uint16_t ff_msmp4_mb_i_table[64][2] = {
{ 0x1, 1 }, { 0x17, 6 }, { 0x9, 5 }, { 0x5, 5 },

View File

@ -48,6 +48,8 @@ typedef struct MVTable {
} MVTable;
FF_VISIBILITY_PUSH_HIDDEN
void ff_msmp4_vc1_vlcs_init_once(void);
#define MSMP4_MB_INTRA_VLC_BITS 9
extern VLC ff_msmp4_mb_i_vlc;
#define MSMP4_DC_VLC_BITS 9

View File

@ -316,19 +316,6 @@ static av_cold void msmpeg4_decode_init_static(void)
mv->table_mv_bits, 1, 1,
mv->table_mv_code, 2, 2, 2694);
INIT_VLC_STATIC(&ff_msmp4_dc_luma_vlc[0], MSMP4_DC_VLC_BITS, 120,
&ff_table0_dc_lum[0][1], 8, 4,
&ff_table0_dc_lum[0][0], 8, 4, 1158);
INIT_VLC_STATIC(&ff_msmp4_dc_chroma_vlc[0], MSMP4_DC_VLC_BITS, 120,
&ff_table0_dc_chroma[0][1], 8, 4,
&ff_table0_dc_chroma[0][0], 8, 4, 1118);
INIT_VLC_STATIC(&ff_msmp4_dc_luma_vlc[1], MSMP4_DC_VLC_BITS, 120,
&ff_table1_dc_lum[0][1], 8, 4,
&ff_table1_dc_lum[0][0], 8, 4, 1476);
INIT_VLC_STATIC(&ff_msmp4_dc_chroma_vlc[1], MSMP4_DC_VLC_BITS, 120,
&ff_table1_dc_chroma[0][1], 8, 4,
&ff_table1_dc_chroma[0][0], 8, 4, 1216);
INIT_VLC_STATIC(&v2_dc_lum_vlc, MSMP4_DC_VLC_BITS, 512,
&ff_v2_dc_lum_table[0][1], 8, 4,
&ff_v2_dc_lum_table[0][0], 8, 4, 1472);
@ -354,13 +341,10 @@ static av_cold void msmpeg4_decode_init_static(void)
offset += ff_mb_non_intra_vlc[i].table_size;
}
INIT_VLC_STATIC(&ff_msmp4_mb_i_vlc, MSMP4_MB_INTRA_VLC_BITS, 64,
&ff_msmp4_mb_i_table[0][1], 4, 2,
&ff_msmp4_mb_i_table[0][0], 4, 2, 536);
INIT_VLC_STATIC(&ff_inter_intra_vlc, INTER_INTRA_VLC_BITS, 4,
&ff_table_inter_intra[0][1], 2, 1,
&ff_table_inter_intra[0][0], 2, 1, 8);
ff_msmp4_vc1_vlcs_init_once();
}
av_cold int ff_msmpeg4_decode_init(AVCodecContext *avctx)