public void parseBlock() {
    int index = 0;
    TrackNo = (int) EBML.readEBMLCode(data);
    index = EBML.codedSizeLength(TrackNo);
    HeaderSize += index;
    short BlockTimecode1 = (short) (data[index++] & 0xFF);
    short BlockTimecode2 = (short) (data[index++] & 0xFF);
    if (BlockTimecode1 != 0 || BlockTimecode2 != 0) {
      BlockTimecode = (BlockTimecode1 << 8) | BlockTimecode2;
    }

    int flags = data[index++] & 0xFF;
    int LaceFlag = flags & 0x06;
    int SeekableFlag = flags & 0x80;

    if (SeekableFlag == 0x80) seekable = true;
    HeaderSize += 3;
    if (LaceFlag != 0x00) {
      System.out.println("LACED");
      byte LaceCount = data[index++];
      HeaderSize += 1;
      if (LaceFlag == 0x02) {
        Sizes = readXiphLaceSizes(index, LaceCount);
      } else if (LaceFlag == 0x06) {
        Sizes = readEBMLLaceSizes(index, LaceCount);
      } else if (LaceFlag == 0x04) {
        Sizes = new int[LaceCount + 1];
        Sizes[0] = (int) (data.length - HeaderSize) / (LaceCount + 1);
        for (int s = 0; s < LaceCount; s++) Sizes[s + 1] = Sizes[0];
      } else {
        throw new RuntimeException("Unsupported lacing type flag.");
      }
    }
  }
 public int[] readEBMLLaceSizes(int index, short LaceCount) {
   int[] LaceSizes = new int[LaceCount + 1];
   LaceSizes[LaceCount] = data.length;
   int startIndex = index;
   LaceSizes[0] = (int) EBML.readEBMLCode(data, index);
   index += EBML.codedSizeLength(LaceSizes[0]);
   LaceSizes[LaceCount] -= LaceSizes[0];
   long FirstEBMLSize = LaceSizes[0];
   long LastEBMLSize = 0;
   for (int l = 0; l < LaceCount - 1; l++) {
     LastEBMLSize = EBML.readSignedEBMLCode(data, index);
     index += EBML.codedSizeLength(LastEBMLSize);
     FirstEBMLSize += LastEBMLSize;
     LaceSizes[l + 1] = (int) FirstEBMLSize;
     LaceSizes[LaceCount] -= LaceSizes[l + 1];
   }
   HeaderSize = HeaderSize + (int) (index - startIndex);
   LaceSizes[LaceCount] -= HeaderSize;
   return LaceSizes;
 }