title: What is the fastest way to encode a bytebuffer image in jpg format?
body: <p>I use <a href="https://developer.android.com/training/camerax" rel="nofollow noreferrer">CameraX</a> to capture an image from the camera using <a href="https://developer.android.com/training/camerax/analyze" rel="nofollow noreferrer">ImageAnalysis</a>. The image is received as 3 ByteBuffers (respectively for the Y, U and V planes). I only keep the Y plane ByteBuffer. The other 2 are discarded.</p>
  <p>I would like to reduce the size of this ByteBuffer, for example by encoding it in the jpg format.</p>
  <p>Is it better to use <strong>MediaCodec</strong> or <strong>BitmapFactory</strong>? Knowing that the encoding time should be as small as possible. Is there another (better or faster) solution?</p>