summaryrefslogtreecommitdiff
path: root/libavcodec/huffman.c
diff options
context:
space:
mode:
authorReimar Döffinger <Reimar.Doeffinger@gmx.de>2012-01-29 21:45:19 +0100
committerReimar Döffinger <Reimar.Doeffinger@gmx.de>2012-01-30 18:39:08 +0100
commit2ab5feafe17edd8f8483c4e461100e0d4cf63e8e (patch)
tree9a0d285d222fa3d3c67808bb3e26533741d0c3e7 /libavcodec/huffman.c
parent6166bf3cbe99d687b15fc5a84bd6d399d6bab3fa (diff)
downloadffmpeg-2ab5feafe17edd8f8483c4e461100e0d4cf63e8e.tar.gz
huffman: use a simple assignment instead of FFSWAP.
Signed-off-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de>
Diffstat (limited to 'libavcodec/huffman.c')
-rw-r--r--libavcodec/huffman.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/libavcodec/huffman.c b/libavcodec/huffman.c
index 42f28859c7..fd9fa95f07 100644
--- a/libavcodec/huffman.c
+++ b/libavcodec/huffman.c
@@ -91,16 +91,18 @@ int ff_huff_build_tree(AVCodecContext *avctx, VLC *vlc, int nb_codes,
nodes[nb_codes*2-1].count = 0;
for(i = 0; i < nb_codes*2-1; i += 2){
uint32_t cur_count = nodes[i].count + nodes[i+1].count;
- nodes[cur_node].sym = HNODE;
- nodes[cur_node].count = cur_count;
- nodes[cur_node].n0 = i;
+ // find correct place to insert new node, and
+ // make space for the new node while at it
for(j = cur_node; j > i + 2; j--){
if(cur_count > nodes[j-1].count ||
(cur_count == nodes[j-1].count &&
!(flags & FF_HUFFMAN_FLAG_HNODE_FIRST)))
break;
- FFSWAP(Node, nodes[j], nodes[j-1]);
+ nodes[j] = nodes[j - 1];
}
+ nodes[j].sym = HNODE;
+ nodes[j].count = cur_count;
+ nodes[j].n0 = i;
cur_node++;
}
if(build_huff_tree(vlc, nodes, nb_codes*2-2, flags) < 0){