Index: /libmpc/branches/r2d/libmpcdec/mpc_demux.c
===================================================================
--- /libmpc/branches/r2d/libmpcdec/mpc_demux.c	(revision 225)
+++ /libmpc/branches/r2d/libmpcdec/mpc_demux.c	(revision 226)
@@ -271,4 +271,6 @@
 
 	memset(&d->si, 0, sizeof d->si);
+	d->si.pns = 0xFF;
+	d->si.profile_name = "n.a.";
 
     // get header position
Index: /libmpc/branches/r2d/libmpcenc/encode_sv7.c
===================================================================
--- /libmpc/branches/r2d/libmpcenc/encode_sv7.c	(revision 225)
+++ /libmpc/branches/r2d/libmpcenc/encode_sv7.c	(revision 226)
@@ -50,5 +50,8 @@
 // initialize SV8
 void
-Init_SV8 ( mpc_encoder_t * e )
+mpc_encoder_init ( mpc_encoder_t * e,
+				   mpc_uint64_t SamplesInWAVE,
+				   unsigned int FramesBlockPwr,
+				   unsigned int SeekDistance )
 {
 	Init_Skalenfaktoren ();
@@ -56,5 +59,26 @@
 
 	memset(e, 0, sizeof(*e));
-	e->seek_pwr = 1;
+
+	if (SeekDistance > 15)
+		SeekDistance = 1;
+	if (FramesBlockPwr > 14)
+		FramesBlockPwr = 6;
+
+	e->seek_pwr = SeekDistance;
+	e->frames_per_block_pwr = FramesBlockPwr;
+
+	if (SamplesInWAVE == 0)
+		e->seek_table = malloc((1 << 16) * sizeof(mpc_uint32_t));
+	else
+		e->seek_table = malloc((size_t)(2 + SamplesInWAVE / (MPC_FRAME_LENGTH << (e->seek_pwr + e->frames_per_block_pwr))) * sizeof(mpc_uint32_t));
+
+	e->buffer = malloc(MAX_FRAME_SIZE * (1 << e->frames_per_block_pwr) * sizeof(mpc_uint8_t));
+}
+
+void
+mpc_encoder_exit ( mpc_encoder_t * e )
+{
+	free(e->seek_table);
+	free(e->buffer);
 }
 
@@ -105,5 +129,5 @@
 	writeBits ( e, ChannelCount - 1  ,  4 );    // Channels
 	writeBits ( e, MS_on        ,  1 );    // MS-Coding Flag
-	writeBits ( e, FRAMES_PER_BLOCK_PWR >> 1,  3 );    // frames per block (log4 unit)
+	writeBits ( e, e->frames_per_block_pwr >> 1,  3 );    // frames per block (log4 unit)
 }
 
@@ -350,5 +374,5 @@
 
 	e->framesInBlock++;
-	if (e->framesInBlock == FRAMES_PER_BLOCK) {
+	if (e->framesInBlock == (1 << e->frames_per_block_pwr)) {
 		if ((e->block_cnt & ((1 << e->seek_pwr) - 1)) == 0) {
 			e->seek_table[e->seek_pos] = ftell(e->outputFile);
Index: /libmpc/branches/r2d/libmpcenc/libmpcenc.h
===================================================================
--- /libmpc/branches/r2d/libmpcenc/libmpcenc.h	(revision 225)
+++ /libmpc/branches/r2d/libmpcenc/libmpcenc.h	(revision 226)
@@ -27,11 +27,6 @@
 #endif
 
-// bitstream.c
-#define FRAMES_PER_BLOCK_PWR 6 // MUST be even
-#define FRAMES_PER_BLOCK (1 << FRAMES_PER_BLOCK_PWR)
-#define BUFFER_FULL         (4352 * FRAMES_PER_BLOCK)         // 34490 bit/frame  1320.3 kbps
-
-// FIXME : make this size dependent of the input file
-#define SEEK_SIZE (1 << 16) // number of seek entries
+#define MPC_FRAME_LENGTH (36 * 32)
+#define MAX_FRAME_SIZE 4352
 
 typedef struct {
@@ -45,9 +40,10 @@
 	mpc_uint64_t outputBits; // Counter for the number of written bits in the bitstream
 	mpc_uint32_t bitsBuff; // bits buffer
-	mpc_uint8_t buffer [BUFFER_FULL]; // Buffer for bitstream-file
-	mpc_uint_t framesInBlock;
+	mpc_uint8_t * buffer; // Buffer for bitstream-file
+	mpc_uint_t framesInBlock; // Number of frames in current block
+	mpc_uint_t frames_per_block_pwr; // Number of frame in a block = 1 << frames_per_block_pwr
 
 	// seeking
-	mpc_uint32_t seek_table[SEEK_SIZE];
+	mpc_uint32_t * seek_table;
 	mpc_uint32_t seek_pos; /// current position in the seek table
 	mpc_uint32_t seek_ref; /// reference position for the seek information
@@ -74,5 +70,9 @@
  } mpc_encoder_t;
 
- void         Init_SV8             ( mpc_encoder_t* );
+ void mpc_encoder_init ( mpc_encoder_t * e,
+						 mpc_uint64_t SamplesInWAVE,
+						 unsigned int FramesBlockPwr,
+						 unsigned int SeekDistance );
+ void mpc_encoder_exit ( mpc_encoder_t * e );
  void writeStreamInfo ( mpc_encoder_t*e,
 						const unsigned int  MaxBand,
Index: /libmpc/branches/r2d/mpc2sv8/mpc2sv8.c
===================================================================
--- /libmpc/branches/r2d/mpc2sv8/mpc2sv8.c	(revision 225)
+++ /libmpc/branches/r2d/mpc2sv8/mpc2sv8.c	(revision 226)
@@ -102,5 +102,5 @@
     mpc_demux_get_info(demux,  &si);
 
-	Init_SV8 (&e);
+	mpc_encoder_init(&e, si.samples, 6, 1);
 	e.outputFile = fopen( argv[2], "w+b" );
 	e.MS_Channelmode = si.ms;
@@ -180,4 +180,5 @@
 	mpc_demux_exit(demux);
 	mpc_reader_exit_stdio(&reader);
+	mpc_encoder_exit(&e);
 
 	return MPC_STATUS_OK;
Index: /libmpc/branches/r2d/mpcenc/config.h
===================================================================
--- /libmpc/branches/r2d/mpcenc/config.h	(revision 225)
+++ /libmpc/branches/r2d/mpcenc/config.h	(revision 226)
@@ -32,5 +32,5 @@
 
 #define MPCENC_MAJOR 1
-#define MPCENC_MINOR 17
+#define MPCENC_MINOR 19
 #define MPCENC_BUILD 0
 
Index: /libmpc/branches/r2d/mpcenc/mpcenc.c
===================================================================
--- /libmpc/branches/r2d/mpcenc/mpcenc.c	(revision 225)
+++ /libmpc/branches/r2d/mpcenc/mpcenc.c	(revision 226)
@@ -47,5 +47,9 @@
 unsigned int  verbose         = 0;      // more information during output
 unsigned int  NoUnicode       = 1;      // console is unicode or not (tag translation)
-mpc_uint64_t    SamplesInWAVE   = 0;      // number of samples per channel in the WAV file
+unsigned int  NoEncoderInfo   = 0;      // write encoder info block or not
+unsigned int  NoSeekTable     = 0;      // write seek table block or not
+unsigned int  FramesBlockPwr  = 6;      // must be even : frames_per_block = 1 << FramesBlockPwr
+unsigned int  SeekDistance    = 1;      // keep a seek table entry every 2^SeekDistance block
+mpc_uint64_t  SamplesInWAVE   = 0;      // number of samples per channel in the WAV file
 float         MaxOverFlow     = 0.f;    // maximum overflow
 float         ScalingFactorl  = 1.f;    // Scaling the input signal
@@ -194,4 +198,12 @@
              "  above braindead  (--quality 10.00)  excellent quality     (~ 350 kbps)\n"
              "\n" );
+
+	stderr_printf (
+			"\033[1m\rBitstream formating:\033[0m\n"
+			"  --no_ei           do not write encoder information packet   (dflt: off)\n"
+			"  --no_st           do not write the seek table               (dflt: off)\n"
+			"  --num_frames x    x = 0..7 number of frames in packet = 4^x (dflt: 3)\n"
+			"  --seek_distance x x = 0..15 keep a seek table entry every 2^x audio packet (dflt: 1)\n"
+			"\n" );
 
     stderr_printf (
@@ -1030,5 +1042,19 @@
         else if ( 0 == strcmp ( arg, "unicode") ) {                                  // no tag conversion
             NoUnicode = 0;
-        }
+		}
+		else if ( 0 == strcmp ( arg, "no_ei") ) {                                  // no encoder info block
+			NoEncoderInfo = 1;
+		}
+		else if ( 0 == strcmp ( arg, "no_st") ) {                                  // no seek table
+			NoSeekTable = 1;
+		}
+		else if ( 0 == strcmp ( arg, "num_frames") ) {
+			if ( ++k >= argc ) { stderr_printf ( errmsg, arg ); return -1; }
+			FramesBlockPwr = atoi (argv[k]) * 2;
+		}
+		else if ( 0 == strcmp ( arg, "seek_distance") ) {
+			if ( ++k >= argc ) { stderr_printf ( errmsg, arg ); return -1; }
+			SeekDistance = atoi (argv[k]);
+		}
         else if ( 0 == strcmp ( arg, "lowdelay") ) {
             LowDelay = 1;
@@ -1518,5 +1544,4 @@
 	Init_Psychoakustik (&m);
 	Init_FPU ();
-	Init_SV8 (&e);
 
     // initialize PCM-data
@@ -1575,4 +1600,5 @@
     }
 
+	mpc_encoder_init (&e, SamplesInWAVE, FramesBlockPwr, SeekDistance);
     Init_Psychoakustiktabellen (&m);              // must be done AFTER decoding command line parameters
 
@@ -1610,11 +1636,14 @@
 	writeGainInfo ( &e, 0, 0, 0, 0);
 	writeBlock(&e, "RG", MPC_FALSE, 0);
-	writeEncoderInfo(&e, m.FullQual, m.PNS > 0, MPCENC_MAJOR, MPCENC_MINOR,
-					  MPCENC_BUILD);
-	writeBlock(&e, "EI", MPC_FALSE, 0);
-	e.seek_ptr = ftell(e.outputFile);
-	writeBits (&e, 0, 8);
-	writeBits (&e, 0, 32); // jump 40 bits for seek table pointer
-	writeBlock(&e, "SO", MPC_FALSE, 0); // reserve space for seek offset
+	if (NoEncoderInfo == 0) {
+		writeEncoderInfo(&e, m.FullQual, m.PNS > 0, MPCENC_MAJOR, MPCENC_MINOR, MPCENC_BUILD);
+		writeBlock(&e, "EI", MPC_FALSE, 0);
+	}
+	if (NoSeekTable == 0) {
+		e.seek_ptr = ftell(e.outputFile);
+		writeBits (&e, 0, 8);
+		writeBits (&e, 0, 32); // jump 40 bits for seek table pointer
+		writeBlock(&e, "SO", MPC_FALSE, 0); // reserve space for seek offset
+	}
 
 
@@ -1723,6 +1752,8 @@
 		writeBlock(&e, "AP", MPC_FALSE, 0);
 	}
-	writeSeekTable(&e);
-	writeBlock(&e, "ST", MPC_FALSE, 0); // write seek table block
+	if (NoSeekTable == 0) {
+		writeSeekTable(&e);
+		writeBlock(&e, "ST", MPC_FALSE, 0); // write seek table block
+	}
 	writeBlock(&e, "SE", MPC_FALSE, 0); // write end of stream block
 
@@ -1741,4 +1772,5 @@
     fclose ( e.outputFile );
     fclose ( Wave.fp );
+	mpc_encoder_exit(&e);
 
     if ( DelInput == 0xAFFEDEAD  &&  remove (InputName) == -1 )         // delete input file if DelInput is active
