[MPlayer-dev-eng] NUT backptr proposal

Oded Shimon ods15 at ods15.dyndns.org
Thu Dec 29 16:30:03 CET 2005


On Thu, Dec 29, 2005 at 03:24:05PM +0100, Michael Niedermayer wrote:
> On Thu, Dec 29, 2005 at 11:07:08AM +0200, Oded Shimon wrote:
> > Now it's my turn.
> > I feel it is easiest to describe this complicated index with code:
> > 
> > for (i = 0; i < ss; i++) s[i].repeat = 1;
> > get_v(syncpoints);
> > get_v(M);
> > for(i = 0; i < syncpoints; i++) {
> > 	int j, flag = 0;
> > 	for (j = 0; j < ss; j++) if (!--s[j].repeat) flag = 1;
> > 	if (!flag) continue;
> > 	get_v(pts);
> > 	for (j = 0; j < ss; j++) {
> > 		if (!s[j].repeat) {
> > 			get_v(back_ptr);
> > 			if (back_ptr < M) {
> > 				int k;
> > 				for (k = 0; k < back_ptr; k++) {
> > 					s[j].back_ptr[i+k] = { pts, s[j].back_ptr[i-1] };
> > 				}
> > 				s[j].repeat = back_ptr;
> > 			} else {
> > 				back_ptr -= M;
> > 				back_ptr *= 8;
> > 				if (i) back_ptr + =s[j].back_ptr[i-1]
> > 				s[j].back_ptr[i] = { pts, back_ptr };
> > 			}
> > 		}
> > 	}
> > }
> > 
> > This code assumes a very very stupid way of storing the index... Basically 
> > stores EVERY syncpoint for every stream, instead of just the repeated ones.
> 
> hmm, trying to win that obfuscated code contest? ;)

Oh, I completely forgot about that, when does this year's contest start, I 
still have my entry ready...

> if we do choose something like that why not:
> 
> n= get_v();
> for(i = 0; i < n; i++) {
>     syncpoint[i].pts     = syncpoint[i-1].pts      + get_v() + 1;
>     syncpoint[i].pos_div8= syncpoint[i-1].pos_div8 + get_v() + 1;
> }
> 
> for(i=0; i<stream_count; i++){
>     s=0;
>     for(j=0; j<n; j++){
>         s+= get_v() + 1;
>         repeat= get_v() + 1;
>         while(repeat--){
>             stream[i].entry[j  ].pts     = syncpoint[s].pts;
>             stream[i].entry[j++].pos_div8= syncpoint[s].pos_div8;
>         }
>     }
> }

I'm not sure I understand, but if I'm not mistaken, this means storing at 
the very least, 2 bytes per each unrepeated syncpoint, plus v_len(pts) and 
v_len(pos). This is bad, because for audio for ex. just about every 
syncpoint is unrepeated. using our method, it's only
v_len(pts) + v_len(pos+M) for each unrepeated syncpoint, much much less 
space.

BTW, I had a few bugs in the code above :) There's the obvious syntax error 
of missing ; and '+ =' instead of '+=', but also I need to set 'repeat=1' 
for the second part of the if.

- ods15




More information about the MPlayer-dev-eng mailing list