[FFmpeg-cvslog] avcodec/msmpeg4dec: Factor initializing VLCs shared with VC-1 out
Andreas Rheinhardt
git at videolan.org
Sun Nov 6 18:50:51 EET 2022
ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Sun Oct 30 13:24:10 2022 +0100| [83dfc21a212cc0b03d1db17df072bfe7c4a3333a] | committer: Andreas Rheinhardt
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 at outlook.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=83dfc21a212cc0b03d1db17df072bfe7c4a3333a
---
libavcodec/msmpeg4data.c | 30 ++++++++++++++++++++++++++++++
libavcodec/msmpeg4data.h | 2 ++
libavcodec/msmpeg4dec.c | 18 +-----------------
3 files changed, 33 insertions(+), 17 deletions(-)
diff --git a/libavcodec/msmpeg4data.c b/libavcodec/msmpeg4data.c
index 63f30ac544..7b54eea221 100644
--- a/libavcodec/msmpeg4data.c
+++ b/libavcodec/msmpeg4data.c
@@ -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 },
diff --git a/libavcodec/msmpeg4data.h b/libavcodec/msmpeg4data.h
index 4f904d7610..ccbfde36f7 100644
--- a/libavcodec/msmpeg4data.h
+++ b/libavcodec/msmpeg4data.h
@@ -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
diff --git a/libavcodec/msmpeg4dec.c b/libavcodec/msmpeg4dec.c
index a7ba53f68e..2be8cf2bf6 100644
--- a/libavcodec/msmpeg4dec.c
+++ b/libavcodec/msmpeg4dec.c
@@ -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)
More information about the ffmpeg-cvslog
mailing list