update the version number from 1.0.4 to 1.0.5-beta1
[flac.git] / src / libFLAC / bitmath.c
index 644f5ad..fdfdfd8 100644 (file)
@@ -1,5 +1,5 @@
 /* libFLAC - Free Lossless Audio Codec library
- * Copyright (C) 2001  Josh Coalson
+ * Copyright (C) 2001,2002,2003  Josh Coalson
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -93,7 +93,32 @@ unsigned FLAC__bitmath_silog2(int v)
                        return 2;
                }
                else {
-                       v = -(++v);
+                       v++;
+                       v = -v;
+               }
+       }
+}
+
+unsigned FLAC__bitmath_silog2_wide(FLAC__int64 v)
+{
+       while(1) {
+               if(v == 0) {
+                       return 0;
+               }
+               else if(v > 0) {
+                       unsigned l = 0;
+                       while(v) {
+                               l++;
+                               v >>= 1;
+                       }
+                       return l+1;
+               }
+               else if(v == -1) {
+                       return 2;
+               }
+               else {
+                       v++;
+                       v = -v;
                }
        }
 }