Esempio n. 1
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]);
            }
        }
Esempio n. 2
0
        public int synthesis(Packet op)
        {
            Info vi = vd.vi;

            opb.readinit(op.packet_base, op.packet, op.bytes);
            opb.read(1);
            // read our mode and pre/post windowsize
            mode = opb.read(vd.modebits);
            W    = vi.mode_param[mode].blockflag;
            if (W != 0)
            {
                lW = opb.read(1); nW = opb.read(1);
            }
            else
            {
                lW = 0; nW = 0;
            }

            // more setup
            granulepos = op.granulepos;
            sequence   = op.packetno - 3;         // first block is third packet
            eofflag    = op.e_o_s;

            // alloc pcm passback storage
            pcmend = vi.blocksizes[W];
            if (pcm.Length < vi.channels)
            {
                pcm = new float[vi.channels][];
            }

            for (int i = 0; i < vi.channels; i++)
            {
                if (pcm[i] == null || pcm[i].Length < pcmend)
                {
                    pcm[i] = new float[pcmend];
                }
                else
                {
                    for (int j = 0; j < pcmend; j++)
                    {
                        pcm[i][j] = 0;
                    }
                }
            }

            // unpack_header enforces range checking
            FuncMapping mapping = vi.map_funcs[vi.mode_param[mode].mapping];

            return(mapping.inverse(this, vd.mode[mode]));
        }