Index: libmpc/branches/r2d/libmpcdec/mpc_demux.c
===================================================================
--- libmpc/branches/r2d/libmpcdec/mpc_demux.c	(revision 219)
+++ libmpc/branches/r2d/libmpcdec/mpc_demux.c	(revision 220)
@@ -298,12 +298,14 @@
 		mpc_demux_fill(d, 11, 0); // max header block size
 		size = mpc_bits_get_block(&d->bits_reader, &b);
-		while( memcmp(b.key, "AD", 2) != 0 ){ // scan all blocks until audio
+		while( memcmp(b.key, "AP", 2) != 0 ){ // scan all blocks until audio
 			mpc_demux_fill(d, 11 + (mpc_uint32_t) b.size, 0);
-			if (memcmp(b.key, "SI", 2) == 0){
+			if (memcmp(b.key, "SH", 2) == 0){
 				int ret = streaminfo_read_header_sv8(&d->si, &d->bits_reader, (mpc_uint32_t) b.size);
 				if (ret != MPC_STATUS_OK) return ret;
-			} else if (memcmp(b.key, "EI", 2) == 0)
+			} else if (memcmp(b.key, "RG", 2) == 0)
+				streaminfo_gain(&d->si, &d->bits_reader);
+			else if (memcmp(b.key, "EI", 2) == 0)
 				streaminfo_encoder_info(&d->si, &d->bits_reader);
-			else if (memcmp(b.key, "SP", 2) == 0)
+			else if (memcmp(b.key, "SO", 2) == 0)
 				mpc_demux_SP(d, size, (mpc_uint32_t) b.size);
 			else if (memcmp(b.key, "ST", 2) == 0)
@@ -366,5 +368,5 @@
 			mpc_demux_fill(d, 11, 0); // max header block size
 			mpc_bits_get_block(&d->bits_reader, &b);
-			while( memcmp(b.key, "AD", 2) != 0 ) { // scan all blocks until audio
+			while( memcmp(b.key, "AP", 2) != 0 ) { // scan all blocks until audio
 				if (memcmp(b.key, "SE", 2) == 0) { // end block
 					i->bits = -1;
@@ -436,5 +438,5 @@
 		size = mpc_bits_get_block(&d->bits_reader, &b);
 		while(i < fwd) {
-			if (memcmp(b.key, "AD", 2) == 0) {
+			if (memcmp(b.key, "AP", 2) == 0) {
 				if (d->d->decoded_samples == (d->seek_table_size << d->seek_pwr) * MPC_FRAME_LENGTH) {
 					d->seek_table[d->seek_table_size] = (mpc_uint32_t) mpc_demux_pos(d) - 8 * size;
Index: libmpc/branches/r2d/libmpcdec/streaminfo.c
===================================================================
--- libmpc/branches/r2d/libmpcdec/streaminfo.c	(revision 219)
+++ libmpc/branches/r2d/libmpcdec/streaminfo.c	(revision 220)
@@ -84,6 +84,5 @@
 		int major = si->encoder_version >> 24;
 		int minor = (si->encoder_version >> 16) & 0xFF;
-		int impl = (si->encoder_version >> 8) & 0xFF;
-		int build = si->encoder_version & 0xFF;
+		int build = (si->encoder_version >> 8) & 0xFF;
 		char * tmp = "--Stable--";
 
@@ -91,6 +90,5 @@
 			tmp = "--Unstable--";
 
-		sprintf(si->encoder, "%s %u.%u.%u build %u", tmp, major, minor, impl,
-				build);
+		sprintf(si->encoder, "%s %u.%u build %u", tmp, major, minor, build);
 	}
 }
@@ -164,5 +162,7 @@
 	mpc_bits_reader r = *r_in;
 
-	mpc_bits_read(&r, 8); // gain version
+	int version = mpc_bits_read(&r, 8); // gain version
+	if (version != 1) // we only know ver 1
+		return;
 	si->gain_title         = (mpc_uint16_t) mpc_bits_read(&r, 16);
 	si->peak_title         = (mpc_uint16_t) mpc_bits_read(&r, 16);
@@ -177,6 +177,5 @@
 {
 	mpc_uint32_t CRC;
-	mpc_uint64_t info_len;
-	mpc_bits_reader r = *r_in, r_gain;
+	mpc_bits_reader r = *r_in;
 
 	CRC = mpc_bits_read(&r, 32);
@@ -184,8 +183,4 @@
 		return MPC_STATUS_FILE;
 
-	r_gain = r;
-	mpc_bits_get_size(&r, &info_len);
-	r_gain.buff += info_len;
-
 	si->stream_version = mpc_bits_read(&r, 8);
 	if (si->stream_version != 8)
@@ -193,8 +188,11 @@
 
 	mpc_bits_get_size(&r, &si->samples);
+	mpc_bits_get_size(&r, &si->beg_silence);
+	mpc_bits_get_size(&r, &si->end_silence);
+
 	si->is_true_gapless = 1;
 	si->sample_freq = samplefreqs[mpc_bits_read(&r, 3)];
+	si->max_band = mpc_bits_read(&r, 5) + 1;
 	si->channels = mpc_bits_read(&r, 4) + 1;
-	si->max_band = mpc_bits_read(&r, 5) + 1;
 	si->ms = mpc_bits_read(&r, 1);
 	si->block_pwr = mpc_bits_read(&r, 3) * 2;
@@ -206,6 +204,4 @@
 				*  si->sample_freq / si->samples;
 
-	streaminfo_gain(si, &r_gain);
-
 	return MPC_STATUS_OK;
 }
@@ -219,8 +215,8 @@
 	si->profile_name       = mpc_get_version_string(si->profile);
 	si->pns                = mpc_bits_read(&r, 1);
-	si->encoder_version = mpc_bits_read(&r, 4) << 24; // major
+	si->encoder_version = mpc_bits_read(&r, 8) << 24; // major
 	si->encoder_version |= mpc_bits_read(&r, 8) << 16; // minor
-	si->encoder_version |= mpc_bits_read(&r, 4) << 8; // implementation
-	si->encoder_version |= mpc_bits_read(&r, 8); // build
+	si->encoder_version |= mpc_bits_read(&r, 8) << 8; // build
+
 
 	mpc_get_encoder_string(si);
