# HG changeset patch # User arpi # Date 1030488414 0 # Node ID 6d784b2812b936b2cd32cebebaf12680806ea127 # Parent da10c07566491eeda557b39f5e4bfce182d76a2c 'sipr' descrambling implemented, at least for 16*6 matrix diff -r da10c0756649 -r 6d784b2812b9 libmpcodecs/ad_real.c --- a/libmpcodecs/ad_real.c Tue Aug 27 22:28:03 2002 +0000 +++ b/libmpcodecs/ad_real.c Tue Aug 27 22:46:54 2002 +0000 @@ -158,27 +158,58 @@ // again: you don't have to free() a_in_buffer here! it's done by the core. } +static unsigned char sipr_swaps[38][2]={ + {0,63},{1,22},{2,44},{3,90},{5,81},{7,31},{8,86},{9,58},{10,36},{12,68}, + {13,39},{14,73},{15,53},{16,69},{17,57},{19,88},{20,34},{21,71},{24,46}, + {25,94},{26,54},{28,75},{29,50},{32,70},{33,92},{35,74},{38,85},{40,56}, + {42,87},{43,65},{45,59},{48,79},{49,93},{51,89},{55,95},{61,76},{67,83}, + {77,80} }; + static int decode_audio(sh_audio_t *sh,unsigned char *buf,int minlen,int maxlen){ int result; int len=-1; int sps=((short*)(sh->wf+1))[0]; int w=sh->wf->nBlockAlign; // 5 int h=((short*)(sh->wf+1))[1]; - - if(sps) w/=sps; else sps=1; + +// printf("bs=%d sps=%d w=%d h=%d \n",sh->wf->nBlockAlign,sps,w,h); -// printf("bs=%d sps=%d w=%d h=%d \n",sh->wf->nBlockAlign,sps,w,h); - #if 1 if(sh->a_in_buffer_len<=0){ // fill the buffer! + if(!sps){ + // 'sipr' way + int j,n; + int bs=h*w*2/96; // nibbles per subpacket + unsigned char *p=sh->a_in_buffer; + demux_read_data(sh->ds, p, h*w); + for(n=0;n<38;n++){ + int i=bs*sipr_swaps[n][0]; + int o=bs*sipr_swaps[n][1]; + // swap nibbles of block 'i' with 'o' TODO: optimize + for(j=0;j>1)]>>4) : (p[(i>>1)]&15); + int y=(o&1) ? (p[(o>>1)]>>4) : (p[(o>>1)]&15); + if(o&1) p[(o>>1)]=(p[(o>>1)]&0x0F)|(x<<4); + else p[(o>>1)]=(p[(o>>1)]&0xF0)|x; + if(i&1) p[(i>>1)]=(p[(i>>1)]&0x0F)|(y<<4); + else p[(i>>1)]=(p[(i>>1)]&0xF0)|y; + ++i;++o; + } + } + sh->a_in_buffer_size= + sh->a_in_buffer_len=w*h; + } else { + // 'cook' way int x,y; + w/=sps; for(y=0;yds, sh->a_in_buffer+sps*(h*x+((h+1)/2)*(y&1)+(y>>1)), sps); } sh->a_in_buffer_size= sh->a_in_buffer_len=w*h*sps; + } } #else