Browse code

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

Originally committed as revision 13887 to svn://svn.ffmpeg.org/ffmpeg/trunk

Peter Ross authored on 2008/06/22 22:20:41
Showing 1 changed files
... ...
@@ -202,10 +202,11 @@ static void vp6_parse_vector_models(vp56_context_t *s)
202 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 206
 static int vp6_huff_cmp(const void *va, const void *vb)
206 207
 {
207 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 212
 static void vp6_build_huff_tree(vp56_context_t *s, uint8_t coeff_model[],