Esempio n. 1
0
		override public 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:
			//  floor(bark(rate/2-1)*C)=mapped-1
			// floor(bark(rate/2)*C)=mapped
			scale = look.ln / (float)toBARK((float)(info.rate/2.0));

			// 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.0)/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;
		}
Esempio n. 2
0
		override public Object look(DspState vd, InfoMode vm, Object m)
		{
			Info vi=vd.vi;
			LookMapping0 looks=new LookMapping0();
			InfoMapping0 info=looks.map=(InfoMapping0)m;
			looks.mode=vm;
  
			looks.time_look=new Object[info.submaps];
			looks.floor_look=new Object[info.submaps];
			looks.residue_look=new Object[info.submaps];

			looks.time_func=new FuncTime[info.submaps];
			looks.floor_func=new FuncFloor[info.submaps];
			looks.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];

				looks.time_func[i]=FuncTime.time_P[vi.time_type[timenum]];
				looks.time_look[i]=looks.time_func[i].look(vd,vm,vi.time_param[timenum]);
		
				looks.floor_func[i]=FuncFloor.floor_P[vi.floor_type[floornum]];
				looks.floor_look[i]=looks.floor_func[i].
					look(vd,vm,vi.floor_param[floornum]);

				looks.residue_func[i]=FuncResidue.residue_P[vi.residue_type[resnum]];
				looks.residue_look[i]=looks.residue_func[i].
					look(vd,vm,vi.residue_param[resnum]);
			}

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

			looks.ch=vi.channels;

			return(looks);
		}
Esempio n. 3
0
		public abstract Object look(DspState vd, InfoMode vm, Object i);
Esempio n. 4
0
 public override Object look(DspState vd, InfoMode mi, Object i)
 {
     return "";
 }
Esempio n. 5
0
		// all of the real encoding details are here.  The modes, books,
		// everything
		int unpack_books(csBuffer opb)
		{

			//d* codebooks
			books=opb.read(8)+1;

			if(book_param==null || book_param.Length!=books)
				book_param=new StaticCodeBook[books];
			for(int i=0;i<books;i++)
			{
				book_param[i]=new StaticCodeBook();
				if(book_param[i].unpack(opb)!=0)
				{
					//goto err_out;
					clear();
					return(-1);
				}
			}

			// time backend settings
			times=opb.read(6)+1;
			if(time_type==null || time_type.Length!=times) time_type=new int[times];
			if(time_param==null || time_param.Length!=times)
				time_param=new Object[times];
			for(int i=0;i<times;i++)
			{
				time_type[i]=opb.read(16);
				if(time_type[i]<0 || time_type[i]>=VI_TIMEB)
				{
					//goto err_out;
					clear();
					return(-1);
				}
				time_param[i]=FuncTime.time_P[time_type[i]].unpack(this, opb);
				if(time_param[i]==null)
				{
					//goto err_out;
					clear();
					return(-1);
				}
			}

			// floor backend settings
			floors=opb.read(6)+1;
			if(floor_type==null || floor_type.Length!=floors)
				floor_type=new int[floors];
			if(floor_param==null || floor_param.Length!=floors)
				floor_param=new Object[floors];

			for(int i=0;i<floors;i++)
			{
				floor_type[i]=opb.read(16);
				if(floor_type[i]<0 || floor_type[i]>=VI_FLOORB)
				{
					//goto err_out;
					clear();
					return(-1);
				}

				floor_param[i]=FuncFloor.floor_P[floor_type[i]].unpack(this,opb);
				if(floor_param[i]==null)
				{
					//goto err_out;
					clear();
					return(-1);
				}
			}

			// residue backend settings
			residues=opb.read(6)+1;

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

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

			for(int i=0;i<residues;i++)
			{
				residue_type[i]=opb.read(16);
				if(residue_type[i]<0 || residue_type[i]>=VI_RESB)
				{
					//	goto err_out;
					clear();
					return(-1);
				}
				residue_param[i]=FuncResidue.residue_P[residue_type[i]].unpack(this,opb);
				if(residue_param[i]==null)
				{
					//	goto err_out;
					clear();
					return(-1);
				}
			}

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

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

				if((mode_param[i].windowtype>=VI_WINDOWB)||
					(mode_param[i].transformtype>=VI_WINDOWB)||
					(mode_param[i].mapping>=maps))
				{
					//      goto err_out;
					clear();
					return(-1);
				}
			}

			if(opb.read(1)!=1)
			{
				//goto err_out; // top level EOP check
				clear();
				return(-1);
			}

			return(0);
			// err_out:
			//  vorbis_info_clear(vi);
			//  return(-1);
		}
Esempio n. 6
0
		override public 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;
		}
Esempio n. 7
0
        public 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 stages=ilog(info.secondstages[j]);
                if(stages!=0)
                {
                    if(stages>maxstage)maxstage=stages;
                    look.partbooks[j]=new int[stages];
                    for(int k=0; k<stages; k++)
                    {
                        if((info.secondstages[j]&(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);
        }