Starts the decode process. This will advance the JPEG stream to the start
of the image data. It also checks if that JPEG file can be decoded by this
library.

@return true if the JPEG can be decoded.
@throws IOException if an IO error occurred
550945
public boolean startDecode() throws IOException {
        if(insideSOS) {
            throw new IllegalStateException("decode already started");
        }
        if(foundEOI) {
            return false;
        }

        decodeHeader();
        int m = getMarker();
        while(m != 0xD9) {  // EOI
            if(m == 0xDA) { // SOS
                processScanHeader();
                insideSOS = true;
                currentMCURow = 0;
                reset();
                return true;
            } else {
                processMarker(m);
            }
            m = getMarker();
        }

        foundEOI = true;
        return false;
    }
312392
public void startPacket()
        throws IOException
    {
        if (_refs != null) {
            _refs.clear();
            _refCount = 0;
        }

        flushBuffer();

        _isPacket = true;
        _offset = 4;
        _buffer[0] = (byte) 0x05; // 0x05 = binary
        _buffer[1] = (byte) 0x55;
        _buffer[2] = (byte) 0x55;
        _buffer[3] = (byte) 0x55;
    }
830252
private void advance()
            throws IOException
    {
        if (compressedSliceInput == null || compressedSliceInput.remaining() == 0) {
            current = null;
            return;
        }

        // 3 byte header
        // NOTE: this must match BLOCK_HEADER_SIZE
        currentCompressedBlockOffset = toIntExact(compressedSliceInput.position());
        int b0 = compressedSliceInput.readUnsignedByte();
        int b1 = compressedSliceInput.readUnsignedByte();
        int b2 = compressedSliceInput.readUnsignedByte();

        boolean isUncompressed = (b0 & 0x01) == 1;
        int chunkLength = (b2 << 15) | (b1 << 7) | (b0 >>> 1);
        if (chunkLength < 0 || chunkLength > compressedSliceInput.remaining()) {
            throw new OrcCorruptionException(orcDataSourceId, "The chunkLength (%s) must not be negative or greater than remaining size (%s)", chunkLength, compressedSliceInput.remaining());
        }

        Slice chunk = compressedSliceInput.readSlice(chunkLength);

        if (isUncompressed) {
            current = chunk.getInput();
        }
        else {
            OrcDecompressor.OutputBuffer output = new OrcDecompressor.OutputBuffer()
            {
                @Override
                public byte[] initialize(int size)
                {
                    if (buffer == null || size > buffer.length) {
                        buffer = new byte[size];
                        bufferMemoryUsage.setBytes(buffer.length);
                    }
                    return buffer;
                }

                @Override
                public byte[] grow(int size)
                {
                    if (size > buffer.length) {
                        buffer = Arrays.copyOfRange(buffer, 0, size);
                        bufferMemoryUsage.setBytes(buffer.length);
                    }
                    return buffer;
                }
            };

            int uncompressedSize = decompressor.get().decompress((byte[]) chunk.getBase(), (int) (chunk.getAddress() - ARRAY_BYTE_BASE_OFFSET), chunk.length(), output);
            current = Slices.wrappedBuffer(buffer, 0, uncompressedSize).getInput();
        }
    }
1227611
private int nextByte() throws IOException {
        int result = 0;
        if (!endOfStream) {
            result = read();
            if (result == -1) {
                endOfStream = true;
            }
        }
        return endOfStream ? 0 : result;
    }
65206
public boolean start() {
        if (!this.isTailing.compareAndSet(false, true)) {
            return false;
        }
        final boolean willReadFromEnd = this.willReadFromEnd();
        LogWatchTailingManager.LOGGER.debug("Tailer {} ignore existing file contents.", willReadFromEnd ? "will"
                : "won't");
        this.tailer = new SplitlogTailer(this.watch.getWatchedFile(), new LogWatchTailerListener(this),
                this.delayBetweenReads, this.willReadFromEnd(), this.reopenBetweenReads, this.bufferSize);
        LogWatchTailingManager.EXECUTOR.submit(this.tailer);
        final long start = System.nanoTime();
        this.tailer.waitUntilStarted();
        final long duration = System.nanoTime() - start;
        LogWatchTailingManager.LOGGER.debug("It took {} ms for the tailing to actually start.",
                TimeUnit.NANOSECONDS.toMillis(duration));
        final long iterationNum = this.numberOfTimesThatTailerWasStarted.incrementAndGet();
        LogWatchTailingManager.LOGGER.info("Tailing #{} started for {}.", iterationNum, this.watch);
        return true;
    }
567854
public static byte[] decode(final byte[] compressed) throws IOException {
        ByteArrayInputStream byteIn = new ByteArrayInputStream(compressed);
        ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
        InflaterInputStream inflaterIn = null;
        try {
            inflaterIn = new InflaterInputStream(byteIn);
            int read;
            byte[] buffer = new byte[BUFFER_SIZE];
            do {
                read = inflaterIn.read(buffer);
                if (read > 0) {
                    byteOut.write(buffer, 0, read);
                }
            } while (read >= 0);
            return byteOut.toByteArray();
        } finally {
            inflaterIn.close();
            byteOut.close();
        }
    }
424454
@Deprecated
	public static FileMessage decode(ByteArray encodedMessage) throws IOException {
		File file = File.createTempFile("FileMessage.", null);
		file.deleteOnExit();
		return decode(encodedMessage, file);
	}
379530
public Execed start() throws IOException
	{
		Process p = getProcessBuilder().start();

		return new Execed(cmd, p, builder.redirectErrorStream());
	}
908604
public static void main(String[] args) throws IOException{
        MutableRoaringBitmap mrb = MutableRoaringBitmap.bitmapOf(1,2,3,1000); 
        System.out.println("starting with  bitmap "+ mrb);
        ByteBuffer outbb = ByteBuffer.allocate(mrb.serializedSizeInBytes());
        // If there were runs of consecutive values, you could
        // call mrb.runOptimize(); to improve compression 
        mrb.serialize(outbb);
        //
        outbb.flip();
        String serializedstring = Base64.getEncoder().encodeToString(outbb.array());
        ByteBuffer newbb = ByteBuffer.wrap(Base64.getDecoder().decode(serializedstring));
        ImmutableRoaringBitmap irb = new ImmutableRoaringBitmap(newbb);
        System.out.println("read bitmap "+ irb);        
    }
1049747
public void reader() throws IOException {
    // [START reader]
    try (ReadChannel reader = blob.reader()) {
      ByteBuffer bytes = ByteBuffer.allocate(64 * 1024);
      while (reader.read(bytes) > 0) {
        bytes.flip();
        // do something with bytes
        bytes.clear();
      }
    }
    // [END reader]
  }
386877
@Override
    public void reset() throws IOException {
        abortIfNeeded();
        // Clear up any encoded data
        currentChunkIterator = null;
        priorChunkSignature = headerSignature;
        // Reset the wrapped stream if it is mark-supported,
        // otherwise use our buffered data.
        if (is.markSupported()) {
            if (log.isDebugEnabled())
                log.debug("AwsChunkedEncodingInputStream reset "
                        + "(will reset the wrapped stream because it is mark-supported).");
            is.reset();
        }
        else {
            if (log.isDebugEnabled())
                log.debug("AwsChunkedEncodingInputStream reset "
                        + "(will use the buffer of the decoded stream).");
            if (null == decodedStreamBuffer) {
                throw new IOException("Cannot reset the stream because the mark is not set.");
            }
            decodedStreamBuffer.startReadBuffer();
        }

        currentChunkIterator = null;
        isAtStart = true;
        isTerminating = false;
    }
542068
private void initOut() throws IOException
   {
      if (out == null)
      {
         FileOutputStream os = PrivilegedFileHelper.fileOutputStream(logFile, false);
         out = os.getChannel();
      }
   }
829107
private void processEncodedPayload() throws IOException {
    if (!readPayload) {
      payloadSpanCollector.reset();
      collect(payloadSpanCollector);
      Collection<byte[]> originalPayloadCollection = payloadSpanCollector
          .getPayloads();
      if (originalPayloadCollection.iterator().hasNext()) {
        byte[] payload = originalPayloadCollection.iterator().next();
        if (payload == null) {
          throw new IOException("no payload");
        }
        MtasPayloadDecoder payloadDecoder = new MtasPayloadDecoder();
        payloadDecoder.init(startPosition(), payload);
        mtasPosition = payloadDecoder.getMtasPosition();
      } else {
        throw new IOException("no payload");
      }
    }
  }
1200997
protected final boolean readLine() throws IOException {
		if (this.stream == null || this.overLimit) {
			return false;
		}

		int countInWrapBuffer = 0;

		// position of matching positions in the delimiter byte array
		int delimPos = 0;

		while (true) {
			if (this.readPos >= this.limit) {
				// readBuffer is completely consumed. Fill it again but keep partially read delimiter bytes.
				if (!fillBuffer(delimPos)) {
					int countInReadBuffer = delimPos;
					if (countInWrapBuffer + countInReadBuffer > 0) {
						// we have bytes left to emit
						if (countInReadBuffer > 0) {
							// we have bytes left in the readBuffer. Move them into the wrapBuffer
							if (this.wrapBuffer.length - countInWrapBuffer < countInReadBuffer) {
								// reallocate
								byte[] tmp = new byte[countInWrapBuffer + countInReadBuffer];
								System.arraycopy(this.wrapBuffer, 0, tmp, 0, countInWrapBuffer);
								this.wrapBuffer = tmp;
							}

							// copy readBuffer bytes to wrapBuffer
							System.arraycopy(this.readBuffer, 0, this.wrapBuffer, countInWrapBuffer, countInReadBuffer);
							countInWrapBuffer += countInReadBuffer;
						}

						this.offset += countInWrapBuffer;
						setResult(this.wrapBuffer, 0, countInWrapBuffer);
						return true;
					} else {
						return false;
					}
				}
			}

			int startPos = this.readPos - delimPos;
			int count;

			// Search for next occurrence of delimiter in read buffer.
			while (this.readPos < this.limit && delimPos < this.delimiter.length) {
				if ((this.readBuffer[this.readPos]) == this.delimiter[delimPos]) {
					// Found the expected delimiter character. Continue looking for the next character of delimiter.
					delimPos++;
				} else {
					// Delimiter does not match.
					// We have to reset the read position to the character after the first matching character
					//   and search for the whole delimiter again.
					readPos -= delimPos;
					delimPos = 0;
				}
				readPos++;
			}

			// check why we dropped out
			if (delimPos == this.delimiter.length) {
				// we found a delimiter
				int readBufferBytesRead = this.readPos - startPos;
				this.offset += countInWrapBuffer + readBufferBytesRead;
				count = readBufferBytesRead - this.delimiter.length;

				// copy to byte array
				if (countInWrapBuffer > 0) {
					// check wrap buffer size
					if (this.wrapBuffer.length < countInWrapBuffer + count) {
						final byte[] nb = new byte[countInWrapBuffer + count];
						System.arraycopy(this.wrapBuffer, 0, nb, 0, countInWrapBuffer);
						this.wrapBuffer = nb;
					}
					if (count >= 0) {
						System.arraycopy(this.readBuffer, 0, this.wrapBuffer, countInWrapBuffer, count);
					}
					setResult(this.wrapBuffer, 0, countInWrapBuffer + count);
					return true;
				} else {
					setResult(this.readBuffer, startPos, count);
					return true;
				}
			} else {
				// we reached the end of the readBuffer
				count = this.limit - startPos;
				
				// check against the maximum record length
				if (((long) countInWrapBuffer) + count > this.lineLengthLimit) {
					throw new IOException("The record length exceeded the maximum record length (" + 
							this.lineLengthLimit + ").");
				}

				// Compute number of bytes to move to wrapBuffer
				// Chars of partially read delimiter must remain in the readBuffer. We might need to go back.
				int bytesToMove = count - delimPos;
				// ensure wrapBuffer is large enough
				if (this.wrapBuffer.length - countInWrapBuffer < bytesToMove) {
					// reallocate
					byte[] tmp = new byte[Math.max(this.wrapBuffer.length * 2, countInWrapBuffer + bytesToMove)];
					System.arraycopy(this.wrapBuffer, 0, tmp, 0, countInWrapBuffer);
					this.wrapBuffer = tmp;
				}

				// copy readBuffer to wrapBuffer (except delimiter chars)
				System.arraycopy(this.readBuffer, startPos, this.wrapBuffer, countInWrapBuffer, bytesToMove);
				countInWrapBuffer += bytesToMove;
				// move delimiter chars to the beginning of the readBuffer
				System.arraycopy(this.readBuffer, this.readPos - delimPos, this.readBuffer, 0, delimPos);

			}
		}
	}
1097262
public IDLProxyObject decode(byte[] bb) throws IOException {
        if (bb == null) {
            throw new IllegalArgumentException("param 'bb' is null");
        }
        Object object = codec.decode(bb);
        return new IDLProxyObject(codec, object, cls);

    }
1255749
public byte decodeBuffer(InputStream in)[] throws IOException {
        ByteArrayOutputStream outStream = new ByteArrayOutputStream();
        decodeBuffer(in, outStream);
        return (outStream.toByteArray());
    }
1077443
public function processFile()
    {
        /** don't reparse the whole file. */
        if (!$this->newFile)
        {
            return true;
        }

        if (!file_exists($this->file))
        {
            echo "<br>Error: File " . ($this->file) . "does not exists!";
            exit;
        }

        $this->debug("Stating Processing of " . $this->newFile, 0, __FILE__, __LINE__);

        $i = 0;
        $exitAll = 0;
        /** Open the JPEG in binary safe reading mode */
        $fp = fopen($this->file, "rb");

        $this->ImageInfo["h"]["FileName"] = $this->file;
        $this->ImageInfo["h"]["FileSize"] = filesize($this->file);
        /** Size of the File */
        $this->ImageInfo["h"]["FileDateTime"] = filectime($this->file);
        /** File node change time */

        /** check whether jped image or not */
        $a = fgetc($fp);
        if (ord($a) != 0xff || ord(fgetc($fp)) != M_SOI)
        {
            $this->debug("Not a JPEG FILE", 1);
            $this->errorno = 1;
            $this->errorstr = "File '" . $this->file . "' is not a JPEG File!";
        }
        $tmpTestLevel = 0;
        /** Examines each byte one-by-one */
        while (!feof($fp))
        {
            $marker = -1;
            for ($a = 0; $a < 7; $a++)
            {
                $marker = fgetc($fp);
                if (ord($marker) != 0xff)
                {
                    break;
                }
                if ($a >= 6)
                {
                    $this->errno = 10;
                    $this->errstr = "too many padding bytes!";
                    $this->debug($this->errstr, 1);
                    return false;
                }
            }

            if (ord($marker) == 0xff)
            {
                // 0xff is legal padding, but if we get that many, something wrong.
                $this->errno = 10;
                $this->errstr = "too many padding bytes!";
                $this->debug($this->errstr, 1);
            }

            $marker = ord($marker);
            $this->sections[$this->currSection]["type"] = $marker;

            // Read the length of the section.
            $lh = ord(fgetc($fp));
            $ll = ord(fgetc($fp));

            $itemLength = ($lh << 8) | $ll;

            if ($itemLength < 2)
            {
                $this->errno = 11;
                $this->errstr = "invalid marker";
                $this->debug($this->errstr, 1);
            }
            $this->sections[$this->currSection]["size"] = $itemLength;

            $tmpDataArr = array();
            /** Temporary Array */

            $tmpStr = fread($fp, $itemLength - 2);
            /*
            $tmpDataArr[] = chr($lh);
            $tmpDataArr[] = chr($ll);

            $chars = preg_split('//', $tmpStr, -1, PREG_SPLIT_NO_EMPTY);
            $tmpDataArr = array_merge($tmpDataArr,$chars);

            $data = $tmpDataArr;
            */
            $data = chr($lh) . chr($ll) . $tmpStr;

            //$this->sections[$this->currSection]["data"] = $data;

            $this->debug("<hr><h1>" . $this->currSection . ":</h1>");
            //print_r($data);
            $this->debug("<hr>");

            //if(count($data) != $itemlen) {
            if (strlen($data) != $itemLength)
            {
                $this->errno = 12;
                $this->errstr = "Premature end of file?";
                $this->debug($this->errstr, 1);
            }

            $this->currSection++;
            /** */

            switch ($marker)
            {
                case M_SOS:
                    $this->debug("<br>Found '" . M_SOS . "' Section, Prcessing it... <br>");;
                    // If reading entire image is requested, read the rest of the data.
                    if ($this->ImageReadMode & $this->ReadMode["READ_IMAGE"])
                    {
                        // Determine how much file is left.
                        $cp = ftell($fp);
                        fseek($fp, 0, SEEK_END);
                        $ep = ftell($fp);
                        fseek($fp, $cp, SEEK_SET);

                        $size = $ep - $cp;
                        $got = fread($fp, $size);

                        $this->sections[$this->currSection]["data"] = $got;
                        $this->sections[$this->currSection]["size"] = $size;
                        $this->sections[$this->currSection]["type"] = PSEUDO_IMAGE_MARKER;
                        $this->currSection++;
                        $HaveAll = 1;
                        $exitAll = 1;
                    }
                    $this->debug("<br>'" . M_SOS . "' Section, PROCESSED<br>");
                    break;
                case M_COM: // Comment section
                    $this->debug("<br>Found '" . M_COM . "'(Comment) Section, Processing<br>");
                    $this->process_COM($data, $itemLength);
                    $this->debug("<br>'" . M_COM . "'(Comment) Section, PROCESSED<br>");

                    $tmpTestLevel++;
                    break;
                case M_SOI:
                    $this->debug(" <br> === START OF IMAGE =====<br>");
                    break;
                case M_EOI:
                    $this->debug(" <br>=== END OF IMAGE =====<br> ");
                    break;
                case M_JFIF:
                    // Regular jpegs always have this tag, exif images have the exif
                    // marker instead, althogh ACDsee will write images with both markers.
                    // this program will re-create this marker on absence of exif marker.
                    // hence no need to keep the copy from the file.
                    //echo " <br> === M_JFIF =====<br>";
                    $this->sections[--$this->currSection]["data"] = "";
                    break;
                case M_EXIF:
                    // Seen files from some 'U-lead' software with Vivitar scanner
                    // that uses marker 31 for non exif stuff.  Thus make sure
                    // it says 'Exif' in the section before treating it as exif.
                    $this->debug("<br>Found '" . M_EXIF . "'(Exif) Section, Proccessing<br>");
                    $this->exifSection = $this->currSection - 1;
                    if (($this->ImageReadMode & $this->ReadMode["READ_EXIF"]) && ($data[2] . $data[3] . $data[4] . $data[5]) == "Exif")
                    {
                        $this->process_EXIF($data, $itemLength);
                    }
                    else
                    {
                        // Discard this section.
                        $this->sections[--$this->currSection]["data"] = "";
                    }
                    $this->debug("<br>'" . M_EXIF . "'(Exif) Section, PROCESSED<br>");
                    $tmpTestLevel++;
                    break;
                case M_SOF0:
                case M_SOF1:
                case M_SOF2:
                case M_SOF3:
                case M_SOF5:
                case M_SOF6:
                case M_SOF7:
                case M_SOF9:
                case M_SOF10:
                case M_SOF11:
                case M_SOF13:
                case M_SOF14:
                case M_SOF15:
                    $this->debug("<br>Found M_SOFn Section, Processing<br>");
                    $this->process_SOFn($data, $marker);
                    $this->debug("<br>M_SOFn Section, PROCESSED<br>");
                    break;
                case M_EXIF_EXT: // 226 - Exif Extended Data
                    $this->debug("<br><b>Found 'Exif Extended Data' Section, Processing</b><br>-------------------------------<br>");
                    $this->process_EXT_EXIF($data, $itemLength);
                    $this->debug("<br>--------------------------PROCESSED<br>");
                    break;

                case M_QUANTA: // 219 - Quantisation Table Definition
                    $this->debug("<br><b>Found 'Quantisation Table Definition' Section, Processing</b><br>-------------------------------<br>");
                    $this->debug("<br>--------------------------PROCESSED<br>");
                    break;

                case M_HUFF: // Huffman Table
                    $this->debug("<br><b>Found 'Huffman Table' Section, Processing</b><br>-------------------------------<br>");
                    $this->debug("<br>--------------------------PROCESSED<br>");
                    break;

                default:
                    $this->debug("DEFAULT: Jpeg section marker 0x$marker x size $itemLength\n");
            }
            $i++;
            if ($exitAll == 1)
            {
                break;
            }
            //if($tmpTestLevel == 2)  break;
        }
        fclose($fp);
        $this->newFile = 0;
        return null;
    }