[FFmpeg-cvslog] qsort: flip compare direction to match libc qsort()

Michael Niedermayer git at videolan.org
Fri Jun 22 22:50:33 CEST 2012


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Fri Jun 22 22:47:30 2012 +0200| [0567715a6b948cbb1251957f7550645d1726cfa0] | committer: Michael Niedermayer

qsort: flip compare direction to match libc qsort()

Found-by: ubitux
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0567715a6b948cbb1251957f7550645d1726cfa0
---

 libavutil/qsort.h |   18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/libavutil/qsort.h b/libavutil/qsort.h
index 089eb74..30edcc8 100644
--- a/libavutil/qsort.h
+++ b/libavutil/qsort.h
@@ -41,23 +41,23 @@
                 type *right = end-2;\
                 type *left  = start+1;\
                 type *mid = start + ((end-start)>>1);\
-                if(cmp(start, end) < 0) {\
-                    if(cmp(  end, mid) < 0) FFSWAP(type, *start, *mid);\
+                if(cmp(start, end) > 0) {\
+                    if(cmp(  end, mid) > 0) FFSWAP(type, *start, *mid);\
                     else                    FFSWAP(type, *start, *end);\
                 }else{\
-                    if(cmp(start, mid) < 0) FFSWAP(type, *start, *mid);\
+                    if(cmp(start, mid) > 0) FFSWAP(type, *start, *mid);\
                     else checksort= 1;\
                 }\
-                if(cmp(mid, end) < 0){ \
+                if(cmp(mid, end) > 0){ \
                     FFSWAP(type, *mid, *end);\
                     checksort=0;\
                 }\
                 if(start == end-2) break;\
                 FFSWAP(type, end[-1], *mid);\
                 while(left <= right){\
-                    while(left<=right && cmp(left, end-1) > 0)\
+                    while(left<=right && cmp(left, end-1) < 0)\
                         left++;\
-                    while(left<=right && cmp(right, end-1) < 0)\
+                    while(left<=right && cmp(right, end-1) > 0)\
                         right--;\
                     if(left <= right){\
                         FFSWAP(type, *left, *right);\
@@ -68,7 +68,7 @@
                 FFSWAP(type, end[-1], *left);\
                 if(checksort && (mid == left-1 || mid == left)){\
                     mid= start;\
-                    while(mid<end && cmp(mid, mid+1) >= 0)\
+                    while(mid<end && cmp(mid, mid+1) <= 0)\
                         mid++;\
                     if(mid==end)\
                         break;\
@@ -83,7 +83,7 @@
                     end = right;\
                 }\
             }else{\
-                if(cmp(start, end) < 0)\
+                if(cmp(start, end) > 0)\
                     FFSWAP(type, *start, *end);\
                 break;\
             }\
@@ -104,7 +104,7 @@
             unsigned a[2] = {i, i+step};\
             unsigned end = FFMIN(i+2*step, (num));\
             for(j=i; a[0]<i+step && a[1]<end; j++){\
-                int idx= cmp(p+a[0], p+a[1]) < 0;\
+                int idx= cmp(p+a[0], p+a[1]) > 0;\
                 tmp[j] = p[ a[idx]++ ];\
             }\
             if(a[0]>=i+step) a[0] = a[1];\



More information about the ffmpeg-cvslog mailing list