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

Commit 38125336 authored by Nick Deakin's avatar Nick Deakin
Browse files

A couple recoverymap fixes.

Fix decoding of P010 narrow range code points. Also fix scaling for
input to OETF during application of the map.

NOTE: tests pass, although there is still an expected failure for
encoding against just P010 input (API-0), sine toneMap() isn't
implemented yet.

Bug: 252835416, 261479255
Test: libjpegrecoverymap_test passes
Change-Id: Ibfd036c6c0cd55de7c5886e32fff69f461cf45d9
parent d1d22742
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -562,7 +562,7 @@ status_t RecoveryMap::applyRecoveryMap(jr_uncompressed_ptr uncompressed_yuv_420_
      float recovery = sampleMap(uncompressed_recovery_map, kMapDimensionScaleFactor, x, y);
      float recovery = sampleMap(uncompressed_recovery_map, kMapDimensionScaleFactor, x, y);
      Color rgb_hdr = applyRecovery(rgb_sdr, recovery, metadata->rangeScalingFactor);
      Color rgb_hdr = applyRecovery(rgb_sdr, recovery, metadata->rangeScalingFactor);


      Color rgb_gamma_hdr = hdrOetf(rgb_hdr);
      Color rgb_gamma_hdr = hdrOetf(rgb_hdr / metadata->rangeScalingFactor);
      uint32_t rgba1010102 = colorToRgba1010102(rgb_gamma_hdr);
      uint32_t rgba1010102 = colorToRgba1010102(rgb_gamma_hdr);


      size_t pixel_idx =  x + y * width;
      size_t pixel_idx =  x + y * width;
+3 −3
Original line number Original line Diff line number Diff line
@@ -336,9 +336,9 @@ Color getP010Pixel(jr_uncompressed_ptr image, size_t x, size_t y) {
                  >> 6;
                  >> 6;


  // Conversions include taking narrow-range into account.
  // Conversions include taking narrow-range into account.
  return {{{ static_cast<float>(y_uint) / 940.0f,
  return {{{ (static_cast<float>(y_uint) - 64.0f) / 876.0f,
             (static_cast<float>(u_uint) - 64.0f) / 940.0f - 0.5f,
             (static_cast<float>(u_uint) - 64.0f) / 896.0f - 0.5f,
             (static_cast<float>(v_uint) - 64.0f) / 940.0f - 0.5f }}};
             (static_cast<float>(v_uint) - 64.0f) / 896.0f - 0.5f }}};
}
}


typedef Color (*getPixelFn)(jr_uncompressed_ptr, size_t, size_t);
typedef Color (*getPixelFn)(jr_uncompressed_ptr, size_t, size_t);
+3 −4
Original line number Original line Diff line number Diff line
@@ -36,9 +36,9 @@ public:
  }
  }


  Color P010(uint16_t y, uint16_t u, uint16_t v) {
  Color P010(uint16_t y, uint16_t u, uint16_t v) {
      return {{{ static_cast<float>(y) / 940.0f,
      return {{{ (static_cast<float>(y) - 64.0f) / 876.0f,
                 (static_cast<float>(u) - 64.0f) / 940.0f - 0.5f,
                 (static_cast<float>(u) - 64.0f) / 896.0f - 0.5f,
                 (static_cast<float>(v) - 64.0f) / 940.0f - 0.5f }}};
                 (static_cast<float>(v) - 64.0f) / 896.0f - 0.5f }}};
  }
  }


  float Map(uint8_t e) {
  float Map(uint8_t e) {
@@ -821,7 +821,6 @@ TEST_F(RecoveryMapMathTest, GenerateMapLuminancePq) {
              bt2100Luminance(RgbBlue()) * kPqMaxNits, LuminanceEpsilon());
              bt2100Luminance(RgbBlue()) * kPqMaxNits, LuminanceEpsilon());
}
}


//Color Recover(Color yuv_gamma, float recovery, float range_scaling_factor) {
TEST_F(RecoveryMapMathTest, ApplyMap) {
TEST_F(RecoveryMapMathTest, ApplyMap) {
  EXPECT_RGB_EQ(Recover(YuvWhite(), 1.0f, 8.0f),
  EXPECT_RGB_EQ(Recover(YuvWhite(), 1.0f, 8.0f),
                RgbWhite() * 8.0f);
                RgbWhite() * 8.0f);