Index: /libmpc/trunk/libmpcdec/mpc_bits_reader.h
===================================================================
--- /libmpc/trunk/libmpcdec/mpc_bits_reader.h	(revision 309)
+++ /libmpc/trunk/libmpcdec/mpc_bits_reader.h	(revision 310)
@@ -44,4 +44,5 @@
 extern const mpc_uint32_t Cnk_lost[MAX_ENUM / 2][MAX_ENUM];
 
+// can read up to 31 bits
 static mpc_inline mpc_uint32_t mpc_bits_read(mpc_bits_reader * r, const unsigned int nb_bits)
 {
@@ -58,5 +59,5 @@
 	}
 
-	return ret & (-1u >> (32 - nb_bits));
+	return ret & ((1 << nb_bits) - 1);
 }
 
Index: /libmpc/trunk/libmpcdec/mpc_decoder.c
===================================================================
--- /libmpc/trunk/libmpcdec/mpc_decoder.c	(revision 309)
+++ /libmpc/trunk/libmpcdec/mpc_decoder.c	(revision 310)
@@ -369,6 +369,9 @@
 	d->Res_L[0] = mpc_bits_read(r, 4);
 	d->Res_R[0] = mpc_bits_read(r, 4);
-	if (d->ms && !(d->Res_L[0] == 0 && d->Res_R[0] == 0))
-        d->MS_Flag[0] = mpc_bits_read(r, 1);
+	if (!(d->Res_L[0] == 0 && d->Res_R[0] == 0)) {
+		if (d->ms)
+        	d->MS_Flag[0] = mpc_bits_read(r, 1);
+		Max_used_Band = 1;
+	}
 
     // consecutive subbands
@@ -383,9 +386,10 @@
 			if (d->ms)
             	d->MS_Flag[n] = mpc_bits_read(r, 1);
-			Max_used_Band = n;
+			Max_used_Band = n + 1;
 		}
     }
+
     /****************************** SCFI ******************************/
-    for ( n = 0; n <= Max_used_Band; n++ ) {
+    for ( n = 0; n < Max_used_Band; n++ ) {
 		if (d->Res_L[n])
 			d->SCFI_L[n] = mpc_bits_huff_dec(r, mpc_table_HuffSCFI);
@@ -395,5 +399,5 @@
 
     /**************************** SCF/DSCF ****************************/
-    for ( n = 0; n <= Max_used_Band; n++ ) {
+    for ( n = 0; n < Max_used_Band; n++ ) {
 		mpc_int32_t * SCF = d->SCF_Index_L[n];
 		mpc_uint32_t Res  = d->Res_L[n], SCFI = d->SCFI_L[n];
@@ -448,5 +452,5 @@
 
     /***************************** Samples ****************************/
-    for ( n = 0; n <= Max_used_Band; n++ ) {
+    for ( n = 0; n < Max_used_Band; n++ ) {
 		mpc_int32_t *q = d->Q[n].L, Res = d->Res_L[n];
 		do {
@@ -554,6 +558,4 @@
 	for( n = Max_used_Band; n <= d->max_band; n++)
 		d->Res_L[n] = d->Res_R[n] = 0;
-
-
 
 	/****************************** SCFI ******************************/
Index: /libmpc/trunk/libmpcdec/streaminfo.c
===================================================================
--- /libmpc/trunk/libmpcdec/streaminfo.c	(revision 309)
+++ /libmpc/trunk/libmpcdec/streaminfo.c	(revision 310)
@@ -105,5 +105,5 @@
 
 	si->bitrate            = 0;
-	frames                 = mpc_bits_read(r, 32);
+	frames                 = (mpc_bits_read(r, 16) << 16) | mpc_bits_read(r, 16);
 	mpc_bits_read(r, 1); // intensity stereo : should be 0
 	si->ms                 = mpc_bits_read(r, 1);
@@ -185,5 +185,5 @@
 	mpc_bits_reader r = *r_in;
 
-	CRC = mpc_bits_read(&r, 32);
+	CRC = (mpc_bits_read(&r, 16) << 16) | mpc_bits_read(&r, 16);
 	if (CRC != crc32(r.buff + 1 - (r.count >> 3), (int)block_size - 4))
 		return MPC_STATUS_FILE;
