Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
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)
        {
            //memset(v,0,sizeof(vorbis_dsp_state));
            this.vi=vi;
            modebits=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]);

            wnd[0][0][0]=new float[VI_WINDOWB][];
            wnd[0][0][1]=wnd[0][0][0];
            wnd[0][1][0]=wnd[0][0][0];
            wnd[0][1][1]=wnd[0][0][0];
            wnd[1][0][0]=new float[VI_WINDOWB][];
            wnd[1][0][1]=new float[VI_WINDOWB][];
            wnd[1][1][0]=new float[VI_WINDOWB][];
            wnd[1][1][1]=new float[VI_WINDOWB][];

            for(int i=0; i<VI_WINDOWB; i++) {
                wnd[0][0][0][i]=
                    window(i,vi.blocksizes[0],vi.blocksizes[0]/2,vi.blocksizes[0]/2);
                wnd[1][0][0][i]=
                    window(i,vi.blocksizes[1],vi.blocksizes[0]/2,vi.blocksizes[0]/2);
                wnd[1][0][1][i]=
                    window(i,vi.blocksizes[1],vi.blocksizes[0]/2,vi.blocksizes[1]/2);
                wnd[1][1][0][i]=
                    window(i,vi.blocksizes[1],vi.blocksizes[1]/2,vi.blocksizes[0]/2);
                wnd[1][1][1][i]=
                    window(i,vi.blocksizes[1],vi.blocksizes[1]/2,vi.blocksizes[1]/2);
            }

            //    if(encp){ // encode/decode differ here
            //      // finish the codebooks
            //      fullbooks=new CodeBook[vi.books];
            //      for(int i=0;i<vi.books;i++){
            //	fullbooks[i]=new CodeBook();
            //	fullbooks[i].init_encode(vi.book_param[i]);
            //      }
            //      analysisp=1;
            //    }
            //    else{
            // finish the codebooks
            fullbooks=new CodeBook[vi.books];
            for(int i=0; i<vi.books; i++) {
                fullbooks[i]=new CodeBook();
                fullbooks[i].init_decode(vi.book_param[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][];
            //pcmret=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.mode_param[i].mapping;
                int maptype=vi.map_type[mapnum];

                mode[i]=FuncMapping.mapping_P[maptype].look(this,vi.mode_param[i],
                        vi.map_param[mapnum]);

            }
            return(0);
        }
Exemplo n.º 3
0
        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);
            }
        }
Exemplo n.º 4
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)
        {
            //memset(v,0,sizeof(vorbis_dsp_state));
            this.vi=vi;
            modebits=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]);

            wnd[0][0][0]=new float[VI_WINDOWB][];
            wnd[0][0][1]=wnd[0][0][0];
            wnd[0][1][0]=wnd[0][0][0];
            wnd[0][1][1]=wnd[0][0][0];
            wnd[1][0][0]=new float[VI_WINDOWB][];
            wnd[1][0][1]=new float[VI_WINDOWB][];
            wnd[1][1][0]=new float[VI_WINDOWB][];
            wnd[1][1][1]=new float[VI_WINDOWB][];

            for(int i=0; i<VI_WINDOWB; i++) {
                wnd[0][0][0][i]=
                    window(i,vi.blocksizes[0],vi.blocksizes[0]/2,vi.blocksizes[0]/2);
                wnd[1][0][0][i]=
                    window(i,vi.blocksizes[1],vi.blocksizes[0]/2,vi.blocksizes[0]/2);
                wnd[1][0][1][i]=
                    window(i,vi.blocksizes[1],vi.blocksizes[0]/2,vi.blocksizes[1]/2);
                wnd[1][1][0][i]=
                    window(i,vi.blocksizes[1],vi.blocksizes[1]/2,vi.blocksizes[0]/2);
                wnd[1][1][1][i]=
                    window(i,vi.blocksizes[1],vi.blocksizes[1]/2,vi.blocksizes[1]/2);
            }

            //    if(encp){ // encode/decode differ here
            //      // finish the codebooks
            //      fullbooks=new CodeBook[vi.books];
            //      for(int i=0;i<vi.books;i++){
            //	fullbooks[i]=new CodeBook();
            //	fullbooks[i].init_encode(vi.book_param[i]);
            //      }
            //      analysisp=1;
            //    }
            //    else{
            // finish the codebooks
            fullbooks=new CodeBook[vi.books];
            for(int i=0; i<vi.books; i++) {
                fullbooks[i]=new CodeBook();
                fullbooks[i].init_decode(vi.book_param[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][];
            //pcmret=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.mode_param[i].mapping;
                int maptype=vi.map_type[mapnum];

                mode[i]=FuncMapping.mapping_P[maptype].look(this,vi.mode_param[i],
                        vi.map_param[mapnum]);

            }
            return(0);
        }
Exemplo n.º 5
0
        override public Object inverse1(Block vb, Object i, Object memo)
        {
            //System.err.println("Floor0.inverse "+i.getClass()+"]");
            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(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)
                        {
                            //goto eop;
                            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);
                }
            }
            //  eop:
            return(null);
        }
Exemplo n.º 6
0
        int inverse(Block vb, Object i, float[] fout)
        {
            //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(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;

                        //memset(out,0,sizeof(float)*look->m);
                        for (int j = 0; j < look.m; j++)
                        {
                            fout[j] = 0.0f;
                        }

                        for (int j = 0; j < look.m; j += b.dim)
                        {
                            if (b.decodevs(lsp, j, vb.opb, 1, -1) == -1)
                            {
                                //goto eop;
                                // memset(out,0,sizeof(float)*look->n);
                                for (int k = 0; k < look.n; k++)
                                {
                                    fout[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_to_lpc(out,out,look.m);
                         * lpc_to_curve(out,out,amp,look,"",0);
                         * for(int j=0;j<look.n;j++){
                         * out[j]=fromdB(out[j]-info.ampdB);
                         * }
                         */
                        Lsp.lsp_to_curve(fout, look.linearmap, look.n, look.ln,
                                         lsp, look.m, amp, info.ampdB);

                        return(1);
                    }
                }
            }
            //  eop:
            //    memset(out,0,sizeof(float)*look->n);
            return(0);
        }