decodeHeader method

bool decodeHeader()

Implementation

bool decodeHeader() {
  final bits = input.readUint24();

  final keyFrame = (bits & 1) == 0;
  if (!keyFrame) {
    return false;
  }

  if (((bits >> 1) & 7) > 3) {
    return false; // unknown profile
  }

  if (((bits >> 4) & 1) == 0) {
    return false; // first frame is invisible!
  }

  _frameHeader.keyFrame = (bits & 1) == 0;
  _frameHeader.profile = (bits >> 1) & 7;
  _frameHeader.show = (bits >> 4) & 1;
  _frameHeader.partitionLength = (bits >> 5);

  final signature = input.readUint24();
  if (signature != VP8_SIGNATURE) {
    return false;
  }

  webp.width = input.readUint16();
  webp.height = input.readUint16();

  return true;
}