From 253eff648bf279488a2b9eb6f82adb054d447369 Mon Sep 17 00:00:00 2001 From: arpi Date: Fri, 28 Dec 2001 01:03:57 +0000 Subject: more stable and reliable spudec packet reassembler git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@3821 b3059339-0415-0410-9bf9-f77b7e298cf2 --- spudec.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'spudec.c') diff --git a/spudec.c b/spudec.c index f7cf698c1b..904f9f53b5 100644 --- a/spudec.c +++ b/spudec.c @@ -292,10 +292,35 @@ void spudec_assemble(void *this, unsigned char *packet, int len, int pts100) spu->packet_offset += len; } } +#if 1 + // check if we have a complete packet (unfortunatelly packet_size is bad + // for some disks) +// if (spu->packet_offset == spu->packet_size) + { int x=0,y; + while(x>=0 && x+4<=spu->packet_offset){ + y=get_be16(spu->packet+x+2); // next control pointer + printf("SPUtest: x=%d y=%d off=%d size=%d\n",x,y,spu->packet_offset,spu->packet_size); + if(x>=4 && x==y){ // if it points to self - we're done! + // we got it! + printf("SPUgot: off=%d size=%d \n",spu->packet_offset,spu->packet_size); + spudec_decode(spu); + spu->packet_offset = 0; + break; + } + if(y<=x || y>=spu->packet_size){ // invalid? + printf("SPUtest: broken packet!!!!! y=%d < x=%d\n",y,x); + spu->packet_size = spu->packet_offset = 0; + break; + } + x=y; + } + } +#else if (spu->packet_offset == spu->packet_size) { spudec_decode(spu); spu->packet_offset = 0; } +#endif } void spudec_reset(void *this) // called after seek -- cgit v1.2.3