@VisibleForTesting
  public static boolean endsWithEOI(CloseableReference<PooledByteBuffer> bytesRef, int length) {
    PooledByteBuffer buffer = bytesRef.get();
    return length >= 2
        && buffer.read(length - 2) == (byte) JfifUtil.MARKER_FIRST_BYTE
        && buffer.read(length - 1) == (byte) JfifUtil.MARKER_EOI;
  }
Decodes a byteArray containing jpeg encoded bytes into a purgeable bitmap

<p>Adds a JFIF End-Of-Image marker if needed before decoding.

@param bytesRef the byte buffer that contains the encoded bytes
@param length the number of encoded bytes in the buffer
@param options the options passed to the BitmapFactory
@return
imagepipeline-native/src/main/java/com/facebook/imagepipeline/nativecode/DalvikPurgeableDecoder.java