[FFmpeg-cvslog] r11603 - trunk/libavutil/tree.c

michael subversion
Wed Jan 23 22:03:21 CET 2008


Author: michael
Date: Wed Jan 23 22:03:21 2008
New Revision: 11603

Log:
Comment to explain how the add/remove core works.


Modified:
   trunk/libavutil/tree.c

Modified: trunk/libavutil/tree.c
==============================================================================
--- trunk/libavutil/tree.c	(original)
+++ trunk/libavutil/tree.c	Wed Jan 23 22:03:21 2008
@@ -75,6 +75,24 @@ void *av_tree_insert(AVTreeNode **tp, vo
 
             if(!(t->state&1)){
                 if(t->state){
+                    /* The following code is equivalent to
+                    if((*child)->state*2 == -t->state)
+                        rotate(child, i^1);
+                    rotate(tp, i);
+
+                    with rotate():
+                    static void rotate(AVTreeNode **tp, int i){
+                        AVTreeNode *t= *tp;
+
+                        *tp= t->child[i];
+                        t->child[i]= t->child[i]->child[i^1];
+                        (*tp)->child[i^1]= t;
+                        i= 4*t->state + 2*(*tp)->state + 12;
+                          t  ->state=                     ((0x614586 >> i) & 3)-1;
+                        (*tp)->state= ((*tp)->state>>1) + ((0x400EEA >> i) & 3)-1;
+                    }
+                    but such a rotate function is both bigger and slower
+                    */
                     if((*child)->state*2 == -t->state){
                         *tp= (*child)->child[i^1];
                         (*child)->child[i^1]= (*tp)->child[i];




More information about the ffmpeg-cvslog mailing list