private void readGifInfo() throws IOException {
    validateAndIgnoreHeader();

    final int[] control = new int[] {0, 0};

    boolean done = false;
    while (!done) {
      int code = readAndWriteNextByte();
      switch (code) {
        case 0x21: // extension
          int extCode = readAndWriteNextByte();
          switch (extCode) {
            case 0xff: // application extension
              readBlock();
              if (isNetscape()) {
                readNetscapeExtension();
              } else {
                skipExtension();
              }
              break;
            case 0xf9: // graphics control extension
              readGraphicsControlExtension(control);
              break;
            case 0x01: // plain text extension, counts as a frame
              addFrame(control);
              skipExtension();
              break;
            default:
              skipExtension();
          }
          break;
        case 0x2C: // image
          addFrame(control);
          skipImage();
          // count as a frame
          break;
        case 0x3b: // terminator
          done = true;
          break;
        default:
          throw new IOException("Unknown block header [" + Integer.toHexString(code) + "]");
      }
    }
  }
@param is InputStream to decode
@param os OutputStream to write fixed version of gif, if needed. (optional)
animated-gif-lite/src/main/java/com/facebook/animated/giflite/decoder/GifMetadataDecoder.java