changeset 6472:e39e03d99d24 libavcodec

huffman: pass hnode_first as a flag instead of as an argument on its own
author aurel
date Sat, 08 Mar 2008 17:57:13 +0000
parents b72f6c4cee12
children e0cd9697ac6d
files huffman.c huffman.h vp6.c
diffstat 3 files changed, 8 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/huffman.c	Sat Mar 08 17:18:28 2008 +0000
+++ b/huffman.c	Sat Mar 08 17:57:13 2008 +0000
@@ -64,7 +64,7 @@
  * first nb_codes nodes.count must be set
  */
 int ff_huff_build_tree(AVCodecContext *avctx, VLC *vlc, int nb_codes,
-                       Node *nodes, huff_cmp_t cmp, int hnode_first)
+                       Node *nodes, huff_cmp_t cmp, int flags)
 {
     int i, j;
     int cur_node;
@@ -90,7 +90,8 @@
         for(j = cur_node; j > 0; j--){
             if(nodes[j].count > nodes[j-1].count ||
                (nodes[j].count == nodes[j-1].count &&
-                (!hnode_first || nodes[j].n0==j-1 || nodes[j].n0==j-2 ||
+                (!(flags & FF_HUFFMAN_FLAG_HNODE_FIRST) ||
+                 nodes[j].n0==j-1 || nodes[j].n0==j-2 ||
                  (nodes[j].sym!=HNODE && nodes[j-1].sym!=HNODE))))
                 break;
             FFSWAP(Node, nodes[j], nodes[j-1]);
--- a/huffman.h	Sat Mar 08 17:18:28 2008 +0000
+++ b/huffman.h	Sat Mar 08 17:57:13 2008 +0000
@@ -32,8 +32,10 @@
     uint32_t count;
 } Node;
 
+#define FF_HUFFMAN_FLAG_HNODE_FIRST 0x01
+
 typedef int (*huff_cmp_t)(const void *va, const void *vb);
 int ff_huff_build_tree(AVCodecContext *avctx, VLC *vlc, int nb_codes,
-                       Node *nodes, huff_cmp_t cmp, int hnode_first);
+                       Node *nodes, huff_cmp_t cmp, int flags);
 
 #endif /* FFMPEG_HUFFMAN_H */
--- a/vp6.c	Sat Mar 08 17:18:28 2008 +0000
+++ b/vp6.c	Sat Mar 08 17:57:13 2008 +0000
@@ -224,7 +224,8 @@
     }
 
     /* then build the huffman tree accodring to probabilities */
-    ff_huff_build_tree(s->avctx, vlc, size, nodes, vp6_huff_cmp, 1);
+    ff_huff_build_tree(s->avctx, vlc, size, nodes, vp6_huff_cmp,
+                       FF_HUFFMAN_FLAG_HNODE_FIRST);
 }
 
 static void vp6_parse_coeff_models(vp56_context_t *s)