private int parseTag(boolean id3v1) throws IOException {
		int tagSize = 0;

		// ID3 v1
		if (id3v1 && instream.seek(instream.length() - 128 - 32)) {
			if (instream.read(buf, 0, 128 + 32) == 128 + 32) {
				if (id3tag.checkID3V1(buf, 32)) {
					tagSize = 128;
					id3tag.parseID3V1(buf, 32);
				}
			} else
				return -1;
			instream.seek(0);
			tagSize += id3tag.checkAPEtagFooter(buf, 0); // APE tag footer
		}

		if ((maxOff = instream.read(buf, 0, BUFLEN)) <= 10) {
			eof = true;
			return -1;
		}

		// ID3 v2
		int sizev2 = id3tag.checkID3V2(buf, 0);
		tagSize += sizev2;
		if (sizev2 > maxOff) {
			byte[] b = new byte[sizev2];
			System.arraycopy(buf, 0, b, 0, maxOff);
			sizev2 -= maxOff;
			if ((maxOff = instream.read(b, maxOff, sizev2)) < sizev2) {
				eof = true;
				return -1;
			}
			id3tag.parseID3V2(b, 0, b.length);
			if ((maxOff = instream.read(buf, 0, BUFLEN)) <= 4)
				eof = true;
		} else if (sizev2 > 10) {
			id3tag.parseID3V2(buf, 0, sizev2);
			off = sizev2;
		}
		return tagSize;
	}