@Test public void testReadVorbisModes() throws ParserException { byte[] data = OggTestData.getSetupHeaderData(); ParsableByteArray headerData = new ParsableByteArray(data, data.length); VorbisUtil.Mode[] modes = VorbisUtil.readVorbisModes(headerData, 2); assertThat(modes).hasLength(2); assertThat(modes[0].blockFlag).isFalse(); assertThat(modes[0].mapping).isEqualTo(0); assertThat(modes[0].transformType).isEqualTo(0); assertThat(modes[0].windowType).isEqualTo(0); assertThat(modes[1].blockFlag).isTrue(); assertThat(modes[1].mapping).isEqualTo(1); assertThat(modes[1].transformType).isEqualTo(0); assertThat(modes[1].windowType).isEqualTo(0); }
public static Mode[] readVorbisModes(ParsableByteArray headerData, int channels) throws ParserException { verifyVorbisHeaderCapturePattern(0x05, headerData, false); int numberOfBooks = headerData.readUnsignedByte() + 1; VorbisBitArray bitArray = new VorbisBitArray(headerData.data); bitArray.skipBits(headerData.getPosition() * 8); for (int i = 0; i < numberOfBooks; i++) { readBook(bitArray); } int timeCount = bitArray.readBits(6) + 1; for (int i = 0; i < timeCount; i++) { if (bitArray.readBits(16) != 0x00) { throw new ParserException("placeholder of time domain transforms not zeroed out"); } } readFloors(bitArray); readResidues(bitArray); readMappings(channels, bitArray); Mode[] modes = readModes(bitArray); if (!bitArray.readBit()) { throw new ParserException("framing bit after modes not set as expected"); } return modes; }
VorbisUtil { public static Mode[] readVorbisModes(ParsableByteArray headerData, int channels) throws ParserException { verifyVorbisHeaderCapturePattern(0x05, headerData, false); int numberOfBooks = headerData.readUnsignedByte() + 1; VorbisBitArray bitArray = new VorbisBitArray(headerData.data); bitArray.skipBits(headerData.getPosition() * 8); for (int i = 0; i < numberOfBooks; i++) { readBook(bitArray); } int timeCount = bitArray.readBits(6) + 1; for (int i = 0; i < timeCount; i++) { if (bitArray.readBits(16) != 0x00) { throw new ParserException("placeholder of time domain transforms not zeroed out"); } } readFloors(bitArray); readResidues(bitArray); readMappings(channels, bitArray); Mode[] modes = readModes(bitArray); if (!bitArray.readBit()) { throw new ParserException("framing bit after modes not set as expected"); } return modes; } }
VorbisUtil { public static Mode[] readVorbisModes(ParsableByteArray headerData, int channels) throws ParserException { verifyVorbisHeaderCapturePattern(0x05, headerData, false); int numberOfBooks = headerData.readUnsignedByte() + 1; VorbisBitArray bitArray = new VorbisBitArray(headerData.data); bitArray.skipBits(headerData.getPosition() * 8); for (int i = 0; i < numberOfBooks; i++) { readBook(bitArray); } int timeCount = bitArray.readBits(6) + 1; for (int i = 0; i < timeCount; i++) { if (bitArray.readBits(16) != 0x00) { throw new ParserException("placeholder of time domain transforms not zeroed out"); } } readFloors(bitArray); readResidues(bitArray); readMappings(channels, bitArray); Mode[] modes = readModes(bitArray); if (!bitArray.readBit()) { throw new ParserException("framing bit after modes not set as expected"); } return modes; } private  VorbisUtil(); }
VorbisUtil { public static Mode[] readVorbisModes(ParsableByteArray headerData, int channels) throws ParserException { verifyVorbisHeaderCapturePattern(0x05, headerData, false); int numberOfBooks = headerData.readUnsignedByte() + 1; VorbisBitArray bitArray = new VorbisBitArray(headerData.data); bitArray.skipBits(headerData.getPosition() * 8); for (int i = 0; i < numberOfBooks; i++) { readBook(bitArray); } int timeCount = bitArray.readBits(6) + 1; for (int i = 0; i < timeCount; i++) { if (bitArray.readBits(16) != 0x00) { throw new ParserException("placeholder of time domain transforms not zeroed out"); } } readFloors(bitArray); readResidues(bitArray); readMappings(channels, bitArray); Mode[] modes = readModes(bitArray); if (!bitArray.readBit()) { throw new ParserException("framing bit after modes not set as expected"); } return modes; } private  VorbisUtil(); static int iLog(int x); static VorbisIdHeader readVorbisIdentificationHeader(ParsableByteArray headerData); static CommentHeader readVorbisCommentHeader(ParsableByteArray headerData); static boolean verifyVorbisHeaderCapturePattern(int headerType, ParsableByteArray header,
      boolean quiet); static Mode[] readVorbisModes(ParsableByteArray headerData, int channels); }
VorbisUtil { public static Mode[] readVorbisModes(ParsableByteArray headerData, int channels) throws ParserException { verifyVorbisHeaderCapturePattern(0x05, headerData, false); int numberOfBooks = headerData.readUnsignedByte() + 1; VorbisBitArray bitArray = new VorbisBitArray(headerData.data); bitArray.skipBits(headerData.getPosition() * 8); for (int i = 0; i < numberOfBooks; i++) { readBook(bitArray); } int timeCount = bitArray.readBits(6) + 1; for (int i = 0; i < timeCount; i++) { if (bitArray.readBits(16) != 0x00) { throw new ParserException("placeholder of time domain transforms not zeroed out"); } } readFloors(bitArray); readResidues(bitArray); readMappings(channels, bitArray); Mode[] modes = readModes(bitArray); if (!bitArray.readBit()) { throw new ParserException("framing bit after modes not set as expected"); } return modes; } private  VorbisUtil(); static int iLog(int x); static VorbisIdHeader readVorbisIdentificationHeader(ParsableByteArray headerData); static CommentHeader readVorbisCommentHeader(ParsableByteArray headerData); static boolean verifyVorbisHeaderCapturePattern(int headerType, ParsableByteArray header,
      boolean quiet); static Mode[] readVorbisModes(ParsableByteArray headerData, int channels);  }