Mercurial > libavcodec.hg
comparison vp6.c @ 7093:544da38cb2c9 libavcodec
vp6: ensure that huffman decoding table is sorted with descending symbol order
Previous code worked by pure luck with glibc qsort implementation.
patch by Peter Ross pross _at_ xvid _dot_ org
author | aurel |
---|---|
date | Sun, 22 Jun 2008 13:20:41 +0000 |
parents | e943e1409077 |
children | 21c3e313709e |
comparison
equal
deleted
inserted
replaced
7092:359237c9a10b | 7093:544da38cb2c9 |
---|---|
200 for (node=0; node<8; node++) | 200 for (node=0; node<8; node++) |
201 if (vp56_rac_get_prob(c, vp6_fdv_pct[comp][node])) | 201 if (vp56_rac_get_prob(c, vp6_fdv_pct[comp][node])) |
202 model->vector_fdv[comp][node] = vp56_rac_gets_nn(c, 7); | 202 model->vector_fdv[comp][node] = vp56_rac_gets_nn(c, 7); |
203 } | 203 } |
204 | 204 |
205 /* nodes must ascend by count, but with descending symbol order */ | |
205 static int vp6_huff_cmp(const void *va, const void *vb) | 206 static int vp6_huff_cmp(const void *va, const void *vb) |
206 { | 207 { |
207 const Node *a = va, *b = vb; | 208 const Node *a = va, *b = vb; |
208 return a->count >= b->count; | 209 return (a->count - b->count)*16 + (b->sym - a->sym); |
209 } | 210 } |
210 | 211 |
211 static void vp6_build_huff_tree(vp56_context_t *s, uint8_t coeff_model[], | 212 static void vp6_build_huff_tree(vp56_context_t *s, uint8_t coeff_model[], |
212 const uint8_t *map, unsigned size, VLC *vlc) | 213 const uint8_t *map, unsigned size, VLC *vlc) |
213 { | 214 { |