[MPlayer-dev-eng] Re: mpeg muxer & dvd pack scr

Tobias Diedrich ranma at tdiedrich.de
Sat Jul 16 06:29:39 CEST 2005


Tobias Diedrich wrote:

> Looking at the code, it seems that the muxer uses the same reference
> clock for both audio/video and the pack headers, which is wrong
> AFAICT (and explains why the first two packs have the same scr).
> It also does not write the scr extension even though it has an extra
> function for writing mpeg2 scr.

This should fix it (Or at least does for my test-case):

Index: muxer_mpeg.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/muxer_mpeg.c,v
retrieving revision 1.18
diff -u -r1.18 muxer_mpeg.c
--- muxer_mpeg.c	10 Jul 2005 08:36:39 -0000	1.18
+++ muxer_mpeg.c	16 Jul 2005 04:28:51 -0000
@@ -494,7 +494,9 @@
 
 static void write_mpeg2_scr(unsigned char *b, uint64_t ts) 
 {
-	uint16_t t1, t2, t3;
+	uint16_t t1, t2, t3, t4;
+
+	t4 = ((ts & 0x3ff) * 300) >> 10;
 	ts >>= 10;
 	ts &= 0x1FFFFFFFFULL;	//33 bits, no extension; input must be * 92160000
 	t1 = (ts >> 30) & 0x7;;
@@ -505,8 +507,8 @@
 	b[1] = (t2 >> 5);
 	b[2] = (t2 & 0x1f) << 3 | 0x4 | ((t3 >> 13) & 0x3);
 	b[3] = (t3 >> 5);
-	b[4] = (t3 & 0x1f) << 3 | 0x4;
-	b[5] = 1;
+	b[4] = (t3 & 0x1f) << 3 | 0x4 | (t4 >> 7);
+	b[5] = (t4 << 1) | 1;
 }
 
 
@@ -525,7 +527,8 @@
 	}
 	else
 	{
-		write_mpeg2_scr(&buff[4], priv->scr); // 0010 and SCR
+		uint64_t scr = (uint64_t) muxer->movi_end * 92160000 / muxer->sysrate;
+		write_mpeg2_scr(&buff[4], scr); // 0010 and SCR
 		write_mpeg_rate(priv->mux, &buff[10], muxer->sysrate);
 		buff[13] = 0xf8; //5 bits reserved + 3 set to 0 to indicate 0 stuffing bytes 
 		len = 14;


-- 
Tobias						PGP: http://9ac7e0bc.uguu.de




More information about the MPlayer-dev-eng mailing list