Exemple #1
0
        internal void init_decode(StaticCodeBook s)
        {
            c         = s;
            entries   = s.entries;
            dim       = s.dim;
            valuelist = s.unquantize();

            decode_tree = make_decode_tree();
        }
Exemple #2
0
        internal int init_decode(StaticCodeBook s)
        {
            c         = s;
            entries   = s.entries;
            dim       = s.dim;
            valuelist = s.unquantize();

            decode_tree = make_decode_tree();
            if (decode_tree == null)
            {
                clear();
                return(-1);
            }

            return(0);
        }
Exemple #3
0
        /*
         * int init_encode(StaticCodeBook s){
         *      //memset(c,0,sizeof(codebook));
         *      c=s;
         *      entries=s.entries;
         *      dim=s.dim;
         *      codelist=make_words(s.lengthlist, s.entries);
         *      valuelist=s.unquantize();
         *      return(0);
         * }
         */

        internal int init_decode(StaticCodeBook s)
        {
            //memset(c,0,sizeof(codebook));
            c         = s;
            entries   = s.entries;
            dim       = s.dim;
            valuelist = s.unquantize();

            decode_tree = make_decode_tree();
            if (decode_tree == null)
            {
                //goto err_out;
                clear();
                return(-1);
            }
            return(0);
            //  err_out:
            //    vorbis_book_clear(c);
            //    return(-1);
        }
        // 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);
        }
Exemple #5
0
        /*
          int init_encode(StaticCodeBook s){
            //memset(c,0,sizeof(codebook));
            c=s;
            entries=s.entries;
            dim=s.dim;
            codelist=make_words(s.lengthlist, s.entries);
            valuelist=s.unquantize();
            return(0);
          }
        */
        internal int init_decode(StaticCodeBook s)
        {
            //memset(c,0,sizeof(codebook));
            c=s;
            entries=s.entries;
            dim=s.dim;
            valuelist=s.unquantize();

            decode_tree=make_decode_tree();
            if(decode_tree==null)
            {
                //goto err_out;
                clear();
                return(-1);
            }
            return(0);
            //  err_out:
            //    vorbis_book_clear(c);
            //    return(-1);
        }
Exemple #6
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);
		}
Exemple #7
0
        void unpack_books(csBuffer opb)
        {
            books      = opb.read(8) + 1;
            book_param = new StaticCodeBook[books];
            for (int i = 0; i < books; i++)
            {
                book_param[i] = new StaticCodeBook();
                book_param[i].unpack(opb);
            }

            times = opb.read(6) + 1;
            for (int i = 0; i < times; i++)
            {
                opb.read(16);
            }

            floors      = opb.read(6) + 1;
            floor_funcs = new Floor1[floors];
            floor_param = new object[floors];
            for (int i = 0; i < floors; i++)
            {
                int type = opb.read(16);
                if (type != 1)
                {
                    throw new csorbisException("floor type must be 1");
                }
                floor_funcs[i] = new Floor1();
                floor_param[i] = floor_funcs[i].unpack(this, opb);
            }

            residues      = opb.read(6) + 1;
            residue_funcs = new FuncResidue[residues];
            residue_param = new object[residues];
            for (int i = 0; i < residues; i++)
            {
                int type = opb.read(16);
                if (type > 2)
                {
                    throw new csorbisException("residue type must be <= 2");
                }
                residue_funcs[i] = FuncResidue.make(type);
                residue_param[i] = residue_funcs[i].unpack(this, opb);
            }

            maps      = opb.read(6) + 1;
            map_funcs = new FuncMapping[maps];
            map_param = new object[maps];
            for (int i = 0; i < maps; i++)
            {
                int type = opb.read(16);
                if (type != 0)
                {
                    throw new csorbisException("mapping type must be 0");
                }
                map_funcs[i] = new Mapping0();
                map_param[i] = map_funcs[i].unpack(this, opb);
            }

            modes      = opb.read(6) + 1;
            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);
            }
            opb.read(1);
        }