Beispiel #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);
        }
Beispiel #2
0
        void init(Info vi)
        {
            this.vi  = vi;
            modebits = VUtils.ilog2(vi.modes);

            transform[0] = new Mdct();
            transform[1] = new Mdct();
            ((Mdct)transform[0]).init(vi.blocksizes[0]);
            ((Mdct)transform[1]).init(vi.blocksizes[1]);

            wnd[0][0][0] = window(vi.blocksizes[0], vi.blocksizes[0] / 2, vi.blocksizes[0] / 2);
            wnd[1][0][0] = window(vi.blocksizes[1], vi.blocksizes[0] / 2, vi.blocksizes[0] / 2);
            wnd[1][0][1] = window(vi.blocksizes[1], vi.blocksizes[0] / 2, vi.blocksizes[1] / 2);
            wnd[1][1][0] = window(vi.blocksizes[1], vi.blocksizes[1] / 2, vi.blocksizes[0] / 2);
            wnd[1][1][1] = window(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.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][];
            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;
                FuncMapping mapping = vi.map_funcs[mapnum];

                mode[i] = mapping.look(this, vi.mode_param[i], vi.map_param[mapnum]);
            }
        }
Beispiel #3
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);
        }
Beispiel #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

        private 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]);

            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);
            }

            // 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][];
            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);
        }