Index: libmpc/branches/r2d/libmpcenc/bitstream.c
===================================================================
--- libmpc/branches/r2d/libmpcenc/bitstream.c	(revision 142)
+++ libmpc/branches/r2d/libmpcenc/bitstream.c	(revision 147)
@@ -70,4 +70,17 @@
 }
 
+static void encodeGolomb(mpc_encoder_t * e, mpc_uint32_t nb, mpc_uint_t k)
+{
+	unsigned int l = (nb >> k) + 1;
+	nb &= (1 << k) - 1;
+
+	while( l > 32 ){
+		writeBits(e, 0, 32);
+		l -= 32;
+	}
+	writeBits(e, 1, l);
+	writeBits(e, nb, k);
+}
+
 void writeMagic(mpc_encoder_t * e)
 {
@@ -121,3 +134,43 @@
 }
 
+void writeSeekTable (mpc_encoder_t * e)
+{
+	mpc_uint32_t tmp1, tmp2, i, len;
+	mpc_uint32_t * table = e->seek_table;
+	mpc_uint8_t tmp[10];
+
+	// write the position to header
+	tmp1 = ftell(e->outputFile); // get the seek table position
+	tmp[0] = (mpc_uint8_t) (tmp1 >> 24);
+	tmp[1] = (mpc_uint8_t) (tmp1 >> 16);
+	tmp[2] = (mpc_uint8_t) (tmp1 >> 8);
+	tmp[3] = (mpc_uint8_t) tmp1;
+	fseek(e->outputFile, e->seek_ref + 3, SEEK_SET);
+	fwrite(tmp, sizeof(mpc_uint8_t), 4, e->outputFile);
+	fseek(e->outputFile, tmp1, SEEK_SET);
+
+	tmp1 = table[0];
+	tmp2 = table[1];
+
+	len = encodeSize(tmp1 - e->seek_ref, tmp, MPC_FALSE);
+	for( i = 0; i < len; i++)
+		writeBits ( e, tmp[i], 8 );
+	len = encodeSize(tmp2 - e->seek_ref, tmp, MPC_FALSE);
+	for( i = 0; i < len; i++)
+		writeBits ( e, tmp[i], 8 );
+
+	for( i = 2; i < e->seek_pos; i++){
+		int code = table[i] - 2 * tmp2 + tmp1;
+		tmp1 = tmp2;
+		tmp2 = table[i];
+		if (code >= 0) {
+			writeBits(e, 0, 1);
+			encodeGolomb(e, code, 10);
+		} else {
+			writeBits(e, 1, 1);
+			encodeGolomb(e, -code, 10);
+		}
+	}
+}
+
 /* end of bitstream.c */
Index: libmpc/branches/r2d/libmpcenc/encode_sv7.c
===================================================================
--- libmpc/branches/r2d/libmpcenc/encode_sv7.c	(revision 142)
+++ libmpc/branches/r2d/libmpcenc/encode_sv7.c	(revision 147)
@@ -75,4 +75,5 @@
 	e->bitsBuff = 0;
 	e->Overflows = 0;
+	e->seek_pos = 0;
 }
 
@@ -415,6 +416,9 @@
 
 	e->framesInBlock++;
-	if (e->framesInBlock == FRAMES_PER_BLOCK)
+	if (e->framesInBlock == FRAMES_PER_BLOCK) {
+		e->seek_table[e->seek_pos] = ftell(e->outputFile);
+		e->seek_pos++;
 		writeBlock(e, "AD", MPC_FALSE);
+	}
 }
 
Index: libmpc/branches/r2d/libmpcenc/libmpcenc.h
===================================================================
--- libmpc/branches/r2d/libmpcenc/libmpcenc.h	(revision 142)
+++ libmpc/branches/r2d/libmpcenc/libmpcenc.h	(revision 147)
@@ -32,11 +32,11 @@
 #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
+
 typedef struct {
 	unsigned int  L [36];
 	unsigned int  R [36];
 } SubbandQuantTyp;
-
-// TODO : enc/dec common struct
-// just the same struct as below, dup ?
 
 typedef struct {
@@ -53,4 +53,9 @@
 	mpc_uint_t framesInBlock;
 
+	// seeking
+	mpc_uint32_t seek_table[SEEK_SIZE];
+	mpc_uint32_t seek_pos; /// current position in the seek table
+	mpc_uint32_t seek_ref; /// reference position for the seek information
+
 	FILE * outputFile; // ouput file
 
