[FFmpeg-cvslog] avcodec/vp6: Don't initialize unused VLC tables

Andreas Rheinhardt git at videolan.org
Sat Apr 26 01:14:57 EEST 2025


ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Thu Apr 17 19:41:05 2025 +0200| [57b7783c22ce33387e312a9a1038708e39c857f9] | committer: Andreas Rheinhardt

avcodec/vp6: Don't initialize unused VLC tables

There are only 2*3*4 VLC trees for decoding Huffman encoded
AC coefficients; see section 13.3.2 of the spec.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=57b7783c22ce33387e312a9a1038708e39c857f9
---

 libavcodec/vp56.h |  2 +-
 libavcodec/vp6.c  | 10 ++++------
 2 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/libavcodec/vp56.h b/libavcodec/vp56.h
index 87b7e06e0b..e922a13c5e 100644
--- a/libavcodec/vp56.h
+++ b/libavcodec/vp56.h
@@ -203,7 +203,7 @@ struct vp56_context {
     GetBitContext gb;
     VLC dccv_vlc[2];
     VLC runv_vlc[2];
-    VLC ract_vlc[2][3][6];
+    VLC ract_vlc[2][3][4];
     unsigned int nb_null[2][2];       /* number of consecutive NULL DC/AC */
 
     int have_undamaged_frame;
diff --git a/libavcodec/vp6.c b/libavcodec/vp6.c
index 73d117c871..926694ae11 100644
--- a/libavcodec/vp6.c
+++ b/libavcodec/vp6.c
@@ -339,7 +339,7 @@ static int vp6_parse_coeff_models(VP56Context *s)
                                     vp6_huff_run_map, 9, &s->runv_vlc[pt]))
                 return -1;
             for (ct=0; ct<3; ct++)
-                for (cg = 0; cg < 6; cg++)
+                for (int cg = 0; cg < 4; cg++)
                     if (vp6_build_huff_tree(s, model->coeff_ract[pt][ct][cg],
                                             vp6_huff_coeff_map, 12,
                                             &s->ract_vlc[pt][ct][cg]))
@@ -704,15 +704,13 @@ static av_cold int vp6_decode_free(AVCodecContext *avctx)
 
 static av_cold void vp6_decode_free_context(VP56Context *s)
 {
-    int pt, ct, cg;
-
     ff_vp56_free_context(s);
 
-    for (pt=0; pt<2; pt++) {
+    for (int pt = 0; pt < 2; ++pt) {
         ff_vlc_free(&s->dccv_vlc[pt]);
         ff_vlc_free(&s->runv_vlc[pt]);
-        for (ct=0; ct<3; ct++)
-            for (cg=0; cg<6; cg++)
+        for (int ct = 0; ct < 3; ++ct)
+            for (int cg = 0; cg < 4; ++cg)
                 ff_vlc_free(&s->ract_vlc[pt][ct][cg]);
     }
 }



More information about the ffmpeg-cvslog mailing list