diff mbox series

[FFmpeg-devel,14/19] avcodec/vc1dec: Don't open and close decoder during init

Message ID GV1P250MB0737240503CDA361DA1F00DC8F349@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM
State Accepted
Commit 5a157313b3860887947b6fe51d313aa4d397d3a0
Headers show
Series [FFmpeg-devel,01/19] avcodec/vc1: Don't check for AVCodecContext.codec | expand


Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Andreas Rheinhardt Oct. 30, 2022, 11:56 p.m. UTC
This is done since 16af29a7a6deff3f6081fca1e36ad96cf8fec77d
(and is actually unnecessary, because the tables initialized
in ff_msmpeg4_decode_init() are only ever used in vc1_block.c
which is only entered after a call to ff_msmpeg4_decode_init())
in a very ugly manner; said manner had the byproduct of
involving lots of unnecessary allocations and even opening
and closing a hwaccel in case one is used.

This commit achieves the aim of 16af29a7a6deff3f6081fca1e36ad96cf8fec77d
by initializing the VLCs used by VC-1 in ff_vc1_init_common().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
 libavcodec/vc1dec.c | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)
diff mbox series


diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c
index b74956c6a3..49ecfd8a48 100644
--- a/libavcodec/vc1dec.c
+++ b/libavcodec/vc1dec.c
@@ -540,6 +540,7 @@  static av_cold void vc1_init_static(void)
                  vc1_if_1mv_mbmode_bits[i],  1, 1,
                  vc1_if_1mv_mbmode_codes[i], 1, 1, INIT_VLC_USE_NEW_STATIC);
+    ff_msmp4_vc1_vlcs_init_once();
@@ -672,16 +673,6 @@  static av_cold int vc1_decode_init(AVCodecContext *avctx)
             avctx->color_range = AVCOL_RANGE_MPEG;
-    // ensure static VLC tables are initialized
-    if ((ret = ff_msmpeg4_decode_init(avctx)) < 0)
-        return ret;
-    if ((ret = ff_vc1_decode_init_alloc_tables(v)) < 0)
-        return ret;
-    // Hack to ensure the above functions will be called
-    // again once we know all necessary settings.
-    // That this is necessary might indicate a bug.
-    ff_vc1_decode_end(avctx);
     ff_h264chroma_init(&v->h264chroma, 8);