Пример #1
0
        override internal Object look(DspState vd, InfoMode mi, Object i)
        {
            float      scale;
            Info       vi   = vd.vi;
            InfoFloor0 info = (InfoFloor0)i;
            LookFloor0 look = new LookFloor0();

            look.m  = info.order;
            look.n  = vi.blocksizes[mi.blockflag] / 2;
            look.ln = info.barkmap;
            look.vi = info;
            look.lpclook.init(look.ln, look.m);

            // we choose a scaling constant so that:
            scale = look.ln / toBARK((float)(info.rate / 2.0f));

            // the mapping from a linear scale to a smaller bark scale is
            // straightforward.  We do *not* make sure that the linear mapping
            // does not skip bark-scale bins; the decoder simply skips them and
            // the encoder may do what it wishes in filling them.  They're
            // necessary in some mapping combinations to keep the scale spacing
            // accurate
            look.linearmap = new int[look.n];
            for (int j = 0; j < look.n; j++)
            {
                int val = (int)Math.Floor(toBARK((float)((info.rate / 2.0f) / look.n * j)) * scale);                 // bark numbers represent band edges
                if (val >= look.ln)
                {
                    val = look.ln;                     // guard against the approximation
                }
                look.linearmap[j] = val;
            }
            return(look);
        }
Пример #2
0
        override internal 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 i      = info.secondstages[j];
                int stages = Util.ilog(i);
                if (stages != 0)
                {
                    if (stages > maxstage)
                    {
                        maxstage = stages;
                    }
                    look.partbooks[j] = new int[stages];
                    for (int k = 0; k < stages; k++)
                    {
                        if ((i & (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);
        }
Пример #3
0
        override internal Object look(DspState vd, InfoMode vm, Object m)
        {
            //System.err.println("Mapping0.look");
            Info         vi   = vd.vi;
            LookMapping0 look = new LookMapping0();
            InfoMapping0 info = look.map = (InfoMapping0)m;

            look.mode = vm;

            look.time_look    = new Object[info.submaps];
            look.floor_look   = new Object[info.submaps];
            look.residue_look = new Object[info.submaps];

            look.time_func    = new FuncTime[info.submaps];
            look.floor_func   = new FuncFloor[info.submaps];
            look.residue_func = new FuncResidue[info.submaps];

            for (int i = 0; i < info.submaps; i++)
            {
                int timenum  = info.timesubmap[i];
                int floornum = info.floorsubmap[i];
                int resnum   = info.residuesubmap[i];

                look.time_func[i]    = FuncTime.time_P[vi.TimeType[timenum]];
                look.time_look[i]    = look.time_func[i].look(vd, vm, vi.TimeParam[timenum]);
                look.floor_func[i]   = FuncFloor.floor_P[vi.FloorType[floornum]];
                look.floor_look[i]   = look.floor_func[i].look(vd, vm, vi.FloorParam[floornum]);
                look.residue_func[i] = FuncResidue.residue_P[vi.residue_type[resnum]];
                look.residue_look[i] = look.residue_func[i].look(vd, vm, vi.ResidueParam[resnum]);
            }

            /*
             * if (vi.psys != 0 && vd.analysisp != 0)
             * {
             *      // ??
             * }
             */

            look.ch = vi.Channels;

            return(look);
        }
Пример #4
0
        internal override Object look(DspState vd, InfoMode vm, Object m)
        {
            //System.err.println("Mapping0.look");
            Info vi = vd.vi;
            LookMapping0 look = new LookMapping0();
            InfoMapping0 info = look.map = (InfoMapping0)m;
            look.mode = vm;

            look.time_look = new Object[info.submaps];
            look.floor_look = new Object[info.submaps];
            look.residue_look = new Object[info.submaps];

            look.time_func = new FuncTime[info.submaps];
            look.floor_func = new FuncFloor[info.submaps];
            look.residue_func = new FuncResidue[info.submaps];

            for (int i = 0; i < info.submaps; i++)
            {
                int timenum = info.timesubmap[i];
                int floornum = info.floorsubmap[i];
                int resnum = info.residuesubmap[i];

                look.time_func[i] = FuncTime.time_P[vi.TimeType[timenum]];
                look.time_look[i] = look.time_func[i].look(vd, vm, vi.TimeParam[timenum]);
                look.floor_func[i] = FuncFloor.floor_P[vi.FloorType[floornum]];
                look.floor_look[i] = look.floor_func[i].look(vd, vm, vi.FloorParam[floornum]);
                look.residue_func[i] = FuncResidue.residue_P[vi.residue_type[resnum]];
                look.residue_look[i] = look.residue_func[i].look(vd, vm, vi.ResidueParam[resnum]);

            }

            /*
            if (vi.psys != 0 && vd.analysisp != 0)
            {
                // ??
            }
            */

            look.ch = vi.Channels;

            return (look);
        }
Пример #5
0
        /// <summary>
        /// All of the real encoding details are here.  The modes, books, everything.
        /// </summary>
        /// <param name="Buffer"></param>
        /// <returns></returns>
        int UnpackBooks(NVorbis.Ogg.BBuffer Buffer)
        {
            Books = Buffer.Read(8) + 1;

            if (BookParam == null || BookParam.Length != Books)
            {
                BookParam = new StaticCodeBook[Books];
            }

            for (int i = 0; i < Books; i++)
            {
                BookParam[i] = new StaticCodeBook();
                if (BookParam[i].unpack(Buffer) != 0)
                {
                    Clear();
                    return(-1);
                }
            }

            // time backend settings
            Times = Buffer.Read(6) + 1;
            if (TimeType == null || TimeType.Length != Times)
            {
                TimeType = new int[Times];
            }
            if (TimeParam == null || TimeParam.Length != Times)
            {
                TimeParam = new Object[Times];
            }
            for (int i = 0; i < Times; i++)
            {
                TimeType[i] = Buffer.Read(16);
                if (TimeType[i] < 0 || TimeType[i] >= VI_TIMEB)
                {
                    Clear();
                    return(-1);
                }
                TimeParam[i] = FuncTime.time_P[TimeType[i]].unpack(this, Buffer);
                if (TimeParam[i] == null)
                {
                    Clear();
                    return(-1);
                }
            }

            // floor backend settings
            floors = Buffer.Read(6) + 1;
            if (FloorType == null || FloorType.Length != floors)
            {
                FloorType = new int[floors];
            }
            if (FloorParam == null || FloorParam.Length != floors)
            {
                FloorParam = new Object[floors];
            }

            for (int i = 0; i < floors; i++)
            {
                FloorType[i] = Buffer.Read(16);
                if (FloorType[i] < 0 || FloorType[i] >= VI_FLOORB)
                {
                    Clear();
                    return(-1);
                }

                FloorParam[i] = FuncFloor.floor_P[FloorType[i]].unpack(this, Buffer);
                if (FloorParam[i] == null)
                {
                    Clear();
                    return(-1);
                }
            }

            // residue backend settings
            residues = Buffer.Read(6) + 1;

            if (residue_type == null || residue_type.Length != residues)
            {
                residue_type = new int[residues];
            }

            if (ResidueParam == null || ResidueParam.Length != residues)
            {
                ResidueParam = new Object[residues];
            }

            for (int i = 0; i < residues; i++)
            {
                residue_type[i] = Buffer.Read(16);
                if (residue_type[i] < 0 || residue_type[i] >= VI_RESB)
                {
                    Clear();
                    return(-1);
                }
                ResidueParam[i] = FuncResidue.residue_P[residue_type[i]].unpack(this, Buffer);
                if (ResidueParam[i] == null)
                {
                    Clear();
                    return(-1);
                }
            }

            // map backend settings
            maps = Buffer.Read(6) + 1;
            if (map_type == null || map_type.Length != maps)
            {
                map_type = new int[maps];
            }
            if (MapParam == null || MapParam.Length != maps)
            {
                MapParam = new Object[maps];
            }
            for (int i = 0; i < maps; i++)
            {
                map_type[i] = Buffer.Read(16);
                if (map_type[i] < 0 || map_type[i] >= VI_MAPB)
                {
                    Clear();
                    return(-1);
                }
                MapParam[i] = FuncMapping.mapping_P[map_type[i]].unpack(this, Buffer);
                if (MapParam[i] == null)
                {
                    Clear();
                    return(-1);
                }
            }

            // mode settings
            Modes = Buffer.Read(6) + 1;
            if (ModeParam == null || ModeParam.Length != Modes)
            {
                ModeParam = new InfoMode[Modes];
            }
            for (int i = 0; i < Modes; i++)
            {
                ModeParam[i]               = new InfoMode();
                ModeParam[i].blockflag     = Buffer.Read(1);
                ModeParam[i].windowtype    = Buffer.Read(16);
                ModeParam[i].transformtype = Buffer.Read(16);
                ModeParam[i].mapping       = Buffer.Read(8);

                if ((ModeParam[i].windowtype >= VI_WINDOWB) ||
                    (ModeParam[i].transformtype >= VI_WINDOWB) ||
                    (ModeParam[i].mapping >= maps))
                {
                    Clear();
                    return(-1);
                }
            }

            if (Buffer.Read(1) != 1)
            {
                Clear();
                return(-1);
            }

            return(0);
        }
Пример #6
0
 internal abstract Object look(DspState vd, InfoMode vm, Object vr);
Пример #7
0
 abstract internal Object look(DspState vd, InfoMode vm, Object i);
Пример #8
0
        /// <summary>
        /// All of the real encoding details are here.  The modes, books, everything.
        /// </summary>
        /// <param name="Buffer"></param>
        /// <returns></returns>
        int UnpackBooks(NVorbis.Ogg.BBuffer Buffer)
        {
            Books = Buffer.Read(8) + 1;

            if (BookParam == null || BookParam.Length != Books) BookParam = new StaticCodeBook[Books];

            for (int i = 0; i < Books; i++)
            {
                BookParam[i] = new StaticCodeBook();
                if (BookParam[i].unpack(Buffer) != 0)
                {
                    Clear();
                    return (-1);
                }
            }

            // time backend settings
            Times = Buffer.Read(6) + 1;
            if (TimeType == null || TimeType.Length != Times) TimeType = new int[Times];
            if (TimeParam == null || TimeParam.Length != Times) TimeParam = new Object[Times];
            for (int i = 0; i < Times; i++)
            {
                TimeType[i] = Buffer.Read(16);
                if (TimeType[i] < 0 || TimeType[i] >= VI_TIMEB)
                {
                    Clear();
                    return (-1);
                }
                TimeParam[i] = FuncTime.time_P[TimeType[i]].unpack(this, Buffer);
                if (TimeParam[i] == null)
                {
                    Clear();
                    return (-1);
                }
            }

            // floor backend settings
            floors = Buffer.Read(6) + 1;
            if (FloorType == null || FloorType.Length != floors) FloorType = new int[floors];
            if (FloorParam == null || FloorParam.Length != floors) FloorParam = new Object[floors];

            for (int i = 0; i < floors; i++)
            {
                FloorType[i] = Buffer.Read(16);
                if (FloorType[i] < 0 || FloorType[i] >= VI_FLOORB)
                {
                    Clear();
                    return (-1);
                }

                FloorParam[i] = FuncFloor.floor_P[FloorType[i]].unpack(this, Buffer);
                if (FloorParam[i] == null)
                {
                    Clear();
                    return (-1);
                }
            }

            // residue backend settings
            residues = Buffer.Read(6) + 1;

            if (residue_type == null || residue_type.Length != residues)
                residue_type = new int[residues];

            if (ResidueParam == null || ResidueParam.Length != residues)
                ResidueParam = new Object[residues];

            for (int i = 0; i < residues; i++)
            {
                residue_type[i] = Buffer.Read(16);
                if (residue_type[i] < 0 || residue_type[i] >= VI_RESB)
                {
                    Clear();
                    return (-1);
                }
                ResidueParam[i] = FuncResidue.residue_P[residue_type[i]].unpack(this, Buffer);
                if (ResidueParam[i] == null)
                {
                    Clear();
                    return (-1);
                }
            }

            // map backend settings
            maps = Buffer.Read(6) + 1;
            if (map_type == null || map_type.Length != maps)
                map_type = new int[maps];
            if (MapParam == null || MapParam.Length != maps)
                MapParam = new Object[maps];
            for (int i = 0; i < maps; i++)
            {
                map_type[i] = Buffer.Read(16);
                if (map_type[i] < 0 || map_type[i] >= VI_MAPB)
                {
                    Clear();
                    return (-1);
                }
                MapParam[i] = FuncMapping.mapping_P[map_type[i]].unpack(this, Buffer);
                if (MapParam[i] == null)
                {
                    Clear();
                    return (-1);
                }
            }

            // mode settings
            Modes = Buffer.Read(6) + 1;
            if (ModeParam == null || ModeParam.Length != Modes)
                ModeParam = new InfoMode[Modes];
            for (int i = 0; i < Modes; i++)
            {
                ModeParam[i] = new InfoMode();
                ModeParam[i].blockflag = Buffer.Read(1);
                ModeParam[i].windowtype = Buffer.Read(16);
                ModeParam[i].transformtype = Buffer.Read(16);
                ModeParam[i].mapping = Buffer.Read(8);

                if ((ModeParam[i].windowtype >= VI_WINDOWB)
                    || (ModeParam[i].transformtype >= VI_WINDOWB)
                    || (ModeParam[i].mapping >= maps))
                {
                    Clear();
                    return (-1);
                }
            }

            if (Buffer.Read(1) != 1)
            {
                Clear();
                return (-1);
            }

            return (0);
        }
Пример #9
0
        internal 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 i = info.secondstages[j];
                int stages = Util.ilog(i);
                if (stages != 0)
                {
                    if (stages > maxstage)
                        maxstage = stages;
                    look.partbooks[j] = new int[stages];
                    for (int k = 0; k < stages; k++)
                    {
                        if ((i & (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);
        }
Пример #10
0
        override internal Object look(DspState vd, InfoMode mi, Object i)
        {
            int _n = 0;

            int[] sortpointer = new int[VIF_POSIT + 2];

            //    Info vi=vd.vi;

            InfoFloor1 info = (InfoFloor1)i;
            LookFloor1 look = new LookFloor1();

            look.vi = info;
            look.n  = info.postlist[1];

            /* we drop each position value in-between already decoded values,
             * and use linear interpolation to predict each new value past the
             * edges.  The positions are read in the order of the position
             * list... we precompute the bounding positions in the lookup.  Of
             * course, the neighbors can change (if a position is declined), but
             * this is an initial mapping */

            for (int j = 0; j < info.Partitions; j++)
            {
                _n += info.class_dim[info.Partitionclass[j]];
            }
            _n        += 2;
            look.posts = _n;

            /* also store a sorted position index */
            for (int j = 0; j < _n; j++)
            {
                sortpointer[j] = j;
            }
            //    qsort(sortpointer,n,sizeof(int),icomp); // !!

            int foo;

            for (int j = 0; j < _n - 1; j++)
            {
                for (int k = j; k < _n; k++)
                {
                    if (info.postlist[sortpointer[j]] > info.postlist[sortpointer[k]])
                    {
                        foo            = sortpointer[k];
                        sortpointer[k] = sortpointer[j];
                        sortpointer[j] = foo;
                    }
                }
            }

            /* points from sort order back to range number */
            for (int j = 0; j < _n; j++)
            {
                look.forward_index[j] = sortpointer[j];
            }
            /* points from range order to sorted position */
            for (int j = 0; j < _n; j++)
            {
                look.reverse_index[look.forward_index[j]] = j;
            }
            /* we actually need the post values too */
            for (int j = 0; j < _n; j++)
            {
                look.sorted_index[j] = info.postlist[look.forward_index[j]];
            }

            /* quantize values to multiplier spec */
            switch (info.mult)
            {
            case 1:                     /* 1024 -> 256 */
                look.quant_q = 256;
                break;

            case 2:                     /* 1024 -> 128 */
                look.quant_q = 128;
                break;

            case 3:                     /* 1024 -> 86 */
                look.quant_q = 86;
                break;

            case 4:                     /* 1024 -> 64 */
                look.quant_q = 64;
                break;

            default:
                look.quant_q = -1;
                break;
            }

            /* discover our neighbors for decode where we don't use fit flags
             * (that would push the neighbors outward) */
            for (int j = 0; j < _n - 2; j++)
            {
                int lo       = 0;
                int hi       = 1;
                int lx       = 0;
                int hx       = look.n;
                int currentx = info.postlist[j + 2];
                for (int k = 0; k < j + 2; k++)
                {
                    int x = info.postlist[k];
                    if (x > lx && x < currentx)
                    {
                        lo = k;
                        lx = x;
                    }
                    if (x < hx && x > currentx)
                    {
                        hi = k;
                        hx = x;
                    }
                }
                look.loneighbor[j] = lo;
                look.hineighbor[j] = hi;
            }

            return(look);
        }
Пример #11
0
 internal override Object look(DspState vd, InfoMode mi, Object i)
 {
     return "";
 }
Пример #12
0
        internal override Object look(DspState vd, InfoMode mi, Object i)
        {
            int _n = 0;

            int[] sortpointer = new int[VIF_POSIT + 2];

            //    Info vi=vd.vi;

            InfoFloor1 info = (InfoFloor1)i;
            LookFloor1 look = new LookFloor1();
            look.vi = info;
            look.n = info.postlist[1];

            /* we drop each position value in-between already decoded values,
             and use linear interpolation to predict each new value past the
             edges.  The positions are read in the order of the position
             list... we precompute the bounding positions in the lookup.  Of
             course, the neighbors can change (if a position is declined), but
             this is an initial mapping */

            for (int j = 0; j < info.Partitions; j++)
            {
                _n += info.class_dim[info.Partitionclass[j]];
            }
            _n += 2;
            look.posts = _n;

            /* also store a sorted position index */
            for (int j = 0; j < _n; j++)
            {
                sortpointer[j] = j;
            }
            //    qsort(sortpointer,n,sizeof(int),icomp); // !!

            int foo;
            for (int j = 0; j < _n - 1; j++)
            {
                for (int k = j; k < _n; k++)
                {
                    if (info.postlist[sortpointer[j]] > info.postlist[sortpointer[k]])
                    {
                        foo = sortpointer[k];
                        sortpointer[k] = sortpointer[j];
                        sortpointer[j] = foo;
                    }
                }
            }

            /* points from sort order back to range number */
            for (int j = 0; j < _n; j++)
            {
                look.forward_index[j] = sortpointer[j];
            }
            /* points from range order to sorted position */
            for (int j = 0; j < _n; j++)
            {
                look.reverse_index[look.forward_index[j]] = j;
            }
            /* we actually need the post values too */
            for (int j = 0; j < _n; j++)
            {
                look.sorted_index[j] = info.postlist[look.forward_index[j]];
            }

            /* quantize values to multiplier spec */
            switch (info.mult)
            {
                case 1: /* 1024 -> 256 */
                    look.quant_q = 256;
                    break;
                case 2: /* 1024 -> 128 */
                    look.quant_q = 128;
                    break;
                case 3: /* 1024 -> 86 */
                    look.quant_q = 86;
                    break;
                case 4: /* 1024 -> 64 */
                    look.quant_q = 64;
                    break;
                default:
                    look.quant_q = -1;
                    break;
            }

            /* discover our neighbors for decode where we don't use fit flags
               (that would push the neighbors outward) */
            for (int j = 0; j < _n - 2; j++)
            {
                int lo = 0;
                int hi = 1;
                int lx = 0;
                int hx = look.n;
                int currentx = info.postlist[j + 2];
                for (int k = 0; k < j + 2; k++)
                {
                    int x = info.postlist[k];
                    if (x > lx && x < currentx)
                    {
                        lo = k;
                        lx = x;
                    }
                    if (x < hx && x > currentx)
                    {
                        hi = k;
                        hx = x;
                    }
                }
                look.loneighbor[j] = lo;
                look.hineighbor[j] = hi;
            }

            return look;
        }
Пример #13
0
 override internal Object look(DspState vd, InfoMode mi, Object i)
 {
     return("");
 }
Пример #14
0
        override internal int inverse(Block vb, Object l)
        {
            lock (this)
            {
                DspState     vd   = vb.vd;
                Info         vi   = vd.vi;
                LookMapping0 look = (LookMapping0)l;
                InfoMapping0 info = look.map;
                InfoMode     mode = look.mode;
                int          n    = vb.pcmend = vi.blocksizes[vb.W];

                float[] window = vd._window[vb.W][vb.lW][vb.nW][mode.windowtype];
                if (pcmbundle == null || pcmbundle.Length < vi.Channels)
                {
                    pcmbundle  = new float[vi.Channels][];
                    nonzero    = new int[vi.Channels];
                    zerobundle = new int[vi.Channels];
                    floormemo  = new Object[vi.Channels];
                }

                // time domain information decode (note that applying the
                // information would have to happen later; we'll probably add a
                // function entry to the harness for that later
                // NOT IMPLEMENTED

                // recover the spectral envelope; store it in the PCM vector for now
                for (int i = 0; i < vi.Channels; i++)
                {
                    float[] pcm    = vb.pcm[i];
                    int     submap = info.chmuxlist[i];

                    floormemo[i] = look.floor_func[submap].inverse1(vb,
                                                                    look.floor_look[submap], floormemo[i]);
                    if (floormemo[i] != null)
                    {
                        nonzero[i] = 1;
                    }
                    else
                    {
                        nonzero[i] = 0;
                    }
                    for (int j = 0; j < n / 2; j++)
                    {
                        pcm[j] = 0;
                    }
                }

                for (int i = 0; i < info.coupling_steps; i++)
                {
                    if (nonzero[info.coupling_mag[i]] != 0 || nonzero[info.coupling_ang[i]] != 0)
                    {
                        nonzero[info.coupling_mag[i]] = 1;
                        nonzero[info.coupling_ang[i]] = 1;
                    }
                }

                // recover the residue, apply directly to the spectral envelope

                for (int i = 0; i < info.submaps; i++)
                {
                    int ch_in_bundle = 0;
                    for (int j = 0; j < vi.Channels; j++)
                    {
                        if (info.chmuxlist[j] == i)
                        {
                            if (nonzero[j] != 0)
                            {
                                zerobundle[ch_in_bundle] = 1;
                            }
                            else
                            {
                                zerobundle[ch_in_bundle] = 0;
                            }
                            pcmbundle[ch_in_bundle++] = vb.pcm[j];
                        }
                    }

                    look.residue_func[i].inverse(vb, look.residue_look[i], pcmbundle,
                                                 zerobundle, ch_in_bundle);
                }

                for (int i = info.coupling_steps - 1; i >= 0; i--)
                {
                    float[] pcmM = vb.pcm[info.coupling_mag[i]];
                    float[] pcmA = vb.pcm[info.coupling_ang[i]];

                    for (int j = 0; j < n / 2; j++)
                    {
                        float mag = pcmM[j];
                        float ang = pcmA[j];

                        if (mag > 0)
                        {
                            if (ang > 0)
                            {
                                pcmM[j] = mag;
                                pcmA[j] = mag - ang;
                            }
                            else
                            {
                                pcmA[j] = mag;
                                pcmM[j] = mag + ang;
                            }
                        }
                        else
                        {
                            if (ang > 0)
                            {
                                pcmM[j] = mag;
                                pcmA[j] = mag + ang;
                            }
                            else
                            {
                                pcmA[j] = mag;
                                pcmM[j] = mag - ang;
                            }
                        }
                    }
                }

                //    /* compute and apply spectral envelope */

                for (int i = 0; i < vi.Channels; i++)
                {
                    float[] pcm    = vb.pcm[i];
                    int     submap = info.chmuxlist[i];
                    look.floor_func[submap].inverse2(vb, look.floor_look[submap],
                                                     floormemo[i], pcm);
                }

                // transform the PCM data; takes PCM vector, vb; modifies PCM vector
                // only MDCT right now....

                for (int i = 0; i < vi.Channels; i++)
                {
                    float[] pcm = vb.pcm[i];
                    //_analysis_output("out",seq+i,pcm,n/2,0,0);
                    ((Mdct)vd.transform[vb.W][0]).Backward(pcm, pcm);
                }

                // now apply the decoded pre-window time information
                // NOT IMPLEMENTED

                // window the data
                for (int i = 0; i < vi.Channels; i++)
                {
                    float[] pcm = vb.pcm[i];
                    if (nonzero[i] != 0)
                    {
                        for (int j = 0; j < n; j++)
                        {
                            pcm[j] *= window[j];
                        }
                    }
                    else
                    {
                        for (int j = 0; j < n; j++)
                        {
                            pcm[j] = 0.0f;
                        }
                    }
                }

                // now apply the decoded post-window time information
                // NOT IMPLEMENTED
                // all done!
                return(0);
            }
        }
Пример #15
0
 internal abstract Object look(DspState vd, InfoMode mi, Object i);
Пример #16
0
        internal override Object look(DspState vd, InfoMode mi, Object i)
        {
            float scale;
            Info vi = vd.vi;
            InfoFloor0 info = (InfoFloor0)i;
            LookFloor0 look = new LookFloor0();
            look.m = info.order;
            look.n = vi.blocksizes[mi.blockflag] / 2;
            look.ln = info.barkmap;
            look.vi = info;
            look.lpclook.init(look.ln, look.m);

            // we choose a scaling constant so that:
            scale = look.ln / toBARK((float)(info.rate / 2.0f));

            // the mapping from a linear scale to a smaller bark scale is
            // straightforward.  We do *not* make sure that the linear mapping
            // does not skip bark-scale bins; the decoder simply skips them and
            // the encoder may do what it wishes in filling them.  They're
            // necessary in some mapping combinations to keep the scale spacing
            // accurate
            look.linearmap = new int[look.n];
            for (int j = 0; j < look.n; j++)
            {
                int val = (int)Math.Floor(toBARK((float)((info.rate / 2.0f) / look.n * j)) * scale); // bark numbers represent band edges
                if (val >= look.ln)
                    val = look.ln; // guard against the approximation
                look.linearmap[j] = val;
            }
            return look;
        }