update the version number from 1.0.4 to 1.0.5-beta1
[flac.git] / src / libFLAC / bitmath.c
index 4543ccb..fdfdfd8 100644 (file)
@@ -1,5 +1,5 @@
 /* libFLAC - Free Lossless Audio Codec library
- * Copyright (C) 2001,2002  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
@@ -98,3 +98,27 @@ unsigned FLAC__bitmath_silog2(int 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;
+               }
+       }
+}