diff mbox series

[FFmpeg-devel,3/3] avcodec/mlpdec: Avoid code duplication when initializing VLCs

Message ID 20201121121728.1018014-3-andreas.rheinhardt@gmail.com
State Accepted
Commit 08a992e018fd1c28daac1ec21cfd133ca3d7a140
Headers show
Series [FFmpeg-devel,1/3] avcodec/mlp: Make initializing CRCs thread-safe
Related show

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Andreas Rheinhardt Nov. 21, 2020, 12:17 p.m. UTC
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavcodec/mlpdec.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/mlpdec.c b/libavcodec/mlpdec.c
index ec346868c6..ed25b71d2d 100644
--- a/libavcodec/mlpdec.c
+++ b/libavcodec/mlpdec.c
@@ -206,15 +206,14 @@  static VLC huff_vlc[3];
 
 static av_cold void init_static(void)
 {
-        INIT_VLC_STATIC(&huff_vlc[0], VLC_BITS, 18,
-                    &ff_mlp_huffman_tables[0][0][1], 2, 1,
-                    &ff_mlp_huffman_tables[0][0][0], 2, 1, VLC_STATIC_SIZE);
-        INIT_VLC_STATIC(&huff_vlc[1], VLC_BITS, 16,
-                    &ff_mlp_huffman_tables[1][0][1], 2, 1,
-                    &ff_mlp_huffman_tables[1][0][0], 2, 1, VLC_STATIC_SIZE);
-        INIT_VLC_STATIC(&huff_vlc[2], VLC_BITS, 15,
-                    &ff_mlp_huffman_tables[2][0][1], 2, 1,
-                    &ff_mlp_huffman_tables[2][0][0], 2, 1, VLC_STATIC_SIZE);
+    for (int i = 0; i < 3; i++) {
+        static VLC_TYPE vlc_buf[3 * VLC_STATIC_SIZE][2];
+        huff_vlc[i].table           = &vlc_buf[i * VLC_STATIC_SIZE];
+        huff_vlc[i].table_allocated = VLC_STATIC_SIZE;
+        init_vlc(&huff_vlc[i], VLC_BITS, 18,
+                 &ff_mlp_huffman_tables[i][0][1], 2, 1,
+                 &ff_mlp_huffman_tables[i][0][0], 2, 1, INIT_VLC_USE_NEW_STATIC);
+    }
 
     ff_mlp_init_crc();
 }