/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.gagravarr.ogg;

public class CRCUtils {
	protected static final Integer CRC_POLYNOMIAL = Integer.valueOf(0x04c11db7);
	private static int[] CRC_TABLE = new int[256];
	
	static {
		int crc;
		for(int i=0; i<256; i++) {
			crc = i << 24;
			for(int j=0; j<8; j++) {
	            if( (crc & 0x80000000) != 0 ) {
	            	crc = ((crc << 1) ^ CRC_POLYNOMIAL);
	            } else {
	               crc <<= 1;
	            }
			}
			CRC_TABLE[i] = crc;
		}
	}

	public static int getCRC(byte[] data) {
		return getCRC(data, 0);
	}
	public static int getCRC(byte[] data, int previous) {
		int crc = previous;
		int a,b;
		
		for(int i=0; i<data.length; i++) {
			a = crc << 8;
			b = CRC_TABLE[ ((crc>>>24) & 0xff) ^ (data[i] & 0xff) ];
			crc = a ^ b;
		}
		
		return crc;
	}
}

@@ -607,17 +607,20 @@
 Utils %7B%0A
-%09
+    
 protecte
@@ -634,23 +634,19 @@
 c final 
-I
+i
 nt
-eger
  CRC_POL
@@ -659,24 +659,8 @@
 L = 
-Integer.valueOf(
 0x04
@@ -665,20 +665,22 @@
 04c11db7
-)
 ;%0A
-%09
+    
 private 
@@ -718,19 +718,21 @@
 t%5B256%5D;%0A
-%09%0A%09
+%0A    
 static %7B
@@ -732,18 +732,24 @@
 tatic %7B%0A
-%09%09
+        
 int crc;
@@ -749,18 +749,24 @@
 nt crc;%0A
-%09%09
+        
 for(int 
@@ -784,19 +784,28 @@
  i++) %7B%0A
-%09%09%09
+            
 crc = i 
@@ -811,19 +811,28 @@
  %3C%3C 24;%0A
-%09%09%09
+            
 for(int 
@@ -844,25 +844,28 @@
 j%3C8; j++) %7B%0A
-%09
+    
             
@@ -896,17 +896,22 @@
 = 0 ) %7B%0A
-%09
+      
         
@@ -914,17 +914,18 @@
         
-%09
+  
 crc = ((
@@ -953,17 +953,20 @@
 OMIAL);%0A
-%09
+    
         
@@ -978,17 +978,21 @@
  else %7B%0A
-%09
+     
         
@@ -1009,17 +1009,20 @@
  %3C%3C= 1;%0A
-%09
+    
         
@@ -1031,45 +1031,75 @@
   %7D%0A
-%09%09%09%7D%0A%09%09%09CRC_TABLE%5Bi%5D = crc;%0A%09%09%7D%0A%09%7D%0A%0A%09
+            %7D%0A            CRC_TABLE%5Bi%5D = crc;%0A        %7D%0A    %7D%0A%0A    
 publ
@@ -1134,18 +1134,24 @@
 data) %7B%0A
-%09%09
+        
 return g
@@ -1166,20 +1166,26 @@
 ta, 0);%0A
-%09%7D%0A%09
+    %7D%0A    
 public s
@@ -1230,18 +1230,24 @@
 ious) %7B%0A
-%09%09
+        
 int crc 
@@ -1258,18 +1258,24 @@
 evious;%0A
-%09%09
+        
 int a,b;
@@ -1275,21 +1275,25 @@
 nt a,b;%0A
-%09%09%0A%09%09
+%0A        
 for(int 
@@ -1319,19 +1319,28 @@
  i++) %7B%0A
-%09%09%09
+            
 a = crc 
@@ -1345,19 +1345,28 @@
 c %3C%3C 8;%0A
-%09%09%09
+            
 b = CRC_
@@ -1418,11 +1418,20 @@
  %5D;%0A
-%09%09%09
+            
 crc 
@@ -1443,17 +1443,27 @@
  b;%0A
-%09%09%7D%0A%09%09%0A%09%09
+        %7D%0A%0A        
 retu
@@ -1474,9 +1474,12 @@
 rc;%0A
-%09
+    
 %7D%0A%7D%0A

Fix whitespace