diff mbox series

[FFmpeg-devel,6/8] avcodec/magicyuv: Reuse array instead of using multiple arrays

Message ID 20200831210930.18900-6-andreas.rheinhardt@gmail.com
State Accepted
Commit aae499f77a1d9f9083486fc7d98baf63e0ab917f
Headers show
Series [FFmpeg-devel,1/8] avcodec/magicyuv: Don't invert Huffman table symbols twice | expand

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Andreas Rheinhardt Aug. 31, 2020, 9:09 p.m. UTC
The lengths of the VLC codes are implicitly contained in the VLC tables
itself; apart from that they are not used lateron. So it is unnecessary
to store them and the very same array can be reused to parse the Huffman
table for the next plane.

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

Patch

diff --git a/libavcodec/magicyuv.c b/libavcodec/magicyuv.c
index 9282b39723..a16135e683 100644
--- a/libavcodec/magicyuv.c
+++ b/libavcodec/magicyuv.c
@@ -68,7 +68,7 @@  typedef struct MagicYUVContext {
     int               vshift[4];
     Slice            *slices[4];      // slice bitstream positions for each plane
     unsigned int      slices_size[4]; // slice sizes for each plane
-    uint8_t           len[4][4096];   // table of code lengths for each plane
+    uint8_t           len[4096];      // scratch table of code lengths
     VLC               vlc[4];         // VLC for each plane
     int (*huff_build)(VLC *vlc, uint8_t *len);
     int (*magy_decode_slice)(AVCodecContext *avctx, void *tdata,
@@ -465,11 +465,11 @@  static int build_huffman(AVCodecContext *avctx, GetBitContext *gbit, int max)
         }
 
         for (; j < k; j++)
-            s->len[i][j] = x;
+            s->len[j] = x;
 
         if (j == max) {
             j = 0;
-            if (s->huff_build(&s->vlc[i], s->len[i])) {
+            if (s->huff_build(&s->vlc[i], s->len)) {
                 av_log(avctx, AV_LOG_ERROR, "Cannot build Huffman codes\n");
                 return AVERROR_INVALIDDATA;
             }