internal static VorbisMode Init(VorbisStreamDecoder vorbis, DataPacket packet) { var mode = new VorbisMode(vorbis); mode.BlockFlag = packet.ReadBit(); mode.WindowType = (int)packet.ReadBits(16); mode.TransformType = (int)packet.ReadBits(16); var mapping = (int)packet.ReadBits(8); if (mode.WindowType != 0 || mode.TransformType != 0 || mapping >= vorbis.Maps.Length) throw new InvalidDataException(); mode.Mapping = vorbis.Maps[mapping]; mode.BlockSize = mode.BlockFlag ? vorbis.Block1Size : vorbis.Block0Size; // now pre-calc the window(s)... if (mode.BlockFlag) { // long block mode._windows = new float[4][]; mode._windows[0] = new float[vorbis.Block1Size]; mode._windows[1] = new float[vorbis.Block1Size]; mode._windows[2] = new float[vorbis.Block1Size]; mode._windows[3] = new float[vorbis.Block1Size]; } else { // short block mode._windows = new float[1][]; mode._windows[0] = new float[vorbis.Block0Size]; } mode.CalcWindows(); return mode; }
internal static VorbisMode Init(VorbisStreamDecoder vorbis, DataPacket packet) { VorbisMode vorbisMode = new VorbisMode(vorbis); vorbisMode.BlockFlag = packet.ReadBit(); vorbisMode.WindowType = (int)packet.ReadBits(16); vorbisMode.TransformType = (int)packet.ReadBits(16); int num = (int)packet.ReadBits(8); if (vorbisMode.WindowType != 0 || vorbisMode.TransformType != 0 || num >= vorbis.Maps.Length) { throw new InvalidDataException(); } vorbisMode.Mapping = vorbis.Maps[num]; vorbisMode.BlockSize = (vorbisMode.BlockFlag ? vorbis.Block1Size : vorbis.Block0Size); if (vorbisMode.BlockFlag) { vorbisMode._windows = new float[4][]; vorbisMode._windows[0] = new float[vorbis.Block1Size]; vorbisMode._windows[1] = new float[vorbis.Block1Size]; vorbisMode._windows[2] = new float[vorbis.Block1Size]; vorbisMode._windows[3] = new float[vorbis.Block1Size]; } else { vorbisMode._windows = new float[1][]; vorbisMode._windows[0] = new float[vorbis.Block0Size]; } vorbisMode.CalcWindows(); return(vorbisMode); }
internal static VorbisMode Init(VorbisStreamDecoder vorbis, DataPacket packet) { VorbisMode vorbisMode = new VorbisMode(vorbis); vorbisMode.BlockFlag = packet.ReadBit(); vorbisMode.WindowType = (int) packet.ReadBits(16); vorbisMode.TransformType = (int) packet.ReadBits(16); int index = (int) packet.ReadBits(8); if (vorbisMode.WindowType != 0 || vorbisMode.TransformType != 0 || index >= vorbis.Maps.Length) throw new InvalidDataException(); vorbisMode.Mapping = vorbis.Maps[index]; vorbisMode.BlockSize = vorbisMode.BlockFlag ? vorbis.Block1Size : vorbis.Block0Size; if (vorbisMode.BlockFlag) { vorbisMode._windows = new float[4][]; vorbisMode._windows[0] = new float[vorbis.Block1Size]; vorbisMode._windows[1] = new float[vorbis.Block1Size]; vorbisMode._windows[2] = new float[vorbis.Block1Size]; vorbisMode._windows[3] = new float[vorbis.Block1Size]; } else { vorbisMode._windows = new float[1][]; vorbisMode._windows[0] = new float[vorbis.Block0Size]; } vorbisMode.CalcWindows(); return vorbisMode; }
internal static VorbisMode Init(VorbisStreamDecoder vorbis, DataPacket packet) { var mode = new VorbisMode(vorbis); mode.BlockFlag = packet.ReadBit(); mode.WindowType = (int)packet.ReadBits(16); mode.TransformType = (int)packet.ReadBits(16); var mapping = (int)packet.ReadBits(8); if (mode.WindowType != 0 || mode.TransformType != 0 || mapping >= vorbis.Maps.Length) { throw new Exception(); } mode.Mapping = vorbis.Maps[mapping]; mode.BlockSize = mode.BlockFlag ? vorbis.Block1Size : vorbis.Block0Size; // now pre-calc the window(s)... if (mode.BlockFlag) { // long block mode._windows = new float[4][]; mode._windows[0] = new float[vorbis.Block1Size]; mode._windows[1] = new float[vorbis.Block1Size]; mode._windows[2] = new float[vorbis.Block1Size]; mode._windows[3] = new float[vorbis.Block1Size]; } else { // short block mode._windows = new float[1][]; mode._windows[0] = new float[vorbis.Block0Size]; } mode.CalcWindows(); return(mode); }