JPEG/R refactor: rename jpegrecoverymap library to ultrahdr
Test: build
Bug: b/264715926
Change-Id: I227fb5960f8fc7e13aae354bf77ec033850faf10
diff --git a/libs/jpegrecoverymap/Android.bp b/libs/ultrahdr/Android.bp
similarity index 97%
rename from libs/jpegrecoverymap/Android.bp
rename to libs/ultrahdr/Android.bp
index a376ced..e3f709b 100644
--- a/libs/jpegrecoverymap/Android.bp
+++ b/libs/ultrahdr/Android.bp
@@ -22,7 +22,7 @@
}
cc_library {
- name: "libjpegrecoverymap",
+ name: "libultrahdr",
host_supported: true,
vendor_available: true,
export_include_dirs: ["include"],
diff --git a/libs/jpegrecoverymap/OWNERS b/libs/ultrahdr/OWNERS
similarity index 100%
rename from libs/jpegrecoverymap/OWNERS
rename to libs/ultrahdr/OWNERS
diff --git a/libs/jpegrecoverymap/gainmapmath.cpp b/libs/ultrahdr/gainmapmath.cpp
similarity index 94%
rename from libs/jpegrecoverymap/gainmapmath.cpp
rename to libs/ultrahdr/gainmapmath.cpp
index f15a078..37c3cf3 100644
--- a/libs/jpegrecoverymap/gainmapmath.cpp
+++ b/libs/ultrahdr/gainmapmath.cpp
@@ -16,9 +16,9 @@
#include <cmath>
#include <vector>
-#include <jpegrecoverymap/gainmapmath.h>
+#include <ultrahdr/gainmapmath.h>
-namespace android::jpegrecoverymap {
+namespace android::ultrahdr {
static const std::vector<float> kPqOETF = [] {
std::vector<float> result;
@@ -396,45 +396,46 @@
// TODO: confirm we always want to convert like this before calculating
// luminance.
-ColorTransformFn getHdrConversionFn(jpegr_color_gamut sdr_gamut, jpegr_color_gamut hdr_gamut) {
+ColorTransformFn getHdrConversionFn(ultrahdr_color_gamut sdr_gamut,
+ ultrahdr_color_gamut hdr_gamut) {
switch (sdr_gamut) {
- case JPEGR_COLORGAMUT_BT709:
+ case ULTRAHDR_COLORGAMUT_BT709:
switch (hdr_gamut) {
- case JPEGR_COLORGAMUT_BT709:
+ case ULTRAHDR_COLORGAMUT_BT709:
return identityConversion;
- case JPEGR_COLORGAMUT_P3:
+ case ULTRAHDR_COLORGAMUT_P3:
return p3ToBt709;
- case JPEGR_COLORGAMUT_BT2100:
+ case ULTRAHDR_COLORGAMUT_BT2100:
return bt2100ToBt709;
- case JPEGR_COLORGAMUT_UNSPECIFIED:
+ case ULTRAHDR_COLORGAMUT_UNSPECIFIED:
return nullptr;
}
break;
- case JPEGR_COLORGAMUT_P3:
+ case ULTRAHDR_COLORGAMUT_P3:
switch (hdr_gamut) {
- case JPEGR_COLORGAMUT_BT709:
+ case ULTRAHDR_COLORGAMUT_BT709:
return bt709ToP3;
- case JPEGR_COLORGAMUT_P3:
+ case ULTRAHDR_COLORGAMUT_P3:
return identityConversion;
- case JPEGR_COLORGAMUT_BT2100:
+ case ULTRAHDR_COLORGAMUT_BT2100:
return bt2100ToP3;
- case JPEGR_COLORGAMUT_UNSPECIFIED:
+ case ULTRAHDR_COLORGAMUT_UNSPECIFIED:
return nullptr;
}
break;
- case JPEGR_COLORGAMUT_BT2100:
+ case ULTRAHDR_COLORGAMUT_BT2100:
switch (hdr_gamut) {
- case JPEGR_COLORGAMUT_BT709:
+ case ULTRAHDR_COLORGAMUT_BT709:
return bt709ToBt2100;
- case JPEGR_COLORGAMUT_P3:
+ case ULTRAHDR_COLORGAMUT_P3:
return p3ToBt2100;
- case JPEGR_COLORGAMUT_BT2100:
+ case ULTRAHDR_COLORGAMUT_BT2100:
return identityConversion;
- case JPEGR_COLORGAMUT_UNSPECIFIED:
+ case ULTRAHDR_COLORGAMUT_UNSPECIFIED:
return nullptr;
}
break;
- case JPEGR_COLORGAMUT_UNSPECIFIED:
+ case ULTRAHDR_COLORGAMUT_UNSPECIFIED:
return nullptr;
}
}
@@ -442,12 +443,12 @@
////////////////////////////////////////////////////////////////////////////////
// Gain map calculations
-uint8_t encodeGain(float y_sdr, float y_hdr, jr_metadata_ptr metadata) {
+uint8_t encodeGain(float y_sdr, float y_hdr, ultrahdr_metadata_ptr metadata) {
return encodeGain(y_sdr, y_hdr, metadata,
log2(metadata->minContentBoost), log2(metadata->maxContentBoost));
}
-uint8_t encodeGain(float y_sdr, float y_hdr, jr_metadata_ptr metadata,
+uint8_t encodeGain(float y_sdr, float y_hdr, ultrahdr_metadata_ptr metadata,
float log2MinContentBoost, float log2MaxContentBoost) {
float gain = 1.0f;
if (y_sdr > 0.0f) {
@@ -462,14 +463,14 @@
* 255.0f);
}
-Color applyGain(Color e, float gain, jr_metadata_ptr metadata) {
+Color applyGain(Color e, float gain, ultrahdr_metadata_ptr metadata) {
float logBoost = log2(metadata->minContentBoost) * (1.0f - gain)
+ log2(metadata->maxContentBoost) * gain;
float gainFactor = exp2(logBoost);
return e * gainFactor;
}
-Color applyGain(Color e, float gain, jr_metadata_ptr metadata, float displayBoost) {
+Color applyGain(Color e, float gain, ultrahdr_metadata_ptr metadata, float displayBoost) {
float logBoost = log2(metadata->minContentBoost) * (1.0f - gain)
+ log2(metadata->maxContentBoost) * gain;
float gainFactor = exp2(logBoost * displayBoost / metadata->maxContentBoost);
@@ -511,7 +512,7 @@
chroma_stride = luma_stride;
}
if (chroma_data == nullptr) {
- chroma_data = &reinterpret_cast<uint16_t*>(image->data)[image->luma_stride * image->height];
+ chroma_data = &reinterpret_cast<uint16_t*>(image->data)[luma_stride * image->height];
}
size_t pixel_y_idx = y * luma_stride + x;
@@ -662,4 +663,4 @@
| (((uint64_t) floatToHalf(1.0f)) << 48);
}
-} // namespace android::jpegrecoverymap
+} // namespace android::ultrahdr
diff --git a/libs/jpegrecoverymap/icc.cpp b/libs/ultrahdr/icc.cpp
similarity index 92%
rename from libs/jpegrecoverymap/icc.cpp
rename to libs/ultrahdr/icc.cpp
index 6e78f67..c807705 100644
--- a/libs/jpegrecoverymap/icc.cpp
+++ b/libs/ultrahdr/icc.cpp
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-#include <jpegrecoverymap/icc.h>
-#include <jpegrecoverymap/gainmapmath.h>
+#include <ultrahdr/icc.h>
+#include <ultrahdr/gainmapmath.h>
#include <vector>
#include <utils/Log.h>
@@ -23,7 +23,7 @@
#define FLT_MAX 0x1.fffffep127f
#endif
-namespace android::jpegrecoverymap {
+namespace android::ultrahdr {
static void Matrix3x3_apply(const Matrix3x3* m, float* x) {
float y0 = x[0] * m->vals[0][0] + x[1] * m->vals[0][1] + x[2] * m->vals[0][2];
float y1 = x[0] * m->vals[1][0] + x[1] * m->vals[1][1] + x[2] * m->vals[1][2];
@@ -127,17 +127,17 @@
}
}
-std::string IccHelper::get_desc_string(const jpegr_transfer_function tf,
- const jpegr_color_gamut gamut) {
+std::string IccHelper::get_desc_string(const ultrahdr_transfer_function tf,
+ const ultrahdr_color_gamut gamut) {
std::string result;
switch (gamut) {
- case JPEGR_COLORGAMUT_BT709:
+ case ULTRAHDR_COLORGAMUT_BT709:
result += "sRGB";
break;
- case JPEGR_COLORGAMUT_P3:
+ case ULTRAHDR_COLORGAMUT_P3:
result += "Display P3";
break;
- case JPEGR_COLORGAMUT_BT2100:
+ case ULTRAHDR_COLORGAMUT_BT2100:
result += "Rec2020";
break;
default:
@@ -146,16 +146,16 @@
}
result += " Gamut with ";
switch (tf) {
- case JPEGR_TF_SRGB:
+ case ULTRAHDR_TF_SRGB:
result += "sRGB";
break;
- case JPEGR_TF_LINEAR:
+ case ULTRAHDR_TF_LINEAR:
result += "Linear";
break;
- case JPEGR_TF_PQ:
+ case ULTRAHDR_TF_PQ:
result += "PQ";
break;
- case JPEGR_TF_HLG:
+ case ULTRAHDR_TF_HLG:
result += "HLG";
break;
default:
@@ -234,11 +234,11 @@
return dataStruct;
}
-float IccHelper::compute_tone_map_gain(const jpegr_transfer_function tf, float L) {
+float IccHelper::compute_tone_map_gain(const ultrahdr_transfer_function tf, float L) {
if (L <= 0.f) {
return 1.f;
}
- if (tf == JPEGR_TF_PQ) {
+ if (tf == ULTRAHDR_TF_PQ) {
// The PQ transfer function will map to the range [0, 1]. Linearly scale
// it up to the range [0, 10,000/203]. We will then tone map that back
// down to [0, 1].
@@ -251,7 +251,7 @@
constexpr float kToneMapB = 1.f / kOutputMaxLuminance;
return kInputMaxLuminance * (1.f + kToneMapA * L) / (1.f + kToneMapB * L);
}
- if (tf == JPEGR_TF_HLG) {
+ if (tf == ULTRAHDR_TF_HLG) {
// Let Lw be the brightness of the display in nits.
constexpr float Lw = 203.f;
const float gamma = 1.2f + 0.42f * std::log(Lw / 1000.f) / std::log(10.f);
@@ -295,7 +295,7 @@
float L = bt2100Luminance({{{rgb[0], rgb[1], rgb[2]}}});
// Compute the tone map gain based on the luminance.
- float tone_map_gain = compute_tone_map_gain(JPEGR_TF_PQ, L);
+ float tone_map_gain = compute_tone_map_gain(ULTRAHDR_TF_PQ, L);
// Apply the tone map gain.
for (size_t i = 0; i < kNumChannels; ++i) {
@@ -397,7 +397,8 @@
return dataStruct;
}
-sp<DataStruct> IccHelper::writeIccProfile(jpegr_transfer_function tf, jpegr_color_gamut gamut) {
+sp<DataStruct> IccHelper::writeIccProfile(ultrahdr_transfer_function tf,
+ ultrahdr_color_gamut gamut) {
ICCHeader header;
std::vector<std::pair<uint32_t, sp<DataStruct>>> tags;
@@ -409,13 +410,13 @@
Matrix3x3 toXYZD50;
switch (gamut) {
- case JPEGR_COLORGAMUT_BT709:
+ case ULTRAHDR_COLORGAMUT_BT709:
toXYZD50 = kSRGB;
break;
- case JPEGR_COLORGAMUT_P3:
+ case ULTRAHDR_COLORGAMUT_P3:
toXYZD50 = kDisplayP3;
break;
- case JPEGR_COLORGAMUT_BT2100:
+ case ULTRAHDR_COLORGAMUT_BT2100:
toXYZD50 = kRec2020;
break;
default:
@@ -437,8 +438,8 @@
tags.emplace_back(kTAG_wtpt, write_xyz_tag(kD50_x, kD50_y, kD50_z));
// Compute transfer curves.
- if (tf != JPEGR_TF_PQ) {
- if (tf == JPEGR_TF_HLG) {
+ if (tf != ULTRAHDR_TF_PQ) {
+ if (tf == ULTRAHDR_TF_HLG) {
std::vector<uint8_t> trc_table;
trc_table.resize(kTrcTableSize * 2);
for (uint32_t i = 0; i < kTrcTableSize; ++i) {
@@ -462,32 +463,32 @@
}
// Compute CICP.
- if (tf == JPEGR_TF_HLG || tf == JPEGR_TF_PQ) {
+ if (tf == ULTRAHDR_TF_HLG || tf == ULTRAHDR_TF_PQ) {
// The CICP tag is present in ICC 4.4, so update the header's version.
header.version = Endian_SwapBE32(0x04400000);
uint32_t color_primaries = 0;
- if (gamut == JPEGR_COLORGAMUT_BT709) {
+ if (gamut == ULTRAHDR_COLORGAMUT_BT709) {
color_primaries = kCICPPrimariesSRGB;
- } else if (gamut == JPEGR_COLORGAMUT_P3) {
+ } else if (gamut == ULTRAHDR_COLORGAMUT_P3) {
color_primaries = kCICPPrimariesP3;
}
uint32_t transfer_characteristics = 0;
- if (tf == JPEGR_TF_SRGB) {
+ if (tf == ULTRAHDR_TF_SRGB) {
transfer_characteristics = kCICPTrfnSRGB;
- } else if (tf == JPEGR_TF_LINEAR) {
+ } else if (tf == ULTRAHDR_TF_LINEAR) {
transfer_characteristics = kCICPTrfnLinear;
- } else if (tf == JPEGR_TF_PQ) {
+ } else if (tf == ULTRAHDR_TF_PQ) {
transfer_characteristics = kCICPTrfnPQ;
- } else if (tf == JPEGR_TF_HLG) {
+ } else if (tf == ULTRAHDR_TF_HLG) {
transfer_characteristics = kCICPTrfnHLG;
}
tags.emplace_back(kTAG_cicp, write_cicp_tag(color_primaries, transfer_characteristics));
}
// Compute A2B0.
- if (tf == JPEGR_TF_PQ) {
+ if (tf == ULTRAHDR_TF_PQ) {
std::vector<uint8_t> a2b_grid;
a2b_grid.resize(kGridSize * kGridSize * kGridSize * kNumChannels * 2);
size_t a2b_grid_index = 0;
@@ -520,7 +521,7 @@
}
// Compute B2A0.
- if (tf == JPEGR_TF_PQ) {
+ if (tf == ULTRAHDR_TF_PQ) {
auto b2a_data = write_mAB_or_mBA_tag(kTAG_mBAType,
/* has_a_curves */ false,
/* grid_points */ nullptr,
@@ -541,7 +542,7 @@
// Write the header.
header.data_color_space = Endian_SwapBE32(Signature_RGB);
- header.pcs = Endian_SwapBE32(tf == JPEGR_TF_PQ ? Signature_Lab : Signature_XYZ);
+ header.pcs = Endian_SwapBE32(tf == ULTRAHDR_TF_PQ ? Signature_Lab : Signature_XYZ);
header.size = Endian_SwapBE32(profile_size);
header.tag_count = Endian_SwapBE32(tags.size());
@@ -581,4 +582,4 @@
return dataStruct;
}
-} // namespace android::jpegrecoverymap
\ No newline at end of file
+} // namespace android::ultrahdr
\ No newline at end of file
diff --git a/libs/jpegrecoverymap/include/jpegrecoverymap/gainmapmath.h b/libs/ultrahdr/include/ultrahdr/gainmapmath.h
similarity index 93%
rename from libs/jpegrecoverymap/include/jpegrecoverymap/gainmapmath.h
rename to libs/ultrahdr/include/ultrahdr/gainmapmath.h
index 57fddd0..abc9356 100644
--- a/libs/jpegrecoverymap/include/jpegrecoverymap/gainmapmath.h
+++ b/libs/ultrahdr/include/ultrahdr/gainmapmath.h
@@ -14,15 +14,15 @@
* limitations under the License.
*/
-#ifndef ANDROID_JPEGRECOVERYMAP_RECOVERYMAPMATH_H
-#define ANDROID_JPEGRECOVERYMAP_RECOVERYMAPMATH_H
+#ifndef ANDROID_ULTRAHDR_RECOVERYMAPMATH_H
+#define ANDROID_ULTRAHDR_RECOVERYMAPMATH_H
#include <cmath>
#include <stdint.h>
-#include <jpegrecoverymap/jpegr.h>
+#include <ultrahdr/jpegr.h>
-namespace android::jpegrecoverymap {
+namespace android::ultrahdr {
#define CLIP3(x, min, max) ((x) < (min)) ? (min) : ((x) > (max)) ? (max) : (x)
@@ -132,7 +132,7 @@
constexpr size_t kGainFactorPrecision = 10;
constexpr size_t kGainFactorNumEntries = 1 << kGainFactorPrecision;
struct GainLUT {
- GainLUT(jr_metadata_ptr metadata) {
+ GainLUT(ultrahdr_metadata_ptr metadata) {
for (int idx = 0; idx < kGainFactorNumEntries; idx++) {
float value = static_cast<float>(idx) / static_cast<float>(kGainFactorNumEntries - 1);
float logBoost = log2(metadata->minContentBoost) * (1.0f - value)
@@ -141,7 +141,7 @@
}
}
- GainLUT(jr_metadata_ptr metadata, float displayBoost) {
+ GainLUT(ultrahdr_metadata_ptr metadata, float displayBoost) {
float boostFactor = displayBoost > 0 ? displayBoost / metadata->maxContentBoost : 1.0f;
for (int idx = 0; idx < kGainFactorNumEntries; idx++) {
float value = static_cast<float>(idx) / static_cast<float>(kGainFactorNumEntries - 1);
@@ -356,7 +356,7 @@
/*
* Get the conversion to apply to the HDR image for gain map generation
*/
-ColorTransformFn getHdrConversionFn(jpegr_color_gamut sdr_gamut, jpegr_color_gamut hdr_gamut);
+ColorTransformFn getHdrConversionFn(ultrahdr_color_gamut sdr_gamut, ultrahdr_color_gamut hdr_gamut);
////////////////////////////////////////////////////////////////////////////////
@@ -366,16 +366,16 @@
* Calculate the 8-bit unsigned integer gain value for the given SDR and HDR
* luminances in linear space, and the hdr ratio to encode against.
*/
-uint8_t encodeGain(float y_sdr, float y_hdr, jr_metadata_ptr metadata);
-uint8_t encodeGain(float y_sdr, float y_hdr, jr_metadata_ptr metadata,
+uint8_t encodeGain(float y_sdr, float y_hdr, ultrahdr_metadata_ptr metadata);
+uint8_t encodeGain(float y_sdr, float y_hdr, ultrahdr_metadata_ptr metadata,
float log2MinContentBoost, float log2MaxContentBoost);
/*
* Calculates the linear luminance in nits after applying the given gain
* value, with the given hdr ratio, to the given sdr input in the range [0, 1].
*/
-Color applyGain(Color e, float gain, jr_metadata_ptr metadata);
-Color applyGain(Color e, float gain, jr_metadata_ptr metadata, float displayBoost);
+Color applyGain(Color e, float gain, ultrahdr_metadata_ptr metadata);
+Color applyGain(Color e, float gain, ultrahdr_metadata_ptr metadata, float displayBoost);
Color applyGainLUT(Color e, float gain, GainLUT& gainLUT);
/*
@@ -426,6 +426,6 @@
*/
uint64_t colorToRgbaF16(Color e_gamma);
-} // namespace android::jpegrecoverymap
+} // namespace android::ultrahdr
-#endif // ANDROID_JPEGRECOVERYMAP_RECOVERYMAPMATH_H
+#endif // ANDROID_ULTRAHDR_RECOVERYMAPMATH_H
diff --git a/libs/jpegrecoverymap/include/jpegrecoverymap/icc.h b/libs/ultrahdr/include/ultrahdr/icc.h
similarity index 92%
rename from libs/jpegrecoverymap/include/jpegrecoverymap/icc.h
rename to libs/ultrahdr/include/ultrahdr/icc.h
index a81aa62..7f6ab88 100644
--- a/libs/jpegrecoverymap/include/jpegrecoverymap/icc.h
+++ b/libs/ultrahdr/include/ultrahdr/icc.h
@@ -14,11 +14,11 @@
* limitations under the License.
*/
-#ifndef ANDROID_JPEGRECOVERYMAP_ICC_H
-#define ANDROID_JPEGRECOVERYMAP_ICC_H
+#ifndef ANDROID_ULTRAHDR_ICC_H
+#define ANDROID_ULTRAHDR_ICC_H
-#include <jpegrecoverymap/jpegr.h>
-#include <jpegrecoverymap/jpegrutils.h>
+#include <ultrahdr/jpegr.h>
+#include <ultrahdr/jpegrutils.h>
#include <utils/RefBase.h>
#include <cmath>
#include <string>
@@ -28,7 +28,7 @@
#define USE_BIG_ENDIAN true
#endif
-namespace android::jpegrecoverymap {
+namespace android::ultrahdr {
typedef int32_t Fixed;
#define Fixed1 (1 << 16)
@@ -210,12 +210,12 @@
static constexpr size_t kNumChannels = 3;
static sp<DataStruct> write_text_tag(const char* text);
- static std::string get_desc_string(const jpegr_transfer_function tf,
- const jpegr_color_gamut gamut);
+ static std::string get_desc_string(const ultrahdr_transfer_function tf,
+ const ultrahdr_color_gamut gamut);
static sp<DataStruct> write_xyz_tag(float x, float y, float z);
static sp<DataStruct> write_trc_tag(const int table_entries, const void* table_16);
static sp<DataStruct> write_trc_tag_for_linear();
- static float compute_tone_map_gain(const jpegr_transfer_function tf, float L);
+ static float compute_tone_map_gain(const ultrahdr_transfer_function tf, float L);
static sp<DataStruct> write_cicp_tag(uint32_t color_primaries,
uint32_t transfer_characteristics);
static sp<DataStruct> write_mAB_or_mBA_tag(uint32_t type,
@@ -226,9 +226,9 @@
static sp<DataStruct> write_clut(const uint8_t* grid_points, const uint8_t* grid_16);
public:
- static sp<DataStruct> writeIccProfile(const jpegr_transfer_function tf,
- const jpegr_color_gamut gamut);
+ static sp<DataStruct> writeIccProfile(const ultrahdr_transfer_function tf,
+ const ultrahdr_color_gamut gamut);
};
-} // namespace android::jpegrecoverymap
+} // namespace android::ultrahdr
-#endif //ANDROID_JPEGRECOVERYMAP_ICC_H
\ No newline at end of file
+#endif //ANDROID_ULTRAHDR_ICC_H
\ No newline at end of file
diff --git a/libs/jpegrecoverymap/include/jpegrecoverymap/jpegdecoderhelper.h b/libs/ultrahdr/include/ultrahdr/jpegdecoderhelper.h
similarity index 94%
rename from libs/jpegrecoverymap/include/jpegrecoverymap/jpegdecoderhelper.h
rename to libs/ultrahdr/include/ultrahdr/jpegdecoderhelper.h
index 8748237..f642bad 100644
--- a/libs/jpegrecoverymap/include/jpegrecoverymap/jpegdecoderhelper.h
+++ b/libs/ultrahdr/include/ultrahdr/jpegdecoderhelper.h
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-#ifndef ANDROID_JPEGRECOVERYMAP_JPEGDECODERHELPER_H
-#define ANDROID_JPEGRECOVERYMAP_JPEGDECODERHELPER_H
+#ifndef ANDROID_ULTRAHDR_JPEGDECODERHELPER_H
+#define ANDROID_ULTRAHDR_JPEGDECODERHELPER_H
// We must include cstdio before jpeglib.h. It is a requirement of libjpeg.
#include <cstdio>
@@ -25,7 +25,7 @@
}
#include <utils/Errors.h>
#include <vector>
-namespace android::jpegrecoverymap {
+namespace android::ultrahdr {
/*
* Encapsulates a converter from JPEG to raw image (YUV420planer or grey-scale) format.
* This class is not thread-safe.
@@ -115,6 +115,6 @@
// Position of EXIF package, default value is -1 which means no EXIF package appears.
size_t mExifPos;
};
-} /* namespace android::jpegrecoverymap */
+} /* namespace android::ultrahdr */
-#endif // ANDROID_JPEGRECOVERYMAP_JPEGDECODERHELPER_H
+#endif // ANDROID_ULTRAHDR_JPEGDECODERHELPER_H
diff --git a/libs/jpegrecoverymap/include/jpegrecoverymap/jpegencoderhelper.h b/libs/ultrahdr/include/ultrahdr/jpegencoderhelper.h
similarity index 93%
rename from libs/jpegrecoverymap/include/jpegrecoverymap/jpegencoderhelper.h
rename to libs/ultrahdr/include/ultrahdr/jpegencoderhelper.h
index 8b82b2b..ac02155 100644
--- a/libs/jpegrecoverymap/include/jpegrecoverymap/jpegencoderhelper.h
+++ b/libs/ultrahdr/include/ultrahdr/jpegencoderhelper.h
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-#ifndef ANDROID_JPEGRECOVERYMAP_JPEGENCODERHELPER_H
-#define ANDROID_JPEGRECOVERYMAP_JPEGENCODERHELPER_H
+#ifndef ANDROID_ULTRAHDR_JPEGENCODERHELPER_H
+#define ANDROID_ULTRAHDR_JPEGENCODERHELPER_H
// We must include cstdio before jpeglib.h. It is a requirement of libjpeg.
#include <cstdio>
@@ -28,7 +28,7 @@
#include <utils/Errors.h>
#include <vector>
-namespace android::jpegrecoverymap {
+namespace android::ultrahdr {
/*
* Encapsulates a converter from raw image (YUV420planer or grey-scale) to JPEG format.
@@ -90,6 +90,6 @@
std::vector<JOCTET> mResultBuffer;
};
-} /* namespace android::jpegrecoverymap */
+} /* namespace android::ultrahdr */
-#endif // ANDROID_JPEGRECOVERYMAP_JPEGENCODERHELPER_H
+#endif // ANDROID_ULTRAHDR_JPEGENCODERHELPER_H
diff --git a/libs/jpegrecoverymap/include/jpegrecoverymap/jpegr.h b/libs/ultrahdr/include/ultrahdr/jpegr.h
similarity index 88%
rename from libs/jpegrecoverymap/include/jpegrecoverymap/jpegr.h
rename to libs/ultrahdr/include/ultrahdr/jpegr.h
index ce7b33b..b755b19 100644
--- a/libs/jpegrecoverymap/include/jpegrecoverymap/jpegr.h
+++ b/libs/ultrahdr/include/ultrahdr/jpegr.h
@@ -14,41 +14,17 @@
* limitations under the License.
*/
-#ifndef ANDROID_JPEGRECOVERYMAP_JPEGR_H
-#define ANDROID_JPEGRECOVERYMAP_JPEGR_H
+#ifndef ANDROID_ULTRAHDR_JPEGR_H
+#define ANDROID_ULTRAHDR_JPEGR_H
#include "jpegrerrorcode.h"
+#include "ultrahdr.h"
#ifndef FLT_MAX
#define FLT_MAX 0x1.fffffep127f
#endif
-namespace android::jpegrecoverymap {
-
-// Color gamuts for image data
-typedef enum {
- JPEGR_COLORGAMUT_UNSPECIFIED,
- JPEGR_COLORGAMUT_BT709,
- JPEGR_COLORGAMUT_P3,
- JPEGR_COLORGAMUT_BT2100,
-} jpegr_color_gamut;
-
-// Transfer functions for image data
-typedef enum {
- JPEGR_TF_UNSPECIFIED = -1,
- JPEGR_TF_LINEAR = 0,
- JPEGR_TF_HLG = 1,
- JPEGR_TF_PQ = 2,
- JPEGR_TF_SRGB = 3,
-} jpegr_transfer_function;
-
-// Target output formats for decoder
-typedef enum {
- JPEGR_OUTPUT_SDR, // SDR in RGBA_8888 color format
- JPEGR_OUTPUT_HDR_LINEAR, // HDR in F16 color format (linear)
- JPEGR_OUTPUT_HDR_PQ, // HDR in RGBA_1010102 color format (PQ transfer function)
- JPEGR_OUTPUT_HDR_HLG, // HDR in RGBA_1010102 color format (HLG transfer function)
-} jpegr_output_format;
+namespace android::ultrahdr {
struct jpegr_info_struct {
size_t width;
@@ -68,7 +44,7 @@
// Height of the gain map or the luma plane of the image in pixels.
int height;
// Color gamut.
- jpegr_color_gamut colorGamut;
+ ultrahdr_color_gamut colorGamut;
// Values below are optional
// Pointer to chroma data, if it's NULL, chroma plane is considered to be immediately
@@ -96,7 +72,7 @@
// Maximum available data length in bytes.
int maxLength;
// Color gamut.
- jpegr_color_gamut colorGamut;
+ ultrahdr_color_gamut colorGamut;
};
/*
@@ -109,22 +85,9 @@
int length;
};
-/*
- * Holds information for gain map related metadata.
- */
-struct jpegr_metadata_struct {
- // JPEG/R version
- uint32_t version;
- // Max Content Boost for the map
- float maxContentBoost;
- // Min Content Boost for the map
- float minContentBoost;
-};
-
typedef struct jpegr_uncompressed_struct* jr_uncompressed_ptr;
typedef struct jpegr_compressed_struct* jr_compressed_ptr;
typedef struct jpegr_exif_struct* jr_exif_ptr;
-typedef struct jpegr_metadata_struct* jr_metadata_ptr;
typedef struct jpegr_info_struct* jr_info_ptr;
class JpegR {
@@ -147,7 +110,7 @@
* @return NO_ERROR if encoding succeeds, error code if error occurs.
*/
status_t encodeJPEGR(jr_uncompressed_ptr uncompressed_p010_image,
- jpegr_transfer_function hdr_tf,
+ ultrahdr_transfer_function hdr_tf,
jr_compressed_ptr dest,
int quality,
jr_exif_ptr exif);
@@ -170,7 +133,7 @@
*/
status_t encodeJPEGR(jr_uncompressed_ptr uncompressed_p010_image,
jr_uncompressed_ptr uncompressed_yuv_420_image,
- jpegr_transfer_function hdr_tf,
+ ultrahdr_transfer_function hdr_tf,
jr_compressed_ptr dest,
int quality,
jr_exif_ptr exif);
@@ -195,7 +158,7 @@
status_t encodeJPEGR(jr_uncompressed_ptr uncompressed_p010_image,
jr_uncompressed_ptr uncompressed_yuv_420_image,
jr_compressed_ptr compressed_jpeg_image,
- jpegr_transfer_function hdr_tf,
+ ultrahdr_transfer_function hdr_tf,
jr_compressed_ptr dest);
/*
@@ -215,7 +178,7 @@
*/
status_t encodeJPEGR(jr_uncompressed_ptr uncompressed_p010_image,
jr_compressed_ptr compressed_jpeg_image,
- jpegr_transfer_function hdr_tf,
+ ultrahdr_transfer_function hdr_tf,
jr_compressed_ptr dest);
/*
@@ -249,16 +212,16 @@
* @param metadata destination of the decoded metadata. The default value is NULL where the
decoder will do nothing about it. If configured not NULL the decoder will
write metadata into this structure. the format of metadata is defined in
- {@code jpegr_metadata}.
+ {@code ultrahdr_metadata_struct}.
* @return NO_ERROR if decoding succeeds, error code if error occurs.
*/
status_t decodeJPEGR(jr_compressed_ptr compressed_jpegr_image,
jr_uncompressed_ptr dest,
float max_display_boost = FLT_MAX,
jr_exif_ptr exif = nullptr,
- jpegr_output_format output_format = JPEGR_OUTPUT_HDR_LINEAR,
+ ultrahdr_output_format output_format = ULTRAHDR_OUTPUT_HDR_LINEAR,
jr_uncompressed_ptr gain_map = nullptr,
- jr_metadata_ptr metadata = nullptr);
+ ultrahdr_metadata_ptr metadata = nullptr);
/*
* Gets Info from JPEGR file without decoding it.
@@ -286,8 +249,8 @@
*/
status_t generateGainMap(jr_uncompressed_ptr uncompressed_yuv_420_image,
jr_uncompressed_ptr uncompressed_p010_image,
- jpegr_transfer_function hdr_tf,
- jr_metadata_ptr metadata,
+ ultrahdr_transfer_function hdr_tf,
+ ultrahdr_metadata_ptr metadata,
jr_uncompressed_ptr dest);
/*
@@ -308,8 +271,8 @@
*/
status_t applyGainMap(jr_uncompressed_ptr uncompressed_yuv_420_image,
jr_uncompressed_ptr uncompressed_gain_map,
- jr_metadata_ptr metadata,
- jpegr_output_format output_format,
+ ultrahdr_metadata_ptr metadata,
+ ultrahdr_output_format output_format,
float max_display_boost,
jr_uncompressed_ptr dest);
@@ -365,7 +328,7 @@
status_t appendGainMap(jr_compressed_ptr compressed_jpeg_image,
jr_compressed_ptr compressed_gain_map,
jr_exif_ptr exif,
- jr_metadata_ptr metadata,
+ ultrahdr_metadata_ptr metadata,
jr_compressed_ptr dest);
/*
@@ -389,6 +352,6 @@
jr_uncompressed_ptr uncompressed_yuv_420_image);
};
-} // namespace android::jpegrecoverymap
+} // namespace android::ultrahdr
-#endif // ANDROID_JPEGRECOVERYMAP_JPEGR_H
+#endif // ANDROID_ULTRAHDR_JPEGR_H
diff --git a/libs/jpegrecoverymap/include/jpegrecoverymap/jpegrerrorcode.h b/libs/ultrahdr/include/ultrahdr/jpegrerrorcode.h
similarity index 91%
rename from libs/jpegrecoverymap/include/jpegrecoverymap/jpegrerrorcode.h
rename to libs/ultrahdr/include/ultrahdr/jpegrerrorcode.h
index 159aaa8..9f59c3e 100644
--- a/libs/jpegrecoverymap/include/jpegrecoverymap/jpegrerrorcode.h
+++ b/libs/ultrahdr/include/ultrahdr/jpegrerrorcode.h
@@ -14,9 +14,12 @@
* limitations under the License.
*/
+#ifndef ANDROID_ULTRAHDR_JPEGRERRORCODE_H
+#define ANDROID_ULTRAHDR_JPEGRERRORCODE_H
+
#include <utils/Errors.h>
-namespace android::jpegrecoverymap {
+namespace android::ultrahdr {
enum {
// status_t map for errors in the media framework
@@ -50,4 +53,6 @@
ERROR_JPEGR_UNSUPPORTED_FEATURE = -20000,
};
-} // namespace android::jpegrecoverymap
+} // namespace android::ultrahdr
+
+#endif // ANDROID_ULTRAHDR_JPEGRERRORCODE_H
diff --git a/libs/jpegrecoverymap/include/jpegrecoverymap/jpegrutils.h b/libs/ultrahdr/include/ultrahdr/jpegrutils.h
similarity index 90%
rename from libs/jpegrecoverymap/include/jpegrecoverymap/jpegrutils.h
rename to libs/ultrahdr/include/ultrahdr/jpegrutils.h
index 09f4165..ed38e07 100644
--- a/libs/jpegrecoverymap/include/jpegrecoverymap/jpegrutils.h
+++ b/libs/ultrahdr/include/ultrahdr/jpegrutils.h
@@ -14,10 +14,10 @@
* limitations under the License.
*/
-#ifndef ANDROID_JPEGRECOVERYMAP_JPEGRUTILS_H
-#define ANDROID_JPEGRECOVERYMAP_JPEGRUTILS_H
+#ifndef ANDROID_ULTRAHDR_JPEGRUTILS_H
+#define ANDROID_ULTRAHDR_JPEGRUTILS_H
-#include <jpegrecoverymap/jpegr.h>
+#include <ultrahdr/jpegr.h>
#include <utils/RefBase.h>
#include <sstream>
@@ -25,7 +25,7 @@
#include <string>
#include <cstdio>
-namespace android::jpegrecoverymap {
+namespace android::ultrahdr {
static constexpr uint32_t EndianSwap32(uint32_t value) {
return ((value & 0xFF) << 24) |
@@ -45,7 +45,7 @@
#define Endian_SwapBE16(n) (n)
#endif
-struct jpegr_metadata_struct;
+struct ultrahdr_metadata_struct;
/*
* Mutable data structure. Holds information for metadata.
*/
@@ -87,7 +87,7 @@
* @param metadata place to store HDR metadata values
* @return true if metadata is successfully retrieved, false otherwise
*/
-bool getMetadataFromXMP(uint8_t* xmp_data, size_t xmp_size, jpegr_metadata_struct* metadata);
+bool getMetadataFromXMP(uint8_t* xmp_data, size_t xmp_size, ultrahdr_metadata_struct* metadata);
/*
* This method generates XMP metadata for the primary image.
@@ -158,7 +158,7 @@
* @param metadata JPEG/R metadata to encode as XMP
* @return XMP metadata in type of string
*/
- std::string generateXmpForSecondaryImage(jpegr_metadata_struct& metadata);
-} // namespace android::jpegrecoverymap
+ std::string generateXmpForSecondaryImage(ultrahdr_metadata_struct& metadata);
+} // namespace android::ultrahdr
-#endif //ANDROID_JPEGRECOVERYMAP_JPEGRUTILS_H
+#endif //ANDROID_ULTRAHDR_JPEGRUTILS_H
diff --git a/libs/jpegrecoverymap/include/jpegrecoverymap/multipictureformat.h b/libs/ultrahdr/include/ultrahdr/multipictureformat.h
similarity index 87%
rename from libs/jpegrecoverymap/include/jpegrecoverymap/multipictureformat.h
rename to libs/ultrahdr/include/ultrahdr/multipictureformat.h
index cf3387d..c5bd09d 100644
--- a/libs/jpegrecoverymap/include/jpegrecoverymap/multipictureformat.h
+++ b/libs/ultrahdr/include/ultrahdr/multipictureformat.h
@@ -14,17 +14,17 @@
* limitations under the License.
*/
-#ifndef ANDROID_JPEGRECOVERYMAP_MULTIPICTUREFORMAT_H
-#define ANDROID_JPEGRECOVERYMAP_MULTIPICTUREFORMAT_H
+#ifndef ANDROID_ULTRAHDR_MULTIPICTUREFORMAT_H
+#define ANDROID_ULTRAHDR_MULTIPICTUREFORMAT_H
-#include <jpegrecoverymap/jpegrutils.h>
+#include <ultrahdr/jpegrutils.h>
#ifdef USE_BIG_ENDIAN
#undef USE_BIG_ENDIAN
#define USE_BIG_ENDIAN true
#endif
-namespace android::jpegrecoverymap {
+namespace android::ultrahdr {
constexpr size_t kNumPictures = 2;
constexpr size_t kMpEndianSize = 4;
@@ -59,6 +59,6 @@
sp<DataStruct> generateMpf(int primary_image_size, int primary_image_offset,
int secondary_image_size, int secondary_image_offset);
-} // namespace android::jpegrecoverymap
+} // namespace android::ultrahdr
-#endif //ANDROID_JPEGRECOVERYMAP_MULTIPICTUREFORMAT_H
+#endif //ANDROID_ULTRAHDR_MULTIPICTUREFORMAT_H
diff --git a/libs/ultrahdr/include/ultrahdr/ultrahdr.h b/libs/ultrahdr/include/ultrahdr/ultrahdr.h
new file mode 100644
index 0000000..302aeee
--- /dev/null
+++ b/libs/ultrahdr/include/ultrahdr/ultrahdr.h
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_ULTRAHDR_ULTRAHDR_H
+#define ANDROID_ULTRAHDR_ULTRAHDR_H
+
+namespace android::ultrahdr {
+// Color gamuts for image data
+typedef enum {
+ ULTRAHDR_COLORGAMUT_UNSPECIFIED,
+ ULTRAHDR_COLORGAMUT_BT709,
+ ULTRAHDR_COLORGAMUT_P3,
+ ULTRAHDR_COLORGAMUT_BT2100,
+} ultrahdr_color_gamut;
+
+// Transfer functions for image data
+typedef enum {
+ ULTRAHDR_TF_UNSPECIFIED = -1,
+ ULTRAHDR_TF_LINEAR = 0,
+ ULTRAHDR_TF_HLG = 1,
+ ULTRAHDR_TF_PQ = 2,
+ ULTRAHDR_TF_SRGB = 3,
+} ultrahdr_transfer_function;
+
+// Target output formats for decoder
+typedef enum {
+ ULTRAHDR_OUTPUT_SDR, // SDR in RGBA_8888 color format
+ ULTRAHDR_OUTPUT_HDR_LINEAR, // HDR in F16 color format (linear)
+ ULTRAHDR_OUTPUT_HDR_PQ, // HDR in RGBA_1010102 color format (PQ transfer function)
+ ULTRAHDR_OUTPUT_HDR_HLG, // HDR in RGBA_1010102 color format (HLG transfer function)
+} ultrahdr_output_format;
+
+/*
+ * Holds information for gain map related metadata.
+ */
+struct ultrahdr_metadata_struct {
+ // Ultra HDR library version
+ uint32_t version;
+ // Max Content Boost for the map
+ float maxContentBoost;
+ // Min Content Boost for the map
+ float minContentBoost;
+};
+typedef struct ultrahdr_metadata_struct* ultrahdr_metadata_ptr;
+
+} // namespace android::ultrahdr
+
+#endif //ANDROID_ULTRAHDR_ULTRAHDR_H
\ No newline at end of file
diff --git a/libs/jpegrecoverymap/jpegdecoderhelper.cpp b/libs/ultrahdr/jpegdecoderhelper.cpp
similarity index 98%
rename from libs/jpegrecoverymap/jpegdecoderhelper.cpp
rename to libs/ultrahdr/jpegdecoderhelper.cpp
index d36bbf8..12217b7 100644
--- a/libs/jpegrecoverymap/jpegdecoderhelper.cpp
+++ b/libs/ultrahdr/jpegdecoderhelper.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#include <jpegrecoverymap/jpegdecoderhelper.h>
+#include <ultrahdr/jpegdecoderhelper.h>
#include <utils/Log.h>
@@ -24,7 +24,7 @@
using namespace std;
-namespace android::jpegrecoverymap {
+namespace android::ultrahdr {
const uint32_t kAPP0Marker = JPEG_APP0; // JFIF
const uint32_t kAPP1Marker = JPEG_APP0 + 1; // EXIF, XMP
@@ -413,4 +413,4 @@
return true;
}
-} // namespace jpegrecoverymap
+} // namespace ultrahdr
diff --git a/libs/jpegrecoverymap/jpegencoderhelper.cpp b/libs/ultrahdr/jpegencoderhelper.cpp
similarity index 98%
rename from libs/jpegrecoverymap/jpegencoderhelper.cpp
rename to libs/ultrahdr/jpegencoderhelper.cpp
index 586cd34..fc6e4d1 100644
--- a/libs/jpegrecoverymap/jpegencoderhelper.cpp
+++ b/libs/ultrahdr/jpegencoderhelper.cpp
@@ -14,13 +14,13 @@
* limitations under the License.
*/
-#include <jpegrecoverymap/jpegencoderhelper.h>
+#include <ultrahdr/jpegencoderhelper.h>
#include <utils/Log.h>
#include <errno.h>
-namespace android::jpegrecoverymap {
+namespace android::ultrahdr {
// The destination manager that can access |mResultBuffer| in JpegEncoderHelper.
struct destination_mgr {
@@ -236,4 +236,4 @@
return true;
}
-} // namespace jpegrecoverymap
+} // namespace ultrahdr
diff --git a/libs/jpegrecoverymap/jpegr.cpp b/libs/ultrahdr/jpegr.cpp
similarity index 93%
rename from libs/jpegrecoverymap/jpegr.cpp
rename to libs/ultrahdr/jpegr.cpp
index 2590f63..8e1dc8c 100644
--- a/libs/jpegrecoverymap/jpegr.cpp
+++ b/libs/ultrahdr/jpegr.cpp
@@ -14,13 +14,13 @@
* limitations under the License.
*/
-#include <jpegrecoverymap/jpegr.h>
-#include <jpegrecoverymap/jpegencoderhelper.h>
-#include <jpegrecoverymap/jpegdecoderhelper.h>
-#include <jpegrecoverymap/gainmapmath.h>
-#include <jpegrecoverymap/jpegrutils.h>
-#include <jpegrecoverymap/multipictureformat.h>
-#include <jpegrecoverymap/icc.h>
+#include <ultrahdr/jpegr.h>
+#include <ultrahdr/jpegencoderhelper.h>
+#include <ultrahdr/jpegdecoderhelper.h>
+#include <ultrahdr/gainmapmath.h>
+#include <ultrahdr/jpegrutils.h>
+#include <ultrahdr/multipictureformat.h>
+#include <ultrahdr/icc.h>
#include <image_io/jpeg/jpeg_marker.h>
#include <image_io/jpeg/jpeg_info.h>
@@ -43,7 +43,7 @@
using namespace std;
using namespace photos_editing_formats::image_io;
-namespace android::jpegrecoverymap {
+namespace android::ultrahdr {
#define USE_SRGB_INVOETF_LUT 1
#define USE_HLG_OETF_LUT 1
@@ -136,7 +136,7 @@
/* Encode API-0 */
status_t JpegR::encodeJPEGR(jr_uncompressed_ptr uncompressed_p010_image,
- jpegr_transfer_function hdr_tf,
+ ultrahdr_transfer_function hdr_tf,
jr_compressed_ptr dest,
int quality,
jr_exif_ptr exif) {
@@ -153,7 +153,7 @@
return ret;
}
- jpegr_metadata_struct metadata;
+ ultrahdr_metadata_struct metadata;
metadata.version = kJpegrVersion;
jpegr_uncompressed_struct uncompressed_yuv_420_image;
@@ -174,7 +174,7 @@
compressed_map.data = compressed_map_data.get();
JPEGR_CHECK(compressGainMap(&map, &compressed_map));
- sp<DataStruct> icc = IccHelper::writeIccProfile(JPEGR_TF_SRGB,
+ sp<DataStruct> icc = IccHelper::writeIccProfile(ULTRAHDR_TF_SRGB,
uncompressed_yuv_420_image.colorGamut);
JpegEncoderHelper jpeg_encoder;
@@ -196,7 +196,7 @@
/* Encode API-1 */
status_t JpegR::encodeJPEGR(jr_uncompressed_ptr uncompressed_p010_image,
jr_uncompressed_ptr uncompressed_yuv_420_image,
- jpegr_transfer_function hdr_tf,
+ ultrahdr_transfer_function hdr_tf,
jr_compressed_ptr dest,
int quality,
jr_exif_ptr exif) {
@@ -215,7 +215,7 @@
return ret;
}
- jpegr_metadata_struct metadata;
+ ultrahdr_metadata_struct metadata;
metadata.version = kJpegrVersion;
jpegr_uncompressed_struct map;
@@ -230,7 +230,7 @@
compressed_map.data = compressed_map_data.get();
JPEGR_CHECK(compressGainMap(&map, &compressed_map));
- sp<DataStruct> icc = IccHelper::writeIccProfile(JPEGR_TF_SRGB,
+ sp<DataStruct> icc = IccHelper::writeIccProfile(ULTRAHDR_TF_SRGB,
uncompressed_yuv_420_image->colorGamut);
JpegEncoderHelper jpeg_encoder;
@@ -253,7 +253,7 @@
status_t JpegR::encodeJPEGR(jr_uncompressed_ptr uncompressed_p010_image,
jr_uncompressed_ptr uncompressed_yuv_420_image,
jr_compressed_ptr compressed_jpeg_image,
- jpegr_transfer_function hdr_tf,
+ ultrahdr_transfer_function hdr_tf,
jr_compressed_ptr dest) {
if (uncompressed_p010_image == nullptr
|| uncompressed_yuv_420_image == nullptr
@@ -267,7 +267,7 @@
return ret;
}
- jpegr_metadata_struct metadata;
+ ultrahdr_metadata_struct metadata;
metadata.version = kJpegrVersion;
jpegr_uncompressed_struct map;
@@ -290,7 +290,7 @@
/* Encode API-3 */
status_t JpegR::encodeJPEGR(jr_uncompressed_ptr uncompressed_p010_image,
jr_compressed_ptr compressed_jpeg_image,
- jpegr_transfer_function hdr_tf,
+ ultrahdr_transfer_function hdr_tf,
jr_compressed_ptr dest) {
if (uncompressed_p010_image == nullptr
|| compressed_jpeg_image == nullptr
@@ -318,7 +318,7 @@
return ERROR_JPEGR_RESOLUTION_MISMATCH;
}
- jpegr_metadata_struct metadata;
+ ultrahdr_metadata_struct metadata;
metadata.version = kJpegrVersion;
jpegr_uncompressed_struct map;
@@ -362,9 +362,9 @@
jr_uncompressed_ptr dest,
float max_display_boost,
jr_exif_ptr exif,
- jpegr_output_format output_format,
+ ultrahdr_output_format output_format,
jr_uncompressed_ptr gain_map,
- jr_metadata_ptr metadata) {
+ ultrahdr_metadata_ptr metadata) {
if (compressed_jpegr_image == nullptr || dest == nullptr) {
return ERROR_JPEGR_INVALID_NULL_PTR;
}
@@ -373,7 +373,7 @@
return ERROR_JPEGR_INVALID_INPUT_TYPE;
}
- if (output_format == JPEGR_OUTPUT_SDR) {
+ if (output_format == ULTRAHDR_OUTPUT_SDR) {
JpegDecoderHelper jpeg_decoder;
if (!jpeg_decoder.decompressImage(compressed_jpegr_image->data, compressed_jpegr_image->length,
true)) {
@@ -423,19 +423,19 @@
memcpy(gain_map->data, gain_map_decoder.getDecompressedImagePtr(), size);
}
- jpegr_metadata_struct jr_metadata;
+ ultrahdr_metadata_struct uhdr_metadata;
if (!getMetadataFromXMP(static_cast<uint8_t*>(gain_map_decoder.getXMPPtr()),
- gain_map_decoder.getXMPSize(), &jr_metadata)) {
+ gain_map_decoder.getXMPSize(), &uhdr_metadata)) {
return ERROR_JPEGR_DECODE_ERROR;
}
if (metadata != nullptr) {
- metadata->version = jr_metadata.version;
- metadata->minContentBoost = jr_metadata.minContentBoost;
- metadata->maxContentBoost = jr_metadata.maxContentBoost;
+ metadata->version = uhdr_metadata.version;
+ metadata->minContentBoost = uhdr_metadata.minContentBoost;
+ metadata->maxContentBoost = uhdr_metadata.maxContentBoost;
}
- if (output_format == JPEGR_OUTPUT_SDR) {
+ if (output_format == ULTRAHDR_OUTPUT_SDR) {
return NO_ERROR;
}
@@ -465,7 +465,7 @@
uncompressed_yuv_420_image.width = jpeg_decoder.getDecompressedImageWidth();
uncompressed_yuv_420_image.height = jpeg_decoder.getDecompressedImageHeight();
- JPEGR_CHECK(applyGainMap(&uncompressed_yuv_420_image, &map, &jr_metadata, output_format,
+ JPEGR_CHECK(applyGainMap(&uncompressed_yuv_420_image, &map, &uhdr_metadata, output_format,
max_display_boost, dest));
return NO_ERROR;
}
@@ -493,7 +493,7 @@
memcpy(dest->data, jpeg_encoder.getCompressedImagePtr(), jpeg_encoder.getCompressedImageSize());
dest->length = jpeg_encoder.getCompressedImageSize();
- dest->colorGamut = JPEGR_COLORGAMUT_UNSPECIFIED;
+ dest->colorGamut = ULTRAHDR_COLORGAMUT_UNSPECIFIED;
return NO_ERROR;
}
@@ -556,8 +556,8 @@
status_t JpegR::generateGainMap(jr_uncompressed_ptr uncompressed_yuv_420_image,
jr_uncompressed_ptr uncompressed_p010_image,
- jpegr_transfer_function hdr_tf,
- jr_metadata_ptr metadata,
+ ultrahdr_transfer_function hdr_tf,
+ ultrahdr_metadata_ptr metadata,
jr_uncompressed_ptr dest) {
if (uncompressed_yuv_420_image == nullptr
|| uncompressed_p010_image == nullptr
@@ -571,8 +571,8 @@
return ERROR_JPEGR_RESOLUTION_MISMATCH;
}
- if (uncompressed_yuv_420_image->colorGamut == JPEGR_COLORGAMUT_UNSPECIFIED
- || uncompressed_p010_image->colorGamut == JPEGR_COLORGAMUT_UNSPECIFIED) {
+ if (uncompressed_yuv_420_image->colorGamut == ULTRAHDR_COLORGAMUT_UNSPECIFIED
+ || uncompressed_p010_image->colorGamut == ULTRAHDR_COLORGAMUT_UNSPECIFIED) {
return ERROR_JPEGR_INVALID_COLORGAMUT;
}
@@ -586,7 +586,7 @@
dest->width = map_stride;
dest->height = map_height_aligned;
- dest->colorGamut = JPEGR_COLORGAMUT_UNSPECIFIED;
+ dest->colorGamut = ULTRAHDR_COLORGAMUT_UNSPECIFIED;
dest->data = new uint8_t[map_stride * map_height_aligned];
std::unique_ptr<uint8_t[]> map_data;
map_data.reset(reinterpret_cast<uint8_t*>(dest->data));
@@ -594,10 +594,10 @@
ColorTransformFn hdrInvOetf = nullptr;
float hdr_white_nits = 0.0f;
switch (hdr_tf) {
- case JPEGR_TF_LINEAR:
+ case ULTRAHDR_TF_LINEAR:
hdrInvOetf = identityConversion;
break;
- case JPEGR_TF_HLG:
+ case ULTRAHDR_TF_HLG:
#if USE_HLG_INVOETF_LUT
hdrInvOetf = hlgInvOetfLUT;
#else
@@ -605,7 +605,7 @@
#endif
hdr_white_nits = kHlgMaxNits;
break;
- case JPEGR_TF_PQ:
+ case ULTRAHDR_TF_PQ:
#if USE_PQ_INVOETF_LUT
hdrInvOetf = pqInvOetfLUT;
#else
@@ -628,16 +628,16 @@
ColorCalculationFn luminanceFn = nullptr;
switch (uncompressed_yuv_420_image->colorGamut) {
- case JPEGR_COLORGAMUT_BT709:
+ case ULTRAHDR_COLORGAMUT_BT709:
luminanceFn = srgbLuminance;
break;
- case JPEGR_COLORGAMUT_P3:
+ case ULTRAHDR_COLORGAMUT_P3:
luminanceFn = p3Luminance;
break;
- case JPEGR_COLORGAMUT_BT2100:
+ case ULTRAHDR_COLORGAMUT_BT2100:
luminanceFn = bt2100Luminance;
break;
- case JPEGR_COLORGAMUT_UNSPECIFIED:
+ case ULTRAHDR_COLORGAMUT_UNSPECIFIED:
// Should be impossible to hit after input validation.
return ERROR_JPEGR_INVALID_COLORGAMUT;
}
@@ -703,8 +703,8 @@
status_t JpegR::applyGainMap(jr_uncompressed_ptr uncompressed_yuv_420_image,
jr_uncompressed_ptr uncompressed_gain_map,
- jr_metadata_ptr metadata,
- jpegr_output_format output_format,
+ ultrahdr_metadata_ptr metadata,
+ ultrahdr_output_format output_format,
float max_display_boost,
jr_uncompressed_ptr dest) {
if (uncompressed_yuv_420_image == nullptr
@@ -759,13 +759,13 @@
size_t pixel_idx = x + y * width;
switch (output_format) {
- case JPEGR_OUTPUT_HDR_LINEAR:
+ case ULTRAHDR_OUTPUT_HDR_LINEAR:
{
uint64_t rgba_f16 = colorToRgbaF16(rgb_hdr);
reinterpret_cast<uint64_t*>(dest->data)[pixel_idx] = rgba_f16;
break;
}
- case JPEGR_OUTPUT_HDR_HLG:
+ case ULTRAHDR_OUTPUT_HDR_HLG:
{
#if USE_HLG_OETF_LUT
ColorTransformFn hdrOetf = hlgOetfLUT;
@@ -777,7 +777,7 @@
reinterpret_cast<uint32_t*>(dest->data)[pixel_idx] = rgba_1010102;
break;
}
- case JPEGR_OUTPUT_HDR_PQ:
+ case ULTRAHDR_OUTPUT_HDR_PQ:
{
#if USE_HLG_OETF_LUT
ColorTransformFn hdrOetf = pqOetfLUT;
@@ -910,7 +910,7 @@
status_t JpegR::appendGainMap(jr_compressed_ptr compressed_jpeg_image,
jr_compressed_ptr compressed_gain_map,
jr_exif_ptr exif,
- jr_metadata_ptr metadata,
+ ultrahdr_metadata_ptr metadata,
jr_compressed_ptr dest) {
if (compressed_jpeg_image == nullptr
|| compressed_gain_map == nullptr
@@ -1034,7 +1034,7 @@
uint16_t* src_chroma_data = reinterpret_cast<uint16_t*>(src->chroma_data);
if (src_chroma_data == nullptr) {
- src_chroma_data = &reinterpret_cast<uint16_t*>(src->data)[src->luma_stride * src->height];
+ src_chroma_data = &reinterpret_cast<uint16_t*>(src->data)[src_luma_stride * src->height];
}
if (src_luma_stride == 0) {
src_luma_stride = src->width;
@@ -1077,4 +1077,4 @@
return NO_ERROR;
}
-} // namespace android::jpegrecoverymap
+} // namespace android::ultrahdr
diff --git a/libs/jpegrecoverymap/jpegrutils.cpp b/libs/ultrahdr/jpegrutils.cpp
similarity index 97%
rename from libs/jpegrecoverymap/jpegrutils.cpp
rename to libs/ultrahdr/jpegrutils.cpp
index cde0ceb..9d07a6f 100644
--- a/libs/jpegrecoverymap/jpegrutils.cpp
+++ b/libs/ultrahdr/jpegrutils.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#include <jpegrecoverymap/jpegrutils.h>
+#include <ultrahdr/jpegrutils.h>
#include <algorithm>
#include <cmath>
@@ -30,7 +30,7 @@
using namespace photos_editing_formats::image_io;
using namespace std;
-namespace android::jpegrecoverymap {
+namespace android::ultrahdr {
/*
* Helper function used for generating XMP metadata.
*
@@ -256,7 +256,7 @@
const string XMPXmlHandler::minContentBoostAttrName = kMapGainMapMin;
const string XMPXmlHandler::maxContentBoostAttrName = kMapGainMapMax;
-bool getMetadataFromXMP(uint8_t* xmp_data, size_t xmp_size, jpegr_metadata_struct* metadata) {
+bool getMetadataFromXMP(uint8_t* xmp_data, size_t xmp_size, ultrahdr_metadata_struct* metadata) {
string nameSpace = "http://ns.adobe.com/xap/1.0/\0";
if (xmp_size < nameSpace.size()+2) {
@@ -338,7 +338,7 @@
return ss.str();
}
-string generateXmpForSecondaryImage(jpegr_metadata_struct& metadata) {
+string generateXmpForSecondaryImage(ultrahdr_metadata_struct& metadata) {
const vector<string> kConDirSeq({kConDirectory, string("rdf:Seq")});
std::stringstream ss;
@@ -365,4 +365,4 @@
return ss.str();
}
-} // namespace android::jpegrecoverymap
+} // namespace android::ultrahdr
diff --git a/libs/jpegrecoverymap/multipictureformat.cpp b/libs/ultrahdr/multipictureformat.cpp
similarity index 95%
rename from libs/jpegrecoverymap/multipictureformat.cpp
rename to libs/ultrahdr/multipictureformat.cpp
index a219aef..7a265c6 100644
--- a/libs/jpegrecoverymap/multipictureformat.cpp
+++ b/libs/ultrahdr/multipictureformat.cpp
@@ -13,10 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#include <jpegrecoverymap/multipictureformat.h>
-#include <jpegrecoverymap/jpegrutils.h>
+#include <ultrahdr/multipictureformat.h>
+#include <ultrahdr/jpegrutils.h>
-namespace android::jpegrecoverymap {
+namespace android::ultrahdr {
size_t calculateMpfSize() {
return sizeof(kMpfSig) + // Signature
kMpEndianSize + // Endianness
@@ -91,4 +91,4 @@
return dataStruct;
}
-} // namespace android::jpegrecoverymap
+} // namespace android::ultrahdr
diff --git a/libs/jpegrecoverymap/tests/Android.bp b/libs/ultrahdr/tests/Android.bp
similarity index 96%
rename from libs/jpegrecoverymap/tests/Android.bp
rename to libs/ultrahdr/tests/Android.bp
index 59b1237..7dd9d04 100644
--- a/libs/jpegrecoverymap/tests/Android.bp
+++ b/libs/ultrahdr/tests/Android.bp
@@ -22,7 +22,7 @@
}
cc_test {
- name: "libjpegrecoverymap_test",
+ name: "libultrahdr_test",
test_suites: ["device-tests"],
srcs: [
"jpegr_test.cpp",
@@ -38,7 +38,7 @@
"libgtest",
"libjpegdecoder",
"libjpegencoder",
- "libjpegrecoverymap",
+ "libultrahdr",
"libutils",
],
}
diff --git a/libs/jpegrecoverymap/tests/data/jpeg_image.jpg b/libs/ultrahdr/tests/data/jpeg_image.jpg
similarity index 100%
rename from libs/jpegrecoverymap/tests/data/jpeg_image.jpg
rename to libs/ultrahdr/tests/data/jpeg_image.jpg
Binary files differ
diff --git a/libs/jpegrecoverymap/tests/data/minnie-318x240.yu12 b/libs/ultrahdr/tests/data/minnie-318x240.yu12
similarity index 100%
rename from libs/jpegrecoverymap/tests/data/minnie-318x240.yu12
rename to libs/ultrahdr/tests/data/minnie-318x240.yu12
Binary files differ
diff --git a/libs/jpegrecoverymap/tests/data/minnie-320x240-y.jpg b/libs/ultrahdr/tests/data/minnie-320x240-y.jpg
similarity index 100%
rename from libs/jpegrecoverymap/tests/data/minnie-320x240-y.jpg
rename to libs/ultrahdr/tests/data/minnie-320x240-y.jpg
Binary files differ
diff --git a/libs/jpegrecoverymap/tests/data/minnie-320x240-yuv.jpg b/libs/ultrahdr/tests/data/minnie-320x240-yuv.jpg
similarity index 100%
rename from libs/jpegrecoverymap/tests/data/minnie-320x240-yuv.jpg
rename to libs/ultrahdr/tests/data/minnie-320x240-yuv.jpg
Binary files differ
diff --git a/libs/jpegrecoverymap/tests/data/minnie-320x240.y b/libs/ultrahdr/tests/data/minnie-320x240.y
similarity index 100%
rename from libs/jpegrecoverymap/tests/data/minnie-320x240.y
rename to libs/ultrahdr/tests/data/minnie-320x240.y
Binary files differ
diff --git a/libs/jpegrecoverymap/tests/data/minnie-320x240.yu12 b/libs/ultrahdr/tests/data/minnie-320x240.yu12
similarity index 100%
rename from libs/jpegrecoverymap/tests/data/minnie-320x240.yu12
rename to libs/ultrahdr/tests/data/minnie-320x240.yu12
Binary files differ
diff --git a/libs/jpegrecoverymap/tests/data/raw_p010_image.p010 b/libs/ultrahdr/tests/data/raw_p010_image.p010
similarity index 100%
rename from libs/jpegrecoverymap/tests/data/raw_p010_image.p010
rename to libs/ultrahdr/tests/data/raw_p010_image.p010
Binary files differ
diff --git a/libs/jpegrecoverymap/tests/data/raw_p010_image_with_stride.p010 b/libs/ultrahdr/tests/data/raw_p010_image_with_stride.p010
similarity index 100%
rename from libs/jpegrecoverymap/tests/data/raw_p010_image_with_stride.p010
rename to libs/ultrahdr/tests/data/raw_p010_image_with_stride.p010
Binary files differ
diff --git a/libs/jpegrecoverymap/tests/data/raw_yuv420_image.yuv420 b/libs/ultrahdr/tests/data/raw_yuv420_image.yuv420
similarity index 100%
rename from libs/jpegrecoverymap/tests/data/raw_yuv420_image.yuv420
rename to libs/ultrahdr/tests/data/raw_yuv420_image.yuv420
Binary files differ
diff --git a/libs/jpegrecoverymap/tests/gainmapmath_test.cpp b/libs/ultrahdr/tests/gainmapmath_test.cpp
similarity index 94%
rename from libs/jpegrecoverymap/tests/gainmapmath_test.cpp
rename to libs/ultrahdr/tests/gainmapmath_test.cpp
index 21de2e6..c456653 100644
--- a/libs/jpegrecoverymap/tests/gainmapmath_test.cpp
+++ b/libs/ultrahdr/tests/gainmapmath_test.cpp
@@ -17,9 +17,9 @@
#include <cmath>
#include <gtest/gtest.h>
#include <gmock/gmock.h>
-#include <jpegrecoverymap/gainmapmath.h>
+#include <ultrahdr/gainmapmath.h>
-namespace android::jpegrecoverymap {
+namespace android::ultrahdr {
class GainMapMathTest : public testing::Test {
public:
@@ -88,7 +88,7 @@
return luminance_scaled * scale_factor;
}
- Color Recover(Color yuv_gamma, float gain, jr_metadata_ptr metadata) {
+ Color Recover(Color yuv_gamma, float gain, ultrahdr_metadata_ptr metadata) {
Color rgb_gamma = srgbYuvToRgb(yuv_gamma);
Color rgb = srgbInvOetf(rgb_gamma);
return applyGain(rgb, gain, metadata);
@@ -108,7 +108,7 @@
0xB0, 0xB1,
0xB2, 0xB3,
};
- return { pixels, 4, 4, JPEGR_COLORGAMUT_BT709 };
+ return { pixels, 4, 4, ULTRAHDR_COLORGAMUT_BT709 };
}
Color (*Yuv420Colors())[4] {
@@ -141,7 +141,7 @@
0xA0 << 6, 0xB0 << 6, 0xA1 << 6, 0xB1 << 6,
0xA2 << 6, 0xB2 << 6, 0xA3 << 6, 0xB3 << 6,
};
- return { pixels, 4, 4, JPEGR_COLORGAMUT_BT709 };
+ return { pixels, 4, 4, ULTRAHDR_COLORGAMUT_BT709 };
}
Color (*P010Colors())[4] {
@@ -170,7 +170,7 @@
0x02, 0x12, 0x22, 0x32,
0x03, 0x13, 0x23, 0x33,
};
- return { pixels, 4, 4, JPEGR_COLORGAMUT_UNSPECIFIED };
+ return { pixels, 4, 4, ULTRAHDR_COLORGAMUT_UNSPECIFIED };
}
float (*MapValues())[4] {
@@ -554,7 +554,7 @@
TEST_F(GainMapMathTest, applyGainLUT) {
for (int boost = 1; boost <= 10; boost++) {
- jpegr_metadata_struct metadata = { .maxContentBoost = static_cast<float>(boost),
+ ultrahdr_metadata_struct metadata = { .maxContentBoost = static_cast<float>(boost),
.minContentBoost = 1.0f / static_cast<float>(boost) };
GainLUT gainLUT(&metadata);
GainLUT gainLUTWithBoost(&metadata, metadata.maxContentBoost);
@@ -584,7 +584,7 @@
}
for (int boost = 1; boost <= 10; boost++) {
- jpegr_metadata_struct metadata = { .maxContentBoost = static_cast<float>(boost),
+ ultrahdr_metadata_struct metadata = { .maxContentBoost = static_cast<float>(boost),
.minContentBoost = 1.0f };
GainLUT gainLUT(&metadata);
GainLUT gainLUTWithBoost(&metadata, metadata.maxContentBoost);
@@ -614,7 +614,7 @@
}
for (int boost = 1; boost <= 10; boost++) {
- jpegr_metadata_struct metadata = { .maxContentBoost = static_cast<float>(boost),
+ ultrahdr_metadata_struct metadata = { .maxContentBoost = static_cast<float>(boost),
.minContentBoost = 1.0f / pow(static_cast<float>(boost),
1.0f / 3.0f) };
GainLUT gainLUT(&metadata);
@@ -654,45 +654,45 @@
}
TEST_F(GainMapMathTest, ColorConversionLookup) {
- EXPECT_EQ(getHdrConversionFn(JPEGR_COLORGAMUT_BT709, JPEGR_COLORGAMUT_UNSPECIFIED),
+ EXPECT_EQ(getHdrConversionFn(ULTRAHDR_COLORGAMUT_BT709, ULTRAHDR_COLORGAMUT_UNSPECIFIED),
nullptr);
- EXPECT_EQ(getHdrConversionFn(JPEGR_COLORGAMUT_BT709, JPEGR_COLORGAMUT_BT709),
+ EXPECT_EQ(getHdrConversionFn(ULTRAHDR_COLORGAMUT_BT709, ULTRAHDR_COLORGAMUT_BT709),
identityConversion);
- EXPECT_EQ(getHdrConversionFn(JPEGR_COLORGAMUT_BT709, JPEGR_COLORGAMUT_P3),
+ EXPECT_EQ(getHdrConversionFn(ULTRAHDR_COLORGAMUT_BT709, ULTRAHDR_COLORGAMUT_P3),
p3ToBt709);
- EXPECT_EQ(getHdrConversionFn(JPEGR_COLORGAMUT_BT709, JPEGR_COLORGAMUT_BT2100),
+ EXPECT_EQ(getHdrConversionFn(ULTRAHDR_COLORGAMUT_BT709, ULTRAHDR_COLORGAMUT_BT2100),
bt2100ToBt709);
- EXPECT_EQ(getHdrConversionFn(JPEGR_COLORGAMUT_P3, JPEGR_COLORGAMUT_UNSPECIFIED),
+ EXPECT_EQ(getHdrConversionFn(ULTRAHDR_COLORGAMUT_P3, ULTRAHDR_COLORGAMUT_UNSPECIFIED),
nullptr);
- EXPECT_EQ(getHdrConversionFn(JPEGR_COLORGAMUT_P3, JPEGR_COLORGAMUT_BT709),
+ EXPECT_EQ(getHdrConversionFn(ULTRAHDR_COLORGAMUT_P3, ULTRAHDR_COLORGAMUT_BT709),
bt709ToP3);
- EXPECT_EQ(getHdrConversionFn(JPEGR_COLORGAMUT_P3, JPEGR_COLORGAMUT_P3),
+ EXPECT_EQ(getHdrConversionFn(ULTRAHDR_COLORGAMUT_P3, ULTRAHDR_COLORGAMUT_P3),
identityConversion);
- EXPECT_EQ(getHdrConversionFn(JPEGR_COLORGAMUT_P3, JPEGR_COLORGAMUT_BT2100),
+ EXPECT_EQ(getHdrConversionFn(ULTRAHDR_COLORGAMUT_P3, ULTRAHDR_COLORGAMUT_BT2100),
bt2100ToP3);
- EXPECT_EQ(getHdrConversionFn(JPEGR_COLORGAMUT_BT2100, JPEGR_COLORGAMUT_UNSPECIFIED),
+ EXPECT_EQ(getHdrConversionFn(ULTRAHDR_COLORGAMUT_BT2100, ULTRAHDR_COLORGAMUT_UNSPECIFIED),
nullptr);
- EXPECT_EQ(getHdrConversionFn(JPEGR_COLORGAMUT_BT2100, JPEGR_COLORGAMUT_BT709),
+ EXPECT_EQ(getHdrConversionFn(ULTRAHDR_COLORGAMUT_BT2100, ULTRAHDR_COLORGAMUT_BT709),
bt709ToBt2100);
- EXPECT_EQ(getHdrConversionFn(JPEGR_COLORGAMUT_BT2100, JPEGR_COLORGAMUT_P3),
+ EXPECT_EQ(getHdrConversionFn(ULTRAHDR_COLORGAMUT_BT2100, ULTRAHDR_COLORGAMUT_P3),
p3ToBt2100);
- EXPECT_EQ(getHdrConversionFn(JPEGR_COLORGAMUT_BT2100, JPEGR_COLORGAMUT_BT2100),
+ EXPECT_EQ(getHdrConversionFn(ULTRAHDR_COLORGAMUT_BT2100, ULTRAHDR_COLORGAMUT_BT2100),
identityConversion);
- EXPECT_EQ(getHdrConversionFn(JPEGR_COLORGAMUT_UNSPECIFIED, JPEGR_COLORGAMUT_UNSPECIFIED),
+ EXPECT_EQ(getHdrConversionFn(ULTRAHDR_COLORGAMUT_UNSPECIFIED, ULTRAHDR_COLORGAMUT_UNSPECIFIED),
nullptr);
- EXPECT_EQ(getHdrConversionFn(JPEGR_COLORGAMUT_UNSPECIFIED, JPEGR_COLORGAMUT_BT709),
+ EXPECT_EQ(getHdrConversionFn(ULTRAHDR_COLORGAMUT_UNSPECIFIED, ULTRAHDR_COLORGAMUT_BT709),
nullptr);
- EXPECT_EQ(getHdrConversionFn(JPEGR_COLORGAMUT_UNSPECIFIED, JPEGR_COLORGAMUT_P3),
+ EXPECT_EQ(getHdrConversionFn(ULTRAHDR_COLORGAMUT_UNSPECIFIED, ULTRAHDR_COLORGAMUT_P3),
nullptr);
- EXPECT_EQ(getHdrConversionFn(JPEGR_COLORGAMUT_UNSPECIFIED, JPEGR_COLORGAMUT_BT2100),
+ EXPECT_EQ(getHdrConversionFn(ULTRAHDR_COLORGAMUT_UNSPECIFIED, ULTRAHDR_COLORGAMUT_BT2100),
nullptr);
}
TEST_F(GainMapMathTest, EncodeGain) {
- jpegr_metadata_struct metadata = { .maxContentBoost = 4.0f,
+ ultrahdr_metadata_struct metadata = { .maxContentBoost = 4.0f,
.minContentBoost = 1.0f / 4.0f };
EXPECT_EQ(encodeGain(0.0f, 0.0f, &metadata), 127);
@@ -750,7 +750,7 @@
}
TEST_F(GainMapMathTest, ApplyGain) {
- jpegr_metadata_struct metadata = { .maxContentBoost = 4.0f,
+ ultrahdr_metadata_struct metadata = { .maxContentBoost = 4.0f,
.minContentBoost = 1.0f / 4.0f };
float displayBoost = metadata.maxContentBoost;
@@ -1049,7 +1049,7 @@
}
TEST_F(GainMapMathTest, ApplyMap) {
- jpegr_metadata_struct metadata = { .maxContentBoost = 8.0f,
+ ultrahdr_metadata_struct metadata = { .maxContentBoost = 8.0f,
.minContentBoost = 1.0f / 8.0f };
EXPECT_RGB_EQ(Recover(YuvWhite(), 1.0f, &metadata),
@@ -1134,4 +1134,4 @@
RgbWhite() / 2.0f);
}
-} // namespace android::jpegrecoverymap
+} // namespace android::ultrahdr
diff --git a/libs/jpegrecoverymap/tests/jpegdecoderhelper_test.cpp b/libs/ultrahdr/tests/jpegdecoderhelper_test.cpp
similarity index 95%
rename from libs/jpegrecoverymap/tests/jpegdecoderhelper_test.cpp
rename to libs/ultrahdr/tests/jpegdecoderhelper_test.cpp
index 2f32a56..c79dbe3 100644
--- a/libs/jpegrecoverymap/tests/jpegdecoderhelper_test.cpp
+++ b/libs/ultrahdr/tests/jpegdecoderhelper_test.cpp
@@ -14,13 +14,13 @@
* limitations under the License.
*/
-#include <jpegrecoverymap/jpegdecoderhelper.h>
+#include <ultrahdr/jpegdecoderhelper.h>
#include <gtest/gtest.h>
#include <utils/Log.h>
#include <fcntl.h>
-namespace android::jpegrecoverymap {
+namespace android::ultrahdr {
#define YUV_IMAGE "/sdcard/Documents/minnie-320x240-yuv.jpg"
#define YUV_IMAGE_SIZE 20193
@@ -99,4 +99,4 @@
ASSERT_GT(decoder.getDecompressedImageSize(), static_cast<uint32_t>(0));
}
-} // namespace android::jpegrecoverymap
\ No newline at end of file
+} // namespace android::ultrahdr
\ No newline at end of file
diff --git a/libs/jpegrecoverymap/tests/jpegencoderhelper_test.cpp b/libs/ultrahdr/tests/jpegencoderhelper_test.cpp
similarity index 96%
rename from libs/jpegrecoverymap/tests/jpegencoderhelper_test.cpp
rename to libs/ultrahdr/tests/jpegencoderhelper_test.cpp
index 095ac2f..b9a2d84 100644
--- a/libs/jpegrecoverymap/tests/jpegencoderhelper_test.cpp
+++ b/libs/ultrahdr/tests/jpegencoderhelper_test.cpp
@@ -14,13 +14,13 @@
* limitations under the License.
*/
-#include <jpegrecoverymap/jpegencoderhelper.h>
+#include <ultrahdr/jpegencoderhelper.h>
#include <gtest/gtest.h>
#include <utils/Log.h>
#include <fcntl.h>
-namespace android::jpegrecoverymap {
+namespace android::ultrahdr {
#define VALID_IMAGE "/sdcard/Documents/minnie-320x240.yu12"
#define VALID_IMAGE_WIDTH 320
@@ -121,5 +121,5 @@
ASSERT_GT(encoder.getCompressedImageSize(), static_cast<uint32_t>(0));
}
-} // namespace android::jpegrecoverymap
+} // namespace android::ultrahdr
diff --git a/libs/jpegrecoverymap/tests/jpegr_test.cpp b/libs/ultrahdr/tests/jpegr_test.cpp
similarity index 86%
rename from libs/jpegrecoverymap/tests/jpegr_test.cpp
rename to libs/ultrahdr/tests/jpegr_test.cpp
index 620f431..ba3b4d0 100644
--- a/libs/jpegrecoverymap/tests/jpegr_test.cpp
+++ b/libs/ultrahdr/tests/jpegr_test.cpp
@@ -14,9 +14,9 @@
* limitations under the License.
*/
-#include <jpegrecoverymap/jpegr.h>
-#include <jpegrecoverymap/jpegrutils.h>
-#include <jpegrecoverymap/gainmapmath.h>
+#include <ultrahdr/jpegr.h>
+#include <ultrahdr/jpegrutils.h>
+#include <ultrahdr/gainmapmath.h>
#include <fcntl.h>
#include <fstream>
#include <gtest/gtest.h>
@@ -36,7 +36,7 @@
#define SAVE_DECODING_RESULT true
#define SAVE_INPUT_RGBA true
-namespace android::jpegrecoverymap {
+namespace android::ultrahdr {
struct Timer {
struct timeval StartingTime;
@@ -118,16 +118,16 @@
class JpegRBenchmark : public JpegR {
public:
void BenchmarkGenerateGainMap(jr_uncompressed_ptr yuv420Image, jr_uncompressed_ptr p010Image,
- jr_metadata_ptr metadata, jr_uncompressed_ptr map);
+ ultrahdr_metadata_ptr metadata, jr_uncompressed_ptr map);
void BenchmarkApplyGainMap(jr_uncompressed_ptr yuv420Image, jr_uncompressed_ptr map,
- jr_metadata_ptr metadata, jr_uncompressed_ptr dest);
+ ultrahdr_metadata_ptr metadata, jr_uncompressed_ptr dest);
private:
const int kProfileCount = 10;
};
void JpegRBenchmark::BenchmarkGenerateGainMap(jr_uncompressed_ptr yuv420Image,
jr_uncompressed_ptr p010Image,
- jr_metadata_ptr metadata,
+ ultrahdr_metadata_ptr metadata,
jr_uncompressed_ptr map) {
ASSERT_EQ(yuv420Image->width, p010Image->width);
ASSERT_EQ(yuv420Image->height, p010Image->height);
@@ -137,7 +137,7 @@
timerStart(&genRecMapTime);
for (auto i = 0; i < kProfileCount; i++) {
ASSERT_EQ(OK, generateGainMap(
- yuv420Image, p010Image, jpegr_transfer_function::JPEGR_TF_HLG, metadata, map));
+ yuv420Image, p010Image, ultrahdr_transfer_function::ULTRAHDR_TF_HLG, metadata, map));
if (i != kProfileCount - 1) delete[] static_cast<uint8_t *>(map->data);
}
timerStop(&genRecMapTime);
@@ -150,13 +150,13 @@
void JpegRBenchmark::BenchmarkApplyGainMap(jr_uncompressed_ptr yuv420Image,
jr_uncompressed_ptr map,
- jr_metadata_ptr metadata,
+ ultrahdr_metadata_ptr metadata,
jr_uncompressed_ptr dest) {
Timer applyRecMapTime;
timerStart(&applyRecMapTime);
for (auto i = 0; i < kProfileCount; i++) {
- ASSERT_EQ(OK, applyGainMap(yuv420Image, map, metadata, JPEGR_OUTPUT_HDR_HLG,
+ ASSERT_EQ(OK, applyGainMap(yuv420Image, map, metadata, ULTRAHDR_OUTPUT_HDR_HLG,
metadata->maxContentBoost /* displayBoost */, dest));
}
timerStop(&applyRecMapTime);
@@ -169,17 +169,17 @@
TEST_F(JpegRTest, build) {
// Force all of the gain map lib to be linked by calling all public functions.
JpegR jpegRCodec;
- jpegRCodec.encodeJPEGR(nullptr, static_cast<jpegr_transfer_function>(0), nullptr, 0, nullptr);
- jpegRCodec.encodeJPEGR(nullptr, nullptr, static_cast<jpegr_transfer_function>(0),
+ jpegRCodec.encodeJPEGR(nullptr, static_cast<ultrahdr_transfer_function>(0), nullptr, 0, nullptr);
+ jpegRCodec.encodeJPEGR(nullptr, nullptr, static_cast<ultrahdr_transfer_function>(0),
nullptr, 0, nullptr);
- jpegRCodec.encodeJPEGR(nullptr, nullptr, nullptr, static_cast<jpegr_transfer_function>(0),
+ jpegRCodec.encodeJPEGR(nullptr, nullptr, nullptr, static_cast<ultrahdr_transfer_function>(0),
nullptr);
- jpegRCodec.encodeJPEGR(nullptr, nullptr, static_cast<jpegr_transfer_function>(0), nullptr);
+ jpegRCodec.encodeJPEGR(nullptr, nullptr, static_cast<ultrahdr_transfer_function>(0), nullptr);
jpegRCodec.decodeJPEGR(nullptr, nullptr);
}
TEST_F(JpegRTest, writeXmpThenRead) {
- jpegr_metadata_struct metadata_expected;
+ ultrahdr_metadata_struct metadata_expected;
metadata_expected.maxContentBoost = 1.25;
metadata_expected.minContentBoost = 0.75;
const std::string nameSpace = "http://ns.adobe.com/xap/1.0/\0";
@@ -194,7 +194,7 @@
xmpData.insert(xmpData.end(), reinterpret_cast<const uint8_t*>(xmp.c_str()),
reinterpret_cast<const uint8_t*>(xmp.c_str()) + xmp.size());
- jpegr_metadata_struct metadata_read;
+ ultrahdr_metadata_struct metadata_read;
EXPECT_TRUE(getMetadataFromXMP(xmpData.data(), xmpData.size(), &metadata_read));
EXPECT_FLOAT_EQ(metadata_expected.maxContentBoost, metadata_read.maxContentBoost);
EXPECT_FLOAT_EQ(metadata_expected.minContentBoost, metadata_read.minContentBoost);
@@ -210,7 +210,7 @@
}
mRawP010Image.width = TEST_IMAGE_WIDTH;
mRawP010Image.height = TEST_IMAGE_HEIGHT;
- mRawP010Image.colorGamut = jpegr_color_gamut::JPEGR_COLORGAMUT_BT2100;
+ mRawP010Image.colorGamut = ultrahdr_color_gamut::ULTRAHDR_COLORGAMUT_BT2100;
JpegR jpegRCodec;
@@ -218,7 +218,8 @@
jpegR.maxLength = TEST_IMAGE_WIDTH * TEST_IMAGE_HEIGHT * sizeof(uint8_t);
jpegR.data = malloc(jpegR.maxLength);
ret = jpegRCodec.encodeJPEGR(
- &mRawP010Image, jpegr_transfer_function::JPEGR_TF_HLG, &jpegR, DEFAULT_JPEG_QUALITY, nullptr);
+ &mRawP010Image, ultrahdr_transfer_function::ULTRAHDR_TF_HLG, &jpegR, DEFAULT_JPEG_QUALITY,
+ nullptr);
if (ret != OK) {
FAIL() << "Error code is " << ret;
}
@@ -264,7 +265,7 @@
mRawP010ImageWithStride.width = TEST_IMAGE_WIDTH;
mRawP010ImageWithStride.height = TEST_IMAGE_HEIGHT;
mRawP010ImageWithStride.luma_stride = TEST_IMAGE_STRIDE;
- mRawP010ImageWithStride.colorGamut = jpegr_color_gamut::JPEGR_COLORGAMUT_BT2100;
+ mRawP010ImageWithStride.colorGamut = ultrahdr_color_gamut::ULTRAHDR_COLORGAMUT_BT2100;
JpegR jpegRCodec;
@@ -272,7 +273,7 @@
jpegR.maxLength = TEST_IMAGE_WIDTH * TEST_IMAGE_HEIGHT * sizeof(uint8_t);
jpegR.data = malloc(jpegR.maxLength);
ret = jpegRCodec.encodeJPEGR(
- &mRawP010ImageWithStride, jpegr_transfer_function::JPEGR_TF_HLG, &jpegR,
+ &mRawP010ImageWithStride, ultrahdr_transfer_function::ULTRAHDR_TF_HLG, &jpegR,
DEFAULT_JPEG_QUALITY, nullptr);
if (ret != OK) {
FAIL() << "Error code is " << ret;
@@ -318,14 +319,14 @@
}
mRawP010Image.width = TEST_IMAGE_WIDTH;
mRawP010Image.height = TEST_IMAGE_HEIGHT;
- mRawP010Image.colorGamut = jpegr_color_gamut::JPEGR_COLORGAMUT_BT2100;
+ mRawP010Image.colorGamut = ultrahdr_color_gamut::ULTRAHDR_COLORGAMUT_BT2100;
if (!loadFile(RAW_YUV420_IMAGE, mRawYuv420Image.data, nullptr)) {
FAIL() << "Load file " << RAW_P010_IMAGE << " failed";
}
mRawYuv420Image.width = TEST_IMAGE_WIDTH;
mRawYuv420Image.height = TEST_IMAGE_HEIGHT;
- mRawYuv420Image.colorGamut = jpegr_color_gamut::JPEGR_COLORGAMUT_BT709;
+ mRawYuv420Image.colorGamut = ultrahdr_color_gamut::ULTRAHDR_COLORGAMUT_BT709;
JpegR jpegRCodec;
@@ -333,7 +334,7 @@
jpegR.maxLength = TEST_IMAGE_WIDTH * TEST_IMAGE_HEIGHT * sizeof(uint8_t);
jpegR.data = malloc(jpegR.maxLength);
ret = jpegRCodec.encodeJPEGR(
- &mRawP010Image, &mRawYuv420Image, jpegr_transfer_function::JPEGR_TF_HLG, &jpegR,
+ &mRawP010Image, &mRawYuv420Image, ultrahdr_transfer_function::ULTRAHDR_TF_HLG, &jpegR,
DEFAULT_JPEG_QUALITY, nullptr);
if (ret != OK) {
FAIL() << "Error code is " << ret;
@@ -379,19 +380,19 @@
}
mRawP010Image.width = TEST_IMAGE_WIDTH;
mRawP010Image.height = TEST_IMAGE_HEIGHT;
- mRawP010Image.colorGamut = jpegr_color_gamut::JPEGR_COLORGAMUT_BT2100;
+ mRawP010Image.colorGamut = ultrahdr_color_gamut::ULTRAHDR_COLORGAMUT_BT2100;
if (!loadFile(RAW_YUV420_IMAGE, mRawYuv420Image.data, nullptr)) {
FAIL() << "Load file " << RAW_P010_IMAGE << " failed";
}
mRawYuv420Image.width = TEST_IMAGE_WIDTH;
mRawYuv420Image.height = TEST_IMAGE_HEIGHT;
- mRawYuv420Image.colorGamut = jpegr_color_gamut::JPEGR_COLORGAMUT_BT709;
+ mRawYuv420Image.colorGamut = ultrahdr_color_gamut::ULTRAHDR_COLORGAMUT_BT709;
if (!loadFile(JPEG_IMAGE, mJpegImage.data, &mJpegImage.length)) {
FAIL() << "Load file " << JPEG_IMAGE << " failed";
}
- mJpegImage.colorGamut = jpegr_color_gamut::JPEGR_COLORGAMUT_BT709;
+ mJpegImage.colorGamut = ultrahdr_color_gamut::ULTRAHDR_COLORGAMUT_BT709;
JpegR jpegRCodec;
@@ -399,7 +400,8 @@
jpegR.maxLength = TEST_IMAGE_WIDTH * TEST_IMAGE_HEIGHT * sizeof(uint8_t);
jpegR.data = malloc(jpegR.maxLength);
ret = jpegRCodec.encodeJPEGR(
- &mRawP010Image, &mRawYuv420Image, &mJpegImage, jpegr_transfer_function::JPEGR_TF_HLG, &jpegR);
+ &mRawP010Image, &mRawYuv420Image, &mJpegImage, ultrahdr_transfer_function::ULTRAHDR_TF_HLG,
+ &jpegR);
if (ret != OK) {
FAIL() << "Error code is " << ret;
}
@@ -444,7 +446,7 @@
}
mRawP010Image.width = TEST_IMAGE_WIDTH;
mRawP010Image.height = TEST_IMAGE_HEIGHT;
- mRawP010Image.colorGamut = jpegr_color_gamut::JPEGR_COLORGAMUT_BT2100;
+ mRawP010Image.colorGamut = ultrahdr_color_gamut::ULTRAHDR_COLORGAMUT_BT2100;
if (SAVE_INPUT_RGBA) {
size_t rgbaSize = mRawP010Image.width * mRawP010Image.height * sizeof(uint32_t);
@@ -472,7 +474,7 @@
if (!loadFile(JPEG_IMAGE, mJpegImage.data, &mJpegImage.length)) {
FAIL() << "Load file " << JPEG_IMAGE << " failed";
}
- mJpegImage.colorGamut = jpegr_color_gamut::JPEGR_COLORGAMUT_BT709;
+ mJpegImage.colorGamut = ultrahdr_color_gamut::ULTRAHDR_COLORGAMUT_BT709;
JpegR jpegRCodec;
@@ -480,7 +482,7 @@
jpegR.maxLength = TEST_IMAGE_WIDTH * TEST_IMAGE_HEIGHT * sizeof(uint8_t);
jpegR.data = malloc(jpegR.maxLength);
ret = jpegRCodec.encodeJPEGR(
- &mRawP010Image, &mJpegImage, jpegr_transfer_function::JPEGR_TF_HLG, &jpegR);
+ &mRawP010Image, &mJpegImage, ultrahdr_transfer_function::ULTRAHDR_TF_HLG, &jpegR);
if (ret != OK) {
FAIL() << "Error code is " << ret;
}
@@ -525,25 +527,25 @@
}
mRawP010Image.width = kWidth;
mRawP010Image.height = kHeight;
- mRawP010Image.colorGamut = jpegr_color_gamut::JPEGR_COLORGAMUT_BT2100;
+ mRawP010Image.colorGamut = ultrahdr_color_gamut::ULTRAHDR_COLORGAMUT_BT2100;
if (!loadFile(RAW_YUV420_IMAGE, mRawYuv420Image.data, nullptr)) {
FAIL() << "Load file " << RAW_P010_IMAGE << " failed";
}
mRawYuv420Image.width = kWidth;
mRawYuv420Image.height = kHeight;
- mRawYuv420Image.colorGamut = jpegr_color_gamut::JPEGR_COLORGAMUT_BT709;
+ mRawYuv420Image.colorGamut = ultrahdr_color_gamut::ULTRAHDR_COLORGAMUT_BT709;
JpegRBenchmark benchmark;
- jpegr_metadata_struct metadata = { .version = 1,
+ ultrahdr_metadata_struct metadata = { .version = 1,
.maxContentBoost = 8.0f,
.minContentBoost = 1.0f / 8.0f };
jpegr_uncompressed_struct map = { .data = NULL,
.width = 0,
.height = 0,
- .colorGamut = JPEGR_COLORGAMUT_UNSPECIFIED };
+ .colorGamut = ULTRAHDR_COLORGAMUT_UNSPECIFIED };
benchmark.BenchmarkGenerateGainMap(&mRawYuv420Image, &mRawP010Image, &metadata, &map);
@@ -552,9 +554,9 @@
jpegr_uncompressed_struct dest = { .data = bufferDst.get(),
.width = 0,
.height = 0,
- .colorGamut = JPEGR_COLORGAMUT_UNSPECIFIED };
+ .colorGamut = ULTRAHDR_COLORGAMUT_UNSPECIFIED };
benchmark.BenchmarkApplyGainMap(&mRawYuv420Image, &map, &metadata, &dest);
}
-} // namespace android::recoverymap
+} // namespace android::ultrahdr