[NUT-devel] info packets/frames
Oded Shimon
ods15 at ods15.dyndns.org
Thu Feb 16 07:01:38 CET 2006
On Thu, Feb 16, 2006 at 12:27:22AM +0100, Michael Niedermayer wrote:
> Hi
>
> On Wed, Feb 15, 2006 at 08:05:19PM +0200, Oded Shimon wrote:
> > On Wed, Feb 15, 2006 at 05:46:37PM +0100, Michael Niedermayer wrote:
> > > On Wed, Feb 15, 2006 at 05:14:25PM +0200, Oded Shimon wrote:
> > > > This may be a question of opinion, but IMO "producor/author/title" etc.
> > > > still apply to all streams/entire file, and then maybe you have a packet
> > > > applied to the subtitle stream. Infact, "director" makes no sense to apply
> > > > to any stream, it's not a video thing or audio thing, it's a movie (as in,
> > > > entire file) thing. But I do see your point, do you have a suggestion for
> > > > how to code it? (in stream, using vlc's. not in C code :)
> > > > Maybe a bitmask? 0 meaning all streams?
> > >
> > > hmmmmmm, what about
> > >
> > > decompress_element(a, i, count)
> > > type v
> > > x= type>>1;
> > > if(type&1){
> > > x>>=1
> > > while(x--)
> > > a[i++] = !!(type&2)
> > > a[i++] = !(type&2);
> > > }else{
> > > while(x != 1){
> > > a[i++] = x&1;
> > > x>>=1;
> > > }
> > > }
> > > return i
> >
> > Warning: `count' unused parameter. :) Maybe you meant to put the loop here?
> >
> > > and then use this for both the index (we aleady do ...) and info packets
> > >
> > > info_packet
> > > for(i=0; i<stream_count; )
> > > i= decompress_element(streams, i, stream_count)
> >
> > I dislike it. For this purpose, a pure bitmask with special case 0 is good
> > enough... It's not quite a complication but it is simply not worth it...
> > (bitmask has the slight disadvantage of overflowing, but seriously, 64
> > streams... Worst pathological scenario I can think of is 30 streams, 20
> > subtitles and 10 audio tracks)
>
> a limitation to 30-60 streams is not acceptable
It's just a implementation limitation, not a spec one, but anyway, see new
patch.
> > > > > just store the f* table in the main header :)
> > > >
> > > > Bleh. :) It's a nice solution, but it's somewhat bad in that it adds info
> > > > stuff in essential, small, main header (slightly defeating the purpose).
> > > > Also it makes it harder for us to enforce our premade headers... (utf-8,
> > > > etc.)
> > >
> > > we cant enforce that anyway, just becaue it has utf-8 as type doensnt mean
> > > it is utf8, if someone decides to ignore a rule in the spec which says only
> > > utf-8 allowed, then he will care little about the type being enforced to utf-8
> > > actually later is worse as its undetectable, so IMHO better give "them" an
> > > option to specify that they violate the rules instead of making it impossible
> > > to specify the type while obviously not preventing them from storing things
> > > in their native encoding ...
> >
> > That's somewhat a good point, but still not excuse enough IMO to put the
> > info types in the main header, it literally defeats the purpose - info
> > stuff goes in info packets, not in main headers...
>
> then my vote is to simply not allow extending the table, its not needed
> anyway to add new fields to info packets
>
> you either have a fixed table or you store the table in the file
Is the problem old programs not understanding new fields? It's not a big
issue IMO...
Main difference in this patch is "type" is only for binary data. I couldn't
decide an elegant way to design the table to accomodate this though...
- ods15
-------------- next part --------------
Index: DOCS/tech/mpcf.txt
===================================================================
RCS file: /cvsroot/mplayer/main/DOCS/tech/mpcf.txt,v
retrieving revision 1.105
diff -u -r1.105 mpcf.txt
--- DOCS/tech/mpcf.txt 13 Feb 2006 07:29:11 -0000 1.105
+++ DOCS/tech/mpcf.txt 16 Feb 2006 05:59:12 -0000
@@ -98,6 +98,7 @@
data[i] u(8)
}
[Note: strings MUST be encoded in UTF-8]
+ [Note: strings MUST NOT be encoded with their terminating NUL]
vb (variable length binary data or string)
length v
@@ -122,6 +123,24 @@
impossible to add new fields at the end of packets in the future
in a compatible way]
+compressed_bitmask(bitmask, index):
+ x v
+ type= x & 1
+ x>>=1
+ if(type){
+ flag= x & 1
+ x>>=1
+ while(x--)
+ bitmask[index++]=flag
+ bitmask[index++]=!flag;
+ }else{
+ while(x != 1){
+ bitmask[index++]=x&1;
+ x>>=1;
+ }
+ }
+ return index;
+
Headers:
main header:
@@ -240,24 +259,9 @@
for(i=0; i<stream_count; i++){
last_pts= -1
for(j=0; j<syncpoints; ){
- x v
- type= x & 1
- x>>=1
- n=j
- if(type){
- flag= x & 1
- x>>=1
- while(x--)
- has_keyframe[n++][i]=flag
- has_keyframe[n++][i]=!flag;
- }else{
- while(x != 1){
- has_keyframe[n++][i]=x&1;
- x>>=1;
- }
- }
+ n= compressed_bitmask(has_keyframe[i],j)
for(; j<n && j<syncpoints; j++){
- if (!has_keyframe[j][i]) continue
+ if (!has_keyframe[i][j]) continue
A v
if(!A){
A v
@@ -275,21 +279,30 @@
checksum u(32)
info_frame: (optional)
- for(;;){
+ for(i=0; i<stream_count; )
+ i= compressed_bitmask(info_stream_mask, i)
+ items v
+ for(i=0; i<items; i++){
id v
- if(id==0) break
- name= info_table[id][0]
- type= info_table[id][1]
- if(type==NULL)
- type vb
- if(name==NULL)
- name vb
- if(type=="v")
- value v
- else if(type=="s")
+ code= id&3
+ index= id>>2
+ name= info_table[code][index][0]
+ if(name==NULL) name vb
+ if(code==0) {
value s
- else
+ } else if(code==1) {
+ nom s
+ denom v
+ value= nom/denom
+ } else if(code==2) {
+ mantissa s
+ exponent s
+ value= mantissa*pow(2,exp)
+ } else {
+ if(index) type= info_table[code][index][1]
+ else type vb
value vb
+ }
}
reserved_bytes
checksum u(32)
@@ -613,9 +626,11 @@
EOF, as index_ptr will always be 12 bytes before the end of file if
there is an index at all.
+info_stream_mask
+ Bit mask saying which which stream(s) this info packet reffers to.
+
id
the ID of the type/name pair, so it is more compact
- 0 means end
type
for example: "UTF8" -> string or "JPEG" -> JPEG image
@@ -624,8 +639,6 @@
info packet types
the name of the info entry, valid names are
- "StreamId"
- the stream(s) to which the info packet applies
"Author"
"Description"
"Copyright"
@@ -644,8 +657,8 @@
(ISO 8601 format, see http://www.cl.cam.ac.uk/~mgk25/iso-time.html)
Note: do not forget the timezone
"Keywords"
- "TotalTime"
- total length of the stream in msecs
+ "TrackTime"
+ length of a track/chapter in seconds
"Language"
ISO 639 and ISO 3166 for language/country code
something like "eng" (US english), can be 0 if unknown
@@ -666,24 +679,36 @@
stuffing
0x80 can be placed in front of any type v entry for stuffing purposes
-info_table[][2]={
- {NULL , NULL }, // end
- {NULL , NULL },
- {NULL , "UTF8"},
- {NULL , "v"},
- {NULL , "s"},
- {"StreamId" , "v"},
- {"Author" , "UTF8"},
- {"Title" , "UTF8"},
- {"Language" , "UTF8"},
- {"Description" , "UTF8"},
- {"Copyright" , "UTF8"},
- {"Encoder" , "UTF8"},
- {"Keyword" , "UTF8"},
- {"Cover" , "JPEG"},
- {"Cover" , "PNG"},
- {"Disposition" , "UTF8"},
+info_table[4][][2]={
+ {
+ {NULL , "i"}, // integer
+ },
+ {
+ {NULL , "r"}, // rational
+ {"TrackTime" , "r"},
+ },
+ {
+ {NULL , "f"}, // float
+ },
+ {
+ {NULL , NULL },
+ {NULL , "UTF8"},
+ {"Author" , "UTF8"},
+ {"Description" , "UTF8"},
+ {"Copyright" , "UTF8"},
+ {"Encoder" , "UTF8"},
+ {"Title" , "UTF8"},
+ {"Cover" , "JPEG"},
+ {"Cover" , "PNG"},
+ {"Source" , "UTF8"},
+ {"CaptureDevice" , "UTF8"},
+ {"CreationTime" , "UTF8"},
+ {"Keywords" , "UTF8"},
+ {"Language" , "UTF8"},
+ {"Disposition" , "UTF8"},
+ }
};
+ Note: No future entries will have NULL as a value.
Structure:
More information about the NUT-devel
mailing list