[FFmpeg-cvslog] avcodec/webp: Use uint8_t for code lengths

Andreas Rheinhardt git at videolan.org
Tue Oct 27 12:51:18 EET 2020


ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at gmail.com> | Thu Oct 22 15:54:08 2020 +0200| [d4cce1514edf023145fb5a8af9c52bb8e95bede1] | committer: Andreas Rheinhardt

avcodec/webp: Use uint8_t for code lengths

They are always in the range 0..15, so using an int is not necessary.
Furthermore, using an int would not work if sizeof(int) != 4 as
ff_init_vlc_sparse() can only handle uint8_t, uint16_t and uint32_t
lengths.

Reviewed-by: zhilizhao(赵志立) <quinkblack at foxmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>

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

 libavcodec/webp.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavcodec/webp.c b/libavcodec/webp.c
index 6140c7ea4a..6b53a7f17c 100644
--- a/libavcodec/webp.c
+++ b/libavcodec/webp.c
@@ -243,7 +243,7 @@ static int huff_reader_get_symbol(HuffReader *r, GetBitContext *gb)
         return get_vlc2(gb, r->vlc.table, 8, 2);
 }
 
-static int huff_reader_build_canonical(HuffReader *r, int *code_lengths,
+static int huff_reader_build_canonical(HuffReader *r, const uint8_t *code_lengths,
                                        int alphabet_size)
 {
     int len = 0, sym, code = 0, ret;
@@ -324,8 +324,8 @@ static int read_huffman_code_normal(WebPContext *s, HuffReader *hc,
                                     int alphabet_size)
 {
     HuffReader code_len_hc = { { 0 }, 0, 0, { 0 } };
-    int *code_lengths = NULL;
-    int code_length_code_lengths[NUM_CODE_LENGTH_CODES] = { 0 };
+    uint8_t *code_lengths = NULL;
+    uint8_t code_length_code_lengths[NUM_CODE_LENGTH_CODES] = { 0 };
     int i, symbol, max_symbol, prev_code_len, ret;
     int num_codes = 4 + get_bits(&s->gb, 4);
 
@@ -340,7 +340,7 @@ static int read_huffman_code_normal(WebPContext *s, HuffReader *hc,
     if (ret < 0)
         goto finish;
 
-    code_lengths = av_mallocz_array(alphabet_size, sizeof(*code_lengths));
+    code_lengths = av_mallocz(alphabet_size);
     if (!code_lengths) {
         ret = AVERROR(ENOMEM);
         goto finish;



More information about the ffmpeg-cvslog mailing list