override internal Object inverse1(Block vb, Object i, Object memo) { LookFloor0 look = (LookFloor0)i; InfoFloor0 info = look.vi; float[] lsp = null; if (memo is float[]) { lsp = (float[])memo; } int ampraw = vb.opb.Read(info.ampbits); if (ampraw > 0) { // also handles the -1 out of data case int maxval = (1 << info.ampbits) - 1; float amp = (float)ampraw / maxval * info.ampdB; int booknum = vb.opb.Read(Util.ilog(info.numbooks)); if (booknum != -1 && booknum < info.numbooks) { CodeBook b = vb.vd.fullbooks[info.books[booknum]]; float last = 0.0f; if (lsp == null || lsp.Length < look.m + 1) { lsp = new float[look.m + 1]; } else { for (int j = 0; j < lsp.Length; j++) { lsp[j] = 0.0f; } } for (int j = 0; j < look.m; j += b.dim) { if (b.decodev_set(lsp, j, vb.opb, b.dim) == -1) { return(null); } } for (int j = 0; j < look.m;) { for (int k = 0; k < b.dim; k++, j++) { lsp[j] += last; } last = lsp[j - 1]; } lsp[look.m] = amp; return(lsp); } } return(null); }
// Analysis side code, but directly related to blocking. Thus it's // here and not in analysis.c (which is for analysis transforms only). // The init is here because some of it is shared int init(Info vi, bool encp) { this.vi = vi; modebits = Util.ilog2(vi.Modes); transform[0] = new Object[VI_TRANSFORMB]; transform[1] = new Object[VI_TRANSFORMB]; // MDCT is tranform 0 transform[0][0] = new Mdct(); transform[1][0] = new Mdct(); ((Mdct)transform[0][0]).Init(vi.blocksizes[0]); ((Mdct)transform[1][0]).Init(vi.blocksizes[1]); _window[0][0][0] = new float[VI_WINDOWB][]; _window[0][0][1] = _window[0][0][0]; _window[0][1][0] = _window[0][0][0]; _window[0][1][1] = _window[0][0][0]; _window[1][0][0] = new float[VI_WINDOWB][]; _window[1][0][1] = new float[VI_WINDOWB][]; _window[1][1][0] = new float[VI_WINDOWB][]; _window[1][1][1] = new float[VI_WINDOWB][]; for (int i = 0; i < VI_WINDOWB; i++) { _window[0][0][0][i] = window(i, vi.blocksizes[0], vi.blocksizes[0] / 2, vi.blocksizes[0] / 2); _window[1][0][0][i] = window(i, vi.blocksizes[1], vi.blocksizes[0] / 2, vi.blocksizes[0] / 2); _window[1][0][1][i] = window(i, vi.blocksizes[1], vi.blocksizes[0] / 2, vi.blocksizes[1] / 2); _window[1][1][0][i] = window(i, vi.blocksizes[1], vi.blocksizes[1] / 2, vi.blocksizes[0] / 2); _window[1][1][1][i] = window(i, vi.blocksizes[1], vi.blocksizes[1] / 2, vi.blocksizes[1] / 2); } fullbooks = new CodeBook[vi.Books]; for (int i = 0; i < vi.Books; i++) { fullbooks[i] = new CodeBook(); fullbooks[i].init_decode(vi.BookParam[i]); } // initialize the storage vectors to a decent size greater than the // minimum pcm_storage = 8192; // we'll assume later that we have // a minimum of twice the blocksize of // accumulated samples in analysis pcm = new float[vi.Channels][]; { for (int i = 0; i < vi.Channels; i++) { pcm[i] = new float[pcm_storage]; } } // all 1 (large block) or 0 (small block) // explicitly set for the sake of clarity lW = 0; // previous window size W = 0; // current window size // all vector indexes; multiples of samples_per_envelope_step centerW = vi.blocksizes[1] / 2; pcm_current = centerW; // initialize all the mapping/backend lookups mode = new Object[vi.Modes]; for (int i = 0; i < vi.Modes; i++) { int mapnum = vi.ModeParam[i].mapping; int maptype = vi.map_type[mapnum]; mode[i] = FuncMapping.mapping_P[maptype].look(this, vi.ModeParam[i], vi.MapParam[mapnum]); } return (0); }
// Analysis side code, but directly related to blocking. Thus it's // here and not in analysis.c (which is for analysis transforms only). // The init is here because some of it is shared int init(Info vi, bool encp) { this.vi = vi; modebits = Util.ilog2(vi.Modes); transform[0] = new Object[VI_TRANSFORMB]; transform[1] = new Object[VI_TRANSFORMB]; // MDCT is tranform 0 transform[0][0] = new Mdct(); transform[1][0] = new Mdct(); ((Mdct)transform[0][0]).Init(vi.blocksizes[0]); ((Mdct)transform[1][0]).Init(vi.blocksizes[1]); _window[0][0][0] = new float[VI_WINDOWB][]; _window[0][0][1] = _window[0][0][0]; _window[0][1][0] = _window[0][0][0]; _window[0][1][1] = _window[0][0][0]; _window[1][0][0] = new float[VI_WINDOWB][]; _window[1][0][1] = new float[VI_WINDOWB][]; _window[1][1][0] = new float[VI_WINDOWB][]; _window[1][1][1] = new float[VI_WINDOWB][]; for (int i = 0; i < VI_WINDOWB; i++) { _window[0][0][0][i] = window(i, vi.blocksizes[0], vi.blocksizes[0] / 2, vi.blocksizes[0] / 2); _window[1][0][0][i] = window(i, vi.blocksizes[1], vi.blocksizes[0] / 2, vi.blocksizes[0] / 2); _window[1][0][1][i] = window(i, vi.blocksizes[1], vi.blocksizes[0] / 2, vi.blocksizes[1] / 2); _window[1][1][0][i] = window(i, vi.blocksizes[1], vi.blocksizes[1] / 2, vi.blocksizes[0] / 2); _window[1][1][1][i] = window(i, vi.blocksizes[1], vi.blocksizes[1] / 2, vi.blocksizes[1] / 2); } fullbooks = new CodeBook[vi.Books]; for (int i = 0; i < vi.Books; i++) { fullbooks[i] = new CodeBook(); fullbooks[i].init_decode(vi.BookParam[i]); } // initialize the storage vectors to a decent size greater than the // minimum pcm_storage = 8192; // we'll assume later that we have // a minimum of twice the blocksize of // accumulated samples in analysis pcm = new float[vi.Channels][]; { for (int i = 0; i < vi.Channels; i++) { pcm[i] = new float[pcm_storage]; } } // all 1 (large block) or 0 (small block) // explicitly set for the sake of clarity lW = 0; // previous window size W = 0; // current window size // all vector indexes; multiples of samples_per_envelope_step centerW = vi.blocksizes[1] / 2; pcm_current = centerW; // initialize all the mapping/backend lookups mode = new Object[vi.Modes]; for (int i = 0; i < vi.Modes; i++) { int mapnum = vi.ModeParam[i].mapping; int maptype = vi.map_type[mapnum]; mode[i] = FuncMapping.mapping_P[maptype].look(this, vi.ModeParam[i], vi.MapParam[mapnum]); } return(0); }
static internal int _2inverse(Block vb, Object vl, float[][] In, int ch) { lock (StatickLock) { 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; if (_2inverse_partword == null || _2inverse_partword.Length < partwords) { _2inverse_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) { return(0); } _2inverse_partword[l] = look.decodemap[temp]; if (_2inverse_partword[l] == null) { 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; int index = _2inverse_partword[l][k]; if ((info.secondstages[index] & (1 << s)) != 0) { CodeBook stagebook = look.fullbooks[look.partbooks[index][s]]; if (stagebook != null) { if (stagebook.decodevv_add(In, offset, ch, vb.opb, samples_per_partition) == -1) { return(0); } } } } } } return(0); } }
internal int inverse(Block vb, Object i, float[] Out) { //System.err.println("Floor0.inverse "+i.getClass()+"]"); LookFloor0 look = (LookFloor0)i; InfoFloor0 info = look.vi; int ampraw = vb.opb.Read(info.ampbits); if (ampraw > 0) { // also handles the -1 out of data case int maxval = (1 << info.ampbits) - 1; float amp = (float)ampraw / maxval * info.ampdB; int booknum = vb.opb.Read(Util.ilog(info.numbooks)); if (booknum != -1 && booknum < info.numbooks) { lock (this) { if (lsp == null || lsp.Length < look.m) { lsp = new float[look.m]; } else { for (int j = 0; j < look.m; j++) { lsp[j] = 0.0f; } } CodeBook b = vb.vd.fullbooks[info.books[booknum]]; float last = 0.0f; for (int j = 0; j < look.m; j++) { Out[j] = 0.0f; } for (int j = 0; j < look.m; j += b.dim) { if (b.decodevs(lsp, j, vb.opb, 1, -1) == -1) { for (int k = 0; k < look.n; k++) { Out[k] = 0.0f; } return(0); } } for (int j = 0; j < look.m;) { for (int k = 0; k < b.dim; k++, j++) { lsp[j] += last; } last = lsp[j - 1]; } // take the coefficients back to a spectral envelope curve Lsp.lsp_to_curve(Out, look.linearmap, look.n, look.ln, lsp, look.m, amp, info.ampdB); return(1); } } } return(0); }