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

Commit 5c20b9e0 authored by Nick Deakin's avatar Nick Deakin
Browse files

Fix up some recoverymapmath function definitons.

Add missing definition, fix a capitilization mistake, mark static
functions static.

Test: builds
Bug: 252835416
Change-Id: I97e2e35083237424f753147c632703344eb18c21
parent dc8220f2
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -66,7 +66,6 @@ float hlgInvOetf(float e);
/*
 * Convert from scene luminance in nits to HLG,  according to BT.2100.
 */
float hlgOetf(float e);
Color hlgOetf(Color e);

/*
+11 −4
Original line number Diff line number Diff line
@@ -56,7 +56,7 @@ float hlgInvOetf(float e) {
  }
}

float hlgOetf(float e) {
static float hlgOetf(float e) {
  if (e <= 1.0f/12.0f) {
    return sqrt(3.0f * e);
  } else {
@@ -68,7 +68,7 @@ Color hlgOetf(Color e) {
  return {{{ hlgOetf(e.r), hlgOetf(e.g), hlgOetf(e.b) }}};
}

uint8_t EncodeRecovery(float y_sdr, float y_hdr, float hdr_ratio) {
uint8_t encodeRecovery(float y_sdr, float y_hdr, float hdr_ratio) {
  float gain = 1.0f;
  if (y_sdr > 0.0f) {
    gain = y_hdr / y_sdr;
@@ -80,8 +80,14 @@ 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);
}

float applyRecovery(float y_sdr, float recovery, float hdr_ratio) {
  return exp2(log2(y_sdr) + recovery * log2(hdr_ratio));
static float applyRecovery(float e, float recovery, float hdr_ratio) {
  return exp2(log2(e) + recovery * log2(hdr_ratio));
}

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) }}};
}

// TODO: do we need something more clever for filtering either the map or images
@@ -166,4 +172,5 @@ static float getP010Y(jr_uncompressed_ptr image, size_t x, size_t y) {
float sampleP010Y(jr_uncompressed_ptr image, size_t map_scale_factor, size_t x, size_t y) {
  return sampleComponent(image, map_scale_factor, x, y, getP010Y);
}

} // namespace android::recoverymap