Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a5ddcc26 authored by Harish Mahendrakar's avatar Harish Mahendrakar Committed by Dichen Zhang
Browse files

jpegrecoverymap: applyRecovery optimizations

Instead of computing pow(hdr_ratio, recovery) for each component
separately, compute it once per pixel.

Bug: 261877699
Test: push files from tests/data to /sdcard/Documents and then \
 atest libjpegdecoder_test libjpegencoder_test libjpegrecoverymap_test

Change-Id: I223c682f75c6c14c08f2fcdec69ab7a8d97d78a2
parent d3bb40ad
Loading
Loading
Loading
Loading
+2 −8
Original line number Diff line number Diff line
@@ -294,15 +294,9 @@ uint8_t encodeRecovery(float y_sdr, float y_hdr, float hdr_ratio) {
  return static_cast<uint8_t>(log2(gain) / log2(hdr_ratio) * 127.5f  + 127.5f);
}

static float applyRecovery(float e, float recovery, float hdr_ratio) {
  if (e <= 0.0f) return 0.0f;
  return e * pow(hdr_ratio, recovery);
}

Color applyRecovery(Color e, float recovery, float hdr_ratio) {
  return {{{ applyRecovery(e.r, recovery, hdr_ratio),
             applyRecovery(e.g, recovery, hdr_ratio),
             applyRecovery(e.b, recovery, hdr_ratio) }}};
  float recoveryFactor = pow(hdr_ratio, recovery);
  return e * recoveryFactor;
}

Color getYuv420Pixel(jr_uncompressed_ptr image, size_t x, size_t y) {