csvorbis.StaticCodeBook.maptype1_quantvals C# (CSharp) Method

maptype1_quantvals() private method

private maptype1_quantvals ( ) : int
return int
        internal int maptype1_quantvals()
        {
            int vals=(int)(Math.Floor(Math.Pow(entries,1.0/dim)));

            // the above *should* be reliable, but we'll not assume that FP is
            // ever reliable when bitstream sync is at stake; verify via integer
            // means that vals really is the greatest value of dim for which
            // vals^b->bim <= b->entries
            // treat the above as an initial guess
            while(true)
            {
                int acc=1;
                int acc1=1;
                for(int i=0;i<dim;i++)
                {
                    acc*=vals;
                    acc1*=vals+1;
                }
                if(acc<=entries && acc1>entries){	return(vals); }
                else
                {
                    if(acc>entries){ vals--; }
                    else{ vals++; }
                }
            }
        }