diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2013-12-06 14:13:19 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2013-12-06 14:13:33 +0100 |
commit | 82c7d704fdc40e0e308d7d6db8a3c48367ca37fc (patch) | |
tree | 4a011dde54b182c7bf4afc693e6af7d6792bd60e /libavcodec/webp.c | |
parent | db44eff197be05b7423105567dac336f10e18941 (diff) | |
parent | d085f80fa1381b363b0b91689407d5646d78ed28 (diff) | |
download | ffmpeg-82c7d704fdc40e0e308d7d6db8a3c48367ca37fc.tar.gz |
Merge remote-tracking branch 'qatar/master'
* qatar/master:
webp: add a special case for a huffman table with only 1 symbol
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/webp.c')
-rw-r--r-- | libavcodec/webp.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/libavcodec/webp.c b/libavcodec/webp.c index 4f137316df..c6d41bea15 100644 --- a/libavcodec/webp.c +++ b/libavcodec/webp.c @@ -277,10 +277,26 @@ static int huff_reader_get_symbol(HuffReader *r, GetBitContext *gb) static int huff_reader_build_canonical(HuffReader *r, int *code_lengths, int alphabet_size) { - int len, sym, code, ret; + int len = 0, sym, code = 0, ret; int max_code_length = 0; uint16_t *codes; + /* special-case 1 symbol since the vlc reader cannot handle it */ + for (sym = 0; sym < alphabet_size; sym++) { + if (code_lengths[sym] > 0) { + len++; + code = sym; + if (len > 1) + break; + } + } + if (len == 1) { + r->nb_symbols = 1; + r->simple_symbols[0] = code; + r->simple = 1; + return 0; + } + for (sym = 0; sym < alphabet_size; sym++) max_code_length = FFMAX(max_code_length, code_lengths[sym]); |