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); }
/// <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); }
/// <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); }
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); }