FastImage::parseSizeForJPEG PHP Method

parseSizeForJPEG() private method

private parseSizeForJPEG ( )
    private function parseSizeForJPEG()
    {
        $state = null;
        $i = 0;
        while (true) {
            switch ($state) {
                default:
                    $this->getChars(2);
                    $state = 'started';
                    break;
                case 'started':
                    $b = $this->getByte();
                    if ($b === false) {
                        return false;
                    }
                    $state = $b == 0xff ? 'sof' : 'started';
                    break;
                case 'sof':
                    $b = $this->getByte();
                    if (in_array($b, range(0xe0, 0xef))) {
                        $state = 'skipframe';
                    } elseif (in_array($b, array_merge(range(0xc0, 0xc3), range(0xc5, 0xc7), range(0xc9, 0xcb), range(0xcd, 0xcf)))) {
                        $state = 'readsize';
                    } elseif ($b == 0xff) {
                        $state = 'sof';
                    } else {
                        $state = 'skipframe';
                    }
                    break;
                case 'skipframe':
                    $skip = $this->readInt($this->getChars(2)) - 2;
                    $state = 'doskip';
                    break;
                case 'doskip':
                    $this->getChars($skip);
                    $state = 'started';
                    break;
                case 'readsize':
                    $c = $this->getChars(7);
                    return array($this->readInt(substr($c, 5, 2)), $this->readInt(substr($c, 3, 2)));
            }
        }
    }