[MPlayer-G2-dev] CVS: g2/demux demux_nut.c,1.1.1.1,1.2

Alex Beregszaszi syncmail at mplayerhq.hu
Sat Jan 31 23:31:28 CET 2004


CVS change done by Alex Beregszaszi

Update of /cvsroot/mplayer/g2/demux
In directory mail:/var2/tmp/cvs-serv19875

Modified Files:
	demux_nut.c 
Log Message:
support for timestamp shift

Index: demux_nut.c
===================================================================
RCS file: /cvsroot/mplayer/g2/demux/demux_nut.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- demux_nut.c	31 Jan 2004 20:16:18 -0000	1.1.1.1
+++ demux_nut.c	31 Jan 2004 22:31:25 -0000	1.2
@@ -1,5 +1,5 @@
 /*
- * "NUT" Container Format demuxer (DRAFT-20031003)
+ * "NUT" Container Format demuxer (DRAFT-20031102)
  * Copyright (C) 2002 Alex Beregszaszi
  *
  * This library is free software; you can redistribute it and/or modify
@@ -48,7 +48,8 @@
     int last_frame_size;
     demux_stream_t* audio;
     demux_stream_t* video;
-    int msb_timestamp_shift;
+    int msb_timestamp_shift[256]; // FIXME!!
+    int64_t last_msb_timestamp[256]; // FIXME!!
 };
 
 #define     MAIN_STARTCODE (0xF9526A6200000000ULL + ('N'<<24) + ('U'<<16) + ('T'<<8) + 'M')
@@ -115,7 +116,7 @@
             data[i] = stream_read_char(s);
     stream_skip(s, len-i);
 
-    return 0;
+    return len;
 }
 
 static int get_packetheader(demuxer_t *demuxer)
@@ -191,8 +192,7 @@
 static int driver_fill(demuxer_t *demuxer, demux_stream_t* ds){
     struct demuxer_priv_s *priv = demuxer->priv;
     int key_frame = 0, id, len, flags;
-    uint64_t ptype;
-    int64_t pts = 0;
+    uint64_t ptype, pts = 0;
 
 start:
     demuxer->filepos = stream_tell(demuxer->stream);
@@ -209,7 +209,8 @@
 	get_packetheader(demuxer);
 	do {
 	    char data[32];
-	    int hdr = 0;
+	    int hdr = 0, len;
+
 	    i = get_v(demuxer->stream);	
 	    switch(i)
 	    {
@@ -220,11 +221,12 @@
 		case 9:	hdr = DEMUX_META_STRING_SOFTWARE;	break;
 		default:
 	    }
-	    get_b(demuxer->stream, &data, 32);
+	    len = get_b(demuxer->stream, &data, 32);
+	    data[len-1] = 0;
 	    if (hdr)
 		demux_metadata_add(&demuxer->meta, hdr, data, -1, 1);
 	} while ((i != 0) && !stream_eof(demuxer->stream));
-	stream_skip(demuxer->stream, 4);
+	stream_skip(demuxer->stream, 4); /* checksum */
 	goto start;
     }
     if ((ptype != KEYFRAME_STARTCODE) && (ptype != 0))
@@ -248,11 +250,18 @@
     get_packetheader(demuxer);
     id = get_v(demuxer->stream);
     if ((flags & 0x8) >> 3) /* msb timestamp */
-	pts = get_v(demuxer->stream) << priv->msb_timestamp_shift;
-    pts |= get_s(demuxer->stream);
+	priv->last_msb_timestamp[id] = get_v(demuxer->stream) << priv->msb_timestamp_shift[id];
+#ifdef DEBUG
+    printf("timestamp last msb: %llx shift: %d\n",
+	priv->last_msb_timestamp[id], priv->msb_timestamp_shift[id]);
+#endif
+//    pts = priv->last_msb_timestamp[id] + get_v(demuxer->stream);
+    pts = get_v(demuxer->stream);
+//    printf("pts: %x\n", pts);
+    pts += priv->last_msb_timestamp[id];
     len = priv->curr_frame_size - (stream_tell(demuxer->stream) - priv->curr_frame_start);
 #ifdef DEBUG
-    printf("%srame flags: %d, id: %d, len: %d, pts: %lld\n",
+    printf("%srame flags: %d, id: %d, len: %d, pts: %x\n",
 	(key_frame) ? "Keyf" : "F", flags, id, len, pts);
 #endif
     
@@ -264,7 +273,9 @@
     else if (len && !stream_eof(demuxer->stream))
     {
 	if (ds && !ds->ignore)
-	    ds_read_packet(ds, demuxer->stream, len, pts, demuxer->filepos, key_frame?1:0);
+	{
+	    ds_read_packet(ds, demuxer->stream, len, (int)pts, demuxer->filepos, (key_frame?1:0));
+	}
 	else
 	    stream_skip(demuxer->stream, len);
     }
@@ -284,7 +295,7 @@
 
     if (search_packet(demuxer->stream, 8192, MAIN_STARTCODE) < 0)
     {
-	printf("Couldn't find main header!\n");
+//	printf("Couldn't find main header!\n");
 	return 0;
     }
     
@@ -325,7 +336,7 @@
 	rate = get_v(demuxer->stream);
 	rate_base = get_v(demuxer->stream);
 	printf("rate: (m) %d, base: (d) %d\n", rate, rate_base);
-	demuxer->priv->msb_timestamp_shift = get_v(demuxer->stream);
+	demuxer->priv->msb_timestamp_shift[id] = get_v(demuxer->stream);
 	get_v(demuxer->stream); /* shuffle type */
 	stream_skip(demuxer->stream, 1); /* flags */
 




More information about the MPlayer-G2-dev mailing list