diff options
author | Andreas Rheinhardt <andreas.rheinhardt@gmail.com> | 2020-10-22 15:54:08 +0200 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@gmail.com> | 2020-10-27 11:51:01 +0100 |
commit | d4cce1514edf023145fb5a8af9c52bb8e95bede1 (patch) | |
tree | 127307c72a201cda5428a2587f117c75480e3553 /libavcodec | |
parent | 6f36eb0da71d22aadf8f056f0966bd86656ea57e (diff) | |
download | ffmpeg-d4cce1514edf023145fb5a8af9c52bb8e95bede1.tar.gz |
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@foxmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/webp.c | 8 |
1 files 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; |