p8BitImageCompressedByteBuffer.position(0);
final Pointer lPointerTo8BitImageCompressedByteBuffer = Pointer.pointerToBytes(p8BitImageCompressedByteBuffer);
TurbojpegLibrary.tjDecompressHeader(mPointerToDecompressor,
lPointerTo8BitImageCompressedByteBuffer,
lCompressedImageBufferSize,
mPointerToWidth,
mPointerToHeight);
lPointerTo8BitImageCompressedByteBuffer.release();
final int lWidth = mPointerToWidth.getInt();
final int lHeight = mPointerToHeight.getInt();
allocateDecompressedBuffer(lWidth * lHeight);
mDecompressedImageByteBuffer.rewind();
final int lErrorCode = TurbojpegLibrary.tjDecompress2(mPointerToDecompressor,
lPointerTo8BitImageCompressedByteBuffer,
lCompressedImageBufferSize,
mPointerToDecompressedImageByteBuffer,
lWidth,
0,
lHeight,
(int) TJPF.TJPF_GRAY.value,
TurbojpegLibrary.TJFLAG_NOREALLOC | TurbojpegLibrary.TJFLAG_FORCESSE3
| TurbojpegLibrary.TJFLAG_FASTDCT);
mLastDecompressionElapsedTimeInMs = lCompressionTime.time(TimeUnit.MILLISECONDS);
lPointerTo8BitImageCompressedByteBuffer.release();
return lErrorCode == 0;
}