diff mbox series

[FFmpeg-devel,26/30] avcodec/dv: Don't pretend VLC allocation can't fail

Message ID 20201230233157.1055287-26-andreas.rheinhardt@gmail.com
State New
Headers show
Series [FFmpeg-devel,01/30] avcodec/opustab: Make array static
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 Dec. 30, 2020, 11:31 p.m. UTC
It can and therefore we switch from a heap allocated VLC table to
a VLC initialized via the mechanism for static VLCs, but without
an actual static VLC.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavcodec/dv.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/dv.c b/libavcodec/dv.c
index 9c75cfd877..7c1ec6e0b2 100644
--- a/libavcodec/dv.c
+++ b/libavcodec/dv.c
@@ -202,7 +202,8 @@  av_cold int ff_dvvideo_init(AVCodecContext *avctx)
     int i, j;
 
     if (!done) {
-        VLC dv_vlc;
+        VLC_TYPE vlc_buf[FF_ARRAY_ELEMS(ff_dv_rl_vlc)][2] = { 0 };
+        VLC dv_vlc = { .table = vlc_buf, .table_allocated = FF_ARRAY_ELEMS(vlc_buf) };
         uint16_t  new_dv_vlc_bits[NB_DV_VLC * 2];
         uint8_t    new_dv_vlc_len[NB_DV_VLC * 2];
         uint8_t    new_dv_vlc_run[NB_DV_VLC * 2];
@@ -232,7 +233,7 @@  av_cold int ff_dvvideo_init(AVCodecContext *avctx)
         /* NOTE: as a trick, we use the fact the no codes are unused
          * to accelerate the parsing of partial codes */
         init_vlc(&dv_vlc, TEX_VLC_BITS, j, new_dv_vlc_len,
-                 1, 1, new_dv_vlc_bits, 2, 2, 0);
+                 1, 1, new_dv_vlc_bits, 2, 2, INIT_VLC_USE_NEW_STATIC);
         av_assert1(dv_vlc.table_size == 1664);
 
         for (i = 0; i < dv_vlc.table_size; i++) {
@@ -251,7 +252,6 @@  av_cold int ff_dvvideo_init(AVCodecContext *avctx)
             ff_dv_rl_vlc[i].level = level;
             ff_dv_rl_vlc[i].run   = run;
         }
-        ff_free_vlc(&dv_vlc);
     }
 
     s->avctx = avctx;