public GifHeader parseHeader() {
        if (rawData == null) {
            throw new IllegalStateException("You must call setData() before parseHeader()");
        }
        if (err()) {
            return header;
        }

        readHeader();
        if (!err()) {
            readContents();
            if (header.frameCount < 0) {
                header.status = STATUS_FORMAT_ERROR;
            }
        }

        return header;
    }
A class responsible for creating {@link GifHeader}s from data representing animated
gifs.
core/src/main/java/com/bumptech/glide/gifdecoder/GifHeaderParser.java