Index: libmpc/branches/r2d/libmpcenc/encode_sv7.c
===================================================================
--- libmpc/branches/r2d/libmpcenc/encode_sv7.c	(revision 212)
+++ libmpc/branches/r2d/libmpcenc/encode_sv7.c	(revision 220)
@@ -60,9 +60,9 @@
 
 // writes replay gain info
-static void writeGainInfo ( mpc_encoder_t * e,
-							unsigned short t_gain,
-							unsigned short t_peak,
-							unsigned short a_gain,
-							unsigned short a_peak)
+void writeGainInfo ( mpc_encoder_t * e,
+					 unsigned short t_gain,
+					 unsigned short t_peak,
+					 unsigned short a_gain,
+					 unsigned short a_peak)
 {
 	writeBits ( e, 1,  8 ); // version
@@ -80,15 +80,8 @@
                   const unsigned int  SamplesCount,
                   const unsigned int  SampleFreq,
-				  const unsigned int  ChannelCount,
-				  unsigned short t_gain,
-				  unsigned short t_peak,
-				  unsigned short a_gain,
-				  unsigned short a_peak)
+				  const unsigned int  ChannelCount)
 {
 	unsigned char tmp[10];
-	int i, len = encodeSize(SamplesCount, (char *)tmp, MPC_FALSE);
-
-	len = encodeSize(len + 3, (char *)tmp, MPC_TRUE);
-	writeBits ( e, tmp[0]  , 8 );
+	int i, len;
 
     writeBits ( e, 8,  8 );    // StreamVersion
@@ -96,5 +89,7 @@
 	len = encodeSize(SamplesCount, (char *)tmp, MPC_FALSE);
 	for( i = 0; i < len; i++) // nb of samples
-		writeBits ( e, tmp[i]  , 8 );
+		writeBits ( e, tmp[i], 8 );
+	writeBits ( e, 0, 8 ); // nb of samples to skip at beginning
+	writeBits ( e, 0, 8 ); // nb of samples to skip at end
 
 	switch ( SampleFreq ) {
@@ -107,10 +102,8 @@
 	}
 
+	writeBits ( e, MaxBand - 1  ,  5 );    // Bandwidth
 	writeBits ( e, ChannelCount - 1  ,  4 );    // Channels
-	writeBits ( e, MaxBand - 1  ,  5 );    // Bandwidth
 	writeBits ( e, MS_on        ,  1 );    // MS-Coding Flag
 	writeBits ( e, FRAMES_PER_BLOCK_PWR >> 1,  3 );    // frames per block (log4 unit)
-
-	writeGainInfo(e, t_gain, t_peak, a_gain, a_peak);
 }
 
@@ -121,12 +114,10 @@
 						const int version_major,
 						const int version_minor,
-						const int version_implement,
 						const int version_build )
 {
 	writeBits ( e, (mpc_uint32_t)(profile * 8 + .5),  7 );
 	writeBits ( e, PNS_on,  1 );
-	writeBits ( e, version_major,  4 );
+	writeBits ( e, version_major,  8 );
 	writeBits ( e, version_minor,  8 );
-	writeBits ( e, version_implement,  4 );
 	writeBits ( e, version_build,  8 );
 }
@@ -269,5 +260,5 @@
 	for ( n = 0; n < MaxBand; n++ ) {
 		int Res = e->Res_L[n];
-		const unsigned int * q = e->Q[n].L;
+		const int * q = e->Q[n].L;
 		static const unsigned int thres[] = {0, 0, 3, 7, 9, 1, 3, 4, 8};
 		static const int HuffQ2_var[5*5*5] =
@@ -356,5 +347,5 @@
 		}
 		e->block_cnt++;
-		writeBlock(e, "AD", MPC_FALSE, 0);
+		writeBlock(e, "AP", MPC_FALSE, 0);
 	}
 }
Index: libmpc/branches/r2d/libmpcenc/libmpcenc.h
===================================================================
--- libmpc/branches/r2d/libmpcenc/libmpcenc.h	(revision 212)
+++ libmpc/branches/r2d/libmpcenc/libmpcenc.h	(revision 220)
@@ -80,9 +80,10 @@
 						const unsigned int  SamplesCount,
 						const unsigned int  SampleFreq,
-						const unsigned int  ChannelCount,
-						unsigned short t_gain,
-						unsigned short t_peak,
-						unsigned short a_gain,
-						unsigned short a_peak);
+						const unsigned int  ChannelCount);
+ void writeGainInfo ( mpc_encoder_t * e,
+					  unsigned short t_gain,
+					  unsigned short t_peak,
+					  unsigned short a_gain,
+					  unsigned short a_peak);
  void writeEncoderInfo ( mpc_encoder_t * e,
 						 const float profile,
@@ -90,5 +91,4 @@
 						 const int version_major,
 						 const int version_minor,
-						 const int version_implement,
 						 const int version_build );
  mpc_uint32_t writeBlock ( mpc_encoder_t *, const char *, const mpc_bool_t, mpc_uint32_t);
