docs: private void decodeBitmapData(GifFrame frame) {
          workBufferSize = 0;
          workBufferPosition = 0;
          if (frame != null) {
              // Jump to the frame start position.
              rawData.position(frame.bufferFrameStart);
          }
  
          int npix = (frame == null) ? header.width * header.height : frame.iw * frame.ih;
          int available, clear, codeMask, codeSize, endOfInformation, inCode, oldCode, bits, code, count,
                  i, datum,
                  dataSize, first, top, bi, pi;
  
          if (mainPixels == null || mainPixels.length < npix) {
              // Allocate new pixel array.
              mainPixels = bitmapProvider.obtainByteArray(npix);
          }
          if (prefix == null) {
              prefix = new short[MAX_STACK_SIZE];
          }
          if (suffix == null) {
              suffix = new byte[MAX_STACK_SIZE];
          }
          if (pixelStack == null) {
              pixelStack = new byte[MAX_STACK_SIZE + 1];
          }
  
          // Initialize GIF data stream decoder.
          dataSize = readByte();
          clear = 1 << dataSize;
          endOfInformation = clear + 1;
          available = clear + 2;
          oldCode = NULL_CODE;
          codeSize = dataSize + 1;
          codeMask = (1 << codeSize) - 1;
          for (code = 0; code < clear; code++) {
              // XXX ArrayIndexOutOfBoundsException.
              prefix[code] = 0;
              suffix[code] = (byte) code;
          }
  
          // Decode GIF pixel stream.
          datum = bits = count = first = top = pi = bi = 0;
          for (i = 0; i < npix; ) {
              // Load bytes until there are enough bits for a code.
              if (count == 0) {
                  // Read a new data block.
                  count = readBlock();
                  if (count <= 0) {
                      status = STATUS_PARTIAL_DECODE;
                      break;
                  }
                  bi = 0;
              }
  
              datum += (((int) block[bi]) & 0xff) << bits;
              bits += 8;
              bi++;
              count--;
  
              while (bits >= codeSize) {
                  // Get the next code.
                  code = datum & codeMask;
                  datum >>= codeSize;
                  bits -= codeSize;
  
                  // Interpret the code.
                  if (code == clear) {
                      // Reset decoder.
                      codeSize = dataSize + 1;
                      codeMask = (1 << codeSize) - 1;
                      available = clear + 2;
                      oldCode = NULL_CODE;
                      continue;
                  }
  
                  if (code > available) {
                      status = STATUS_PARTIAL_DECODE;
                      break;
                  }
  
                  if (code == endOfInformation) {
                      break;
                  }
  
                  if (oldCode == NULL_CODE) {
                      pixelStack[top++] = suffix[code];
                      oldCode = code;
                      first = code;
                      continue;
                  }
                  inCode = code;
                  if (code >= available) {
                      pixelStack[top++] = (byte) first;
                      code = oldCode;
                  }
                  while (code >= clear) {
                      pixelStack[top++] = suffix[code];
                      code = prefix[code];
                  }
                  first = ((int) suffix[code]) & 0xff;
                  pixelStack[top++] = (byte) first;
  
                  // Add a new string to the string table.
                  if (available < MAX_STACK_SIZE) {
                      prefix[available] = (short) oldCode;
                      suffix[available] = (byte) first;
                      available++;
                      if (((available & codeMask) == 0) && (available < MAX_STACK_SIZE)) {
                          codeSize++;
                          codeMask += available;
                      }
                  }
                  oldCode = inCode;
  
                  while (top > 0) {
                      // Pop a pixel off the pixel stack.
                      mainPixels[pi++] = pixelStack[--top];
                      i++;
                  }
              }
          }
  
          // Clear missing pixels.
          for (i = pi; i < npix; i++) {
              mainPixels[i] = 0;
          }
      }