internal static int _2inverse(Block vb, Object vl, float[][] fin, int ch) { int i, k, l, s; LookResidue0 look = (LookResidue0 )vl; InfoResidue0 info = look.info; // move all this setup out later int samples_per_partition = info.grouping; int partitions_per_word = look.phrasebook.dim; int n = info.end - info.begin; int partvals = n / samples_per_partition; int partwords = (partvals + partitions_per_word - 1) / partitions_per_word; int[][] partword = new int[partwords][]; for (s = 0; s < look.stages; s++) { for (i = 0, l = 0; i < partvals; l++) { if (s == 0) { // fetch the partition word for each channel int temp = look.phrasebook.decode(vb.opb); if (temp == -1) { // goto eopbreak; return(0); } partword[l] = look.decodemap[temp]; if (partword[l] == null) { // goto errout; return(0); } } // now we decode residual values for the partitions for (k = 0; k < partitions_per_word && i < partvals; k++, i++) { int offset = info.begin + i * samples_per_partition; if ((info.secondstages[partword[l][k]] & (1 << s)) != 0) { CodeBook stagebook = look.fullbooks[look.partbooks[partword[l][k]][s]]; if (stagebook != null) { if (stagebook.decodevv_add(fin, offset, ch, vb.opb, samples_per_partition) == -1) { // goto errout; return(0); } } } } } } // errout: // eopbreak: return(0); }
override public Object look(DspState vd, InfoMode vm, Object vr) { InfoResidue0 info = (InfoResidue0)vr; LookResidue0 look = new LookResidue0(); int acc = 0; int dim; int maxstage = 0; look.info = info; look.map = vm.mapping; look.parts = info.partitions; look.fullbooks = vd.fullbooks; look.phrasebook = vd.fullbooks[info.groupbook]; dim = look.phrasebook.dim; look.partbooks = new int[look.parts][]; for (int j = 0; j < look.parts; j++) { int stages = ilog(info.secondstages[j]); if (stages != 0) { if (stages > maxstage) { maxstage = stages; } look.partbooks[j] = new int[stages]; for (int k = 0; k < stages; k++) { if ((info.secondstages[j] & (1 << k)) != 0) { look.partbooks[j][k] = info.booklist[acc++]; } } } } look.partvals = (int)Math.Round(Math.Pow(look.parts, dim)); look.stages = maxstage; look.decodemap = new int[look.partvals][]; for (int j = 0; j < look.partvals; j++) { int val = j; int mult = look.partvals / look.parts; look.decodemap[j] = new int[dim]; for (int k = 0; k < dim; k++) { int deco = val / mult; val -= deco * mult; mult /= look.parts; look.decodemap[j][k] = deco; } } return(look); }
internal static int _01inverse(Block vb, Object vl, float[][] fin, int ch, int decodepart) { { int i, j, k, l, s; LookResidue0 look = (LookResidue0 )vl; InfoResidue0 info = look.info; // move all this setup out later int samples_per_partition = info.grouping; int partitions_per_word = look.phrasebook.dim; int n = info.end - info.begin; int partvals = n / samples_per_partition; int partwords = (partvals + partitions_per_word - 1) / partitions_per_word; if (partword.Length < ch) { partword = new int[ch][][]; for (j = 0; j < ch; j++) { partword[j] = new int[partwords][]; } } else { for (j = 0; j < ch; j++) { if (partword[j] == null || partword[j].Length < partwords) { partword[j] = new int[partwords][]; } } } for (s = 0; s < look.stages; s++) { // each loop decodes on partition codeword containing // partitions_pre_word partitions for (i = 0, l = 0; i < partvals; l++) { if (s == 0) { // fetch the partition word for each channel for (j = 0; j < ch; j++) { int temp = look.phrasebook.decode(vb.opb); if (temp == -1) { //goto eopbreak; return(0); } partword[j][l] = look.decodemap[temp]; if (partword[j][l] == null) { // goto errout; return(0); } } } // now we decode residual values for the partitions for (k = 0; k < partitions_per_word && i < partvals; k++, i++) { for (j = 0; j < ch; j++) { int offset = info.begin + i * samples_per_partition; if ((info.secondstages[partword[j][l][k]] & (1 << s)) != 0) { CodeBook stagebook = look.fullbooks[look.partbooks[partword[j][l][k]][s]]; // CodeBook stagebook=look.partbooks[partword[j][l][k]][s]; if (stagebook != null) { if (decodepart == 0) { if (stagebook.decodevs_add(fin[j], offset, vb.opb, samples_per_partition) == -1) { // goto errout; return(0); } } else if (decodepart == 1) { if (stagebook.decodev_add(fin[j], offset, vb.opb, samples_per_partition) == -1) { // goto errout; return(0); } } } } } } } } return(0); } }
public override Object look(DspState vd, InfoMode vm, Object vr) { InfoResidue0 info=(InfoResidue0)vr; LookResidue0 look=new LookResidue0(); int acc=0; int dim; int maxstage=0; look.info=info; look.map=vm.mapping; look.parts=info.partitions; look.fullbooks=vd.fullbooks; look.phrasebook=vd.fullbooks[info.groupbook]; dim=look.phrasebook.dim; look.partbooks=new int[look.parts][]; for(int j=0; j<look.parts; j++) { int stages=ilog(info.secondstages[j]); if(stages!=0) { if(stages>maxstage) { maxstage=stages; } look.partbooks[j]=new int[stages]; for(int k=0; k<stages; k++) { if((info.secondstages[j]&(1<<k))!=0) { look.partbooks[j][k]=info.booklist[acc++]; } } } } look.partvals=(int)Math.Round(Math.Pow(look.parts,dim)); look.stages=maxstage; look.decodemap=new int[look.partvals][]; for(int j=0; j<look.partvals; j++) { int val=j; int mult=look.partvals/look.parts; look.decodemap[j]=new int[dim]; for(int k=0; k<dim; k++) { int deco=val/mult; val-=deco*mult; mult/=look.parts; look.decodemap[j][k]=deco; } } return(look); }