[ExtractStream] More Re: its in the 3s.....

Dale Reed daler at n...
Sun, 18 Nov 2001 19:49:33 -0800


joe666boxer@y... wrote:

> > From Tyconvert:
> >
> > unsigned long size = (((p[0]<<8) | p[1])<<4) | (p[2]>>4);
> >
> > From SplitStream:
> >
> > TyStream[i].size =
> > (((unsigned int) buf[header_pos]) << 12) |
> > (((unsigned int) buf[header_pos + 1]) << 4) |
> > (((unsigned int) buf[header_pos + 2]) >> 4);
> >
> > Anyone notice the subtle difference between the two? It would only
> > matter if the first byte was non-zero. Wonder which is correct? :)
> 
> That looks like a typo in tyconvert. the shifted bits from p[1] will 
> overwrite the lower 4 bits of p[0], which can't be right. From 
> Extractstream 0.3 (around line 169):
> 
> size = ((*p)[0]<<12 | (*p)[1])<<4 | ((*p)[2]>>4);


But is it really not a typo in ES? I'm a little rusty on bitwise shifting,
but this is what I come up with (a=0, b=1, c=2). Now lets also remember that
ES runs on the tivo and tyc runs on my intel box. Would the little endian vs.
big endian processors be an issue? I'm using sendstream to pull the tystream
off the tivo and then processing them on my Wintel box.

aaaaaaaa000000000000 << 12
bbbbbbbb0000 << 4
cccc >> 4

aaaaaaaa0000000000000000 << 12 << 4 = 16
bbbbbbbb0000 << 4
cccc >> 4

My problem is when I use the ES method, I get too large of numbers
that cause overflows. Any thoughts?


Dale