[MPlayer-dev-eng] NUT cleanup

Oded Shimon ods15 at ods15.dyndns.org
Fri Sep 9 00:17:20 CEST 2005


On Tue, Sep 06, 2005 at 06:10:14PM +0200, Michael Niedermayer wrote:
> Hi
> 
> On Tue, Sep 06, 2005 at 01:20:30PM +0300, Oded Shimon wrote:
> [...]
> > This is all that's left that you haven't ok'ed... ok this stuff, anf I'll 
> > apply the patch:
> > (this is NOT a valid patch, just chunks from the previous patch...)
> 
> [...]

This patch addresses I think everything. It also includes the new MN dts 
rule...
Please comment, as I'll commit this patch soon...

- ods15
-------------- next part --------------
--- ../main/DOCS/tech/mpcf.txt	2005-06-19 12:17:44.000000000 +0300
+++ mpcf.txt	2005-09-09 01:09:43.000000000 +0300
@@ -126,7 +126,7 @@
 	for(i=0; i<256; ){
 		tmp_flag			v
 		tmp_fields			v
-		if(tmp_fields>0) tmp_timestamp	s
+		if(tmp_fields>0) tmp_pts	s
 		if(tmp_fields>1) tmp_mul	v
 		if(tmp_fields>2) tmp_stream	v
 		if(tmp_fields>3) tmp_size	v
@@ -143,7 +143,7 @@
 			stream_id_plus1[i]= tmp_stream;
 			data_size_mul[i]= tmp_mul;
 			data_size_lsb[i]= tmp_size + j;
-			timestamp_delta[i]= tmp_timestamp;
+			pts_delta[i]= tmp_pts;
 			reserved_count[i]= tmp_res;
 		}
 	}
@@ -156,10 +156,9 @@
 	stream_id				v
 	stream_class				v
 	fourcc					vb
-	average_bitrate				v
 	time_base_nom				v
 	time_base_denom				v
-	msb_timestamp_shift			v
+	msb_pts_shift				v
 	decode_delay				v
 	fixed_fps				u(1)
 	reserved				u(6)
@@ -183,6 +182,11 @@
 	reserved_bytes
 	checksum				u(32)
 
+other_stream_header:
+	stream_header
+	reserved_bytes
+	checksum				u(32)
+
 		Basic Packets:
  
 frame:
@@ -190,8 +194,8 @@
 	if(stream_id_plus1[frame_code]==0){
 		stream_id			v
 	}
-	if(timestamp_delta[frame_code]==0){
-		coded_timestamp			v
+	if(pts_delta[frame_code]==0){
+		coded_pts			v
 	}
 	if(flags[frame_code]&1){
 		data_size_msb			v
@@ -204,9 +208,10 @@
 	index_startcode				f(64)
 	packet header
 	stream_id				v
+	max_pts					v
 	index_length				v
 	for(i=0; i<index_length; i++){
-		index_timestamp			v
+		index_pts			v
 		index_position			v
 	}
 	reserved_bytes
@@ -245,8 +250,10 @@
 		for(i=0; i<stream_count; i++){
 			if(next_packet==video_stream_header)
 				video_stream_header
-			else
+			else if(next_packet==audio_stream_header)
 				audio_stream_header
+			else
+				other_stream_header
 		}
 		while(next_code != main_startcode){
 			if(next_code == info_startcode)
@@ -258,16 +265,19 @@
 			}
 		}
 	}
-	index
-                
+	if (next_code == index_startcode){
+		while(!eof){
+			index
+		}
+		index_ptr			u(64)
+	}
 
 
 			Tag description:
 
 forward_ptr
-	size of the packet (exactly the distance from the first byte of the
-	startcode of the current packet to the first byte of the following
-	packet
+	size of the packet data (exactly the distance from the first byte
+	after the forward_ptr to the first byte of the next packet)
 
 file_id_string
 	"nut/multimedia container\0"
@@ -313,11 +323,8 @@
 	SHOULD be set to <=32768 or at least <=65536 unless there is a very
 	good reason to set it higher
 
-stream_id[FIXME]
+stream_id
 	Stream identifier
-	Note: streams with a lower relative class MUST have a lower relative id
-	so a stream with class 0 MUST always have an id which is lower than any
-	stream with class > 0
 	stream_id MUST be < stream_count
 
 stream_class
@@ -335,45 +342,38 @@
 	if needed
 
 time_base_nom / time_base_denom = time_base
-	the number of timer ticks per second, this MUST be equal to the fps
+	the length of a timer tick in seconds, this MUST be equal to the 1/fps
 	if the fixed_fps is 1
-	time_base_denom MUST NOT be 0
+	time_base_nom and time_base_denom MUST NOT be 0
 	time_base_nom and time_base_denom MUST be relatively prime
-	time_base_nom MUST be < 2^31
+	time_base_denom MUST be < 2^31
 	examples:
         	fps	time_base_nom	time_base_denom
-		30	30		1
-		29.97	30000		1001
-		23.976	24000		1001
-		sample_rate	sample_rate_mul	time_base_nom	time_base_denom
-		44100		1		44100		1
-		44100		64		11025		16 
-		48000		1024		375		8  
-
-		Note: the advantage to using a large sample_rate_mul is that
-		the timestamps need fewer bits
+		30	1		30
+		29.97	1001		30000
+		23.976	1001		24000
 
 global_time_base_nom / global_time_base_denom = global_time_base
-	the number of timer ticks per second
-	global_time_base_denom MUST NOT be 0
+	the length of a timer tick in seconds
+	global_time_base_nom and global_time_base_denom MUST NOT be 0
 	global_time_base_nom and global_time_base_denom MUST be relatively prime
-	global_time_base_nom MUST be < 2^31
+	global_time_base_denom MUST be < 2^31
 
 global_timestamp
 	timestamp in global_time_base units
-	when a global_timestamp is encountered the last_timestamp of all
+	when a global_timestamp is encountered the last_pts of all
 	streams is set to the following:
 	
-	ln= global_time_base_denom*time_base_nom
+	ln= global_time_base_nom*time_base_denom
 	sn= global_timestamp
-	d1= global_time_base_nom
-	d2= time_base_denom
-	last_timestamp= (ln/d1*sn + ln%d1*sn/d1)/d2
+	d1= global_time_base_denom
+	d2= time_base_nom
+	last_pts= (ln/d1*sn + ln%d1*sn/d1)/d2
 	Note: this calculation MUST be done with unsigned 64 bit integers, and 
 	is equivalent to (ln*sn)/(d1*d2) but this would require a 96bit integer
 
-msb_timestamp_shift
-	amount of bits in lsb_timestamp
+msb_pts_shift
+	amount of bits in lsb_pts
 	MUST be <16
 
 decode_delay
@@ -416,47 +416,46 @@
 data_size_lsb[frame_code]
 	must be <16384
 
-timestamp_delta[frame_code]
+pts_delta[frame_code]
 	must be <16384 and >-16384
 
 data_size       
 	data_size= data_size_lsb + data_size_msb*data_size_mul;
 
-coded_timestamp
-	if coded_timestamp < (1<<msb_timestamp_shift) then it is an lsb
-	timestamp, otherwise it is a full timestamp + (1<<msb_timestamp_shift)
-	lsb timestamps are converted to full timesamps by:
-	mask = (1<<msb_timestamp_shift)-1;
-	delta= last_timestamp - mask/2
-	timestamp= ((timestamp_lsb-delta)&mask) + delta
-	a full timestamp MUST be used if there is no reference timestamp
-	available after the last frame_startcode with the current stream_id
+coded_pts
+	if coded_pts < (1<<msb_pts_shift) then it is an lsb
+	pts, otherwise it is a full pts + (1<<msb_pts_shift)
+	lsb pts is converted to a full pts by:
+	mask = (1<<msb_pts_shift)-1;
+	delta= last_pts - mask/2
+	pts= ((pts_lsb-delta)&mask) + delta
         
-lsb_timestamp
-	least significant bits of the timestamp in time_base precision
+lsb_pts
+	least significant bits of the pts in time_base precision
         Example: IBBP display order
-		keyframe timestamp=0                     -> timestamp=0
-		frame                    lsb_timestamp=3 -> timestamp=3
-		frame                    lsb_timestamp=1 -> timestamp=1
-		frame                    lsb_timestamp=2 -> timestamp=2
+		keyframe pts=0                     -> pts=0
+		frame                    lsb_pts=3 -> pts=3
+		frame                    lsb_pts=1 -> pts=1
+		frame                    lsb_pts=2 -> pts=2
 		...
-		keyframe msb_timestamp=257               -> timestamp=257
-		frame                    lsb_timestamp=255->timestamp=255
-		frame                    lsb_timestamp=0 -> timestamp=256
-		frame                    lsb_timestamp=4 -> timestamp=260
-		frame                    lsb_timestamp=2 -> timestamp=258
-		frame                    lsb_timestamp=3 -> timestamp=259
-	all timestamps of keyframes of a single stream MUST be monotone
+		keyframe msb_pts=257               -> pts=257
+		frame                    lsb_pts=255->pts=255
+		frame                    lsb_pts=0 -> pts=256
+		frame                    lsb_pts=4 -> pts=260
+		frame                    lsb_pts=2 -> pts=258
+		frame                    lsb_pts=3 -> pts=259
+	all pts's of keyframes of a single stream MUST be monotone
 
 dts
 	dts is calculated by using a decode_delay+1 sized buffer for each 
 	stream, into which the current pts is inserted and the element with
 	the smallest value is removed, this is then the current dts
 	this buffer is initalized with decode_delay -1 elements
-	all frames with dts == timestamp must be monotone, that means a frame
-	which occures later in the stream must have a larger or equal dts
-	than an earlier frame
-	FIXME rename timestamp* to pts* ?
+	All timestamps must satisfy a monotonicity condition: if I and J
+	are two frames, not necessarily from the same stream, and I
+	precedes J in the bitstream, then the _decode_ timestamp of I must
+	be less than or equal to the _presentation_ timestamp of J,
+	compared in a common time base.
 
 width/height
 	MUST be set to the coded width/height
@@ -478,9 +477,15 @@
 
 checksum
 	adler32 checksum
+	checksum is calculated for the area pointed to by forward_ptr not
+	including the checksum itself (from first byte after the
+	forward_ptr until last byte before the checksum).
 
-index_timestamp
-	value of the timestamp of a keyframe relative to the last keyframe
+max_pts
+	The highest pts in the stream.
+
+index_pts
+	value of the pts of a keyframe relative to the last keyframe
 	stored in this index
 
 index_position
@@ -490,6 +495,11 @@
 	2 consecutive index entries if they are more than max_index_distance
 	apart
 
+index_ptr
+	Length in bytes from the first byte of the first index startcode
+	to the first byte of the index_ptr. If there is no index, index_ptr
+	MUST NOT be written.
+
 id
 	the id of the type/name pair, so it's more compact
 	0 means end
@@ -573,15 +583,13 @@
 the index or at the file end if there is no index
 headers MUST be repeated at least twice (so they exist 3 times in a file)
 
-a demuxer MUST NOT demux a stream which contains more than one stream, or which
-is wrapped in a structure to facilitate more than one stream or otherwise 
-duplicate the role of a container. any such file is to be considered invalid
-
 info packets which describe the whole file or individual streams/tracks MUST be
 placed before any video/audio/... frames
 
 		Index
 Note: with realtime streaming, there is no end, so no index there either
+An index SHOULD be written for every stream. Indices MUST be placed at end
+of file. Indices MAY be repeated for a stream.
 
 		Info packets
 the info_packet can be repeated, and can also contain different names & values
@@ -601,6 +609,15 @@
 headers starting at offset 2^x for each x players SHOULD end their search from
 a particular offset when any startcode is found (including syncpoint)
 
+			Semantic requirements
+
+If more than one stream of a given stream class is present, each one MUST
+have info tags specifying disposition, and if applicable, language.
+
+A demuxer MUST NOT demux a stream which contains more than one stream, or which
+is wrapped in a structure to facilitate more than one stream or otherwise
+duplicate the role of a container. any such file is to be considered invalid.
+
 
 			Sample code (GPL, & untested)
 
@@ -692,3 +709,4 @@
     Gereoffy, Arpad (arpi at thot.banki.hu)
     Hess, Andreas (jaska at gmx.net)
     Niedermayer, Michael (michaelni at gmx.at)
+    Shimon, Oded (ods15 at ods15.dyndns.org)


More information about the MPlayer-dev-eng mailing list