Loading libs/jpegrecoverymap/tests/recoverymap_test.cpp +25 −0 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ */ #include <jpegrecoverymap/recoverymap.h> #include <jpegrecoverymap/recoverymapmath.h> #include <jpegrecoverymap/recoverymaputils.h> #include <fcntl.h> #include <fstream> Loading @@ -30,6 +31,7 @@ #define SAVE_ENCODING_RESULT true #define SAVE_DECODING_RESULT true #define SAVE_INPUT_RGBA true namespace android::recoverymap { Loading Loading @@ -304,6 +306,29 @@ TEST_F(RecoveryMapTest, encodeFromJpegThenDecode) { mRawP010Image.height = TEST_IMAGE_HEIGHT; mRawP010Image.colorGamut = jpegr_color_gamut::JPEGR_COLORGAMUT_BT2100; if (SAVE_INPUT_RGBA) { size_t rgbaSize = mRawP010Image.width * mRawP010Image.height * sizeof(uint32_t); uint32_t *data = (uint32_t *)malloc(rgbaSize); for (size_t y = 0; y < mRawP010Image.height; ++y) { for (size_t x = 0; x < mRawP010Image.width; ++x) { Color hdr_yuv_gamma = getP010Pixel(&mRawP010Image, x, y); Color hdr_rgb_gamma = bt2100YuvToRgb(hdr_yuv_gamma); uint32_t rgba1010102 = colorToRgba1010102(hdr_rgb_gamma); size_t pixel_idx = x + y * mRawP010Image.width; reinterpret_cast<uint32_t*>(data)[pixel_idx] = rgba1010102; } } // Output image data to file std::string filePath = "/sdcard/Documents/input_from_p010.rgb10"; std::ofstream imageFile(filePath.c_str(), std::ofstream::binary); if (!imageFile.is_open()) { ALOGE("%s: Unable to create file %s", __FUNCTION__, filePath.c_str()); } imageFile.write((const char*)data, rgbaSize); free(data); } if (!loadFile(JPEG_IMAGE, mJpegImage.data, &mJpegImage.length)) { FAIL() << "Load file " << JPEG_IMAGE << " failed"; } Loading Loading
libs/jpegrecoverymap/tests/recoverymap_test.cpp +25 −0 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ */ #include <jpegrecoverymap/recoverymap.h> #include <jpegrecoverymap/recoverymapmath.h> #include <jpegrecoverymap/recoverymaputils.h> #include <fcntl.h> #include <fstream> Loading @@ -30,6 +31,7 @@ #define SAVE_ENCODING_RESULT true #define SAVE_DECODING_RESULT true #define SAVE_INPUT_RGBA true namespace android::recoverymap { Loading Loading @@ -304,6 +306,29 @@ TEST_F(RecoveryMapTest, encodeFromJpegThenDecode) { mRawP010Image.height = TEST_IMAGE_HEIGHT; mRawP010Image.colorGamut = jpegr_color_gamut::JPEGR_COLORGAMUT_BT2100; if (SAVE_INPUT_RGBA) { size_t rgbaSize = mRawP010Image.width * mRawP010Image.height * sizeof(uint32_t); uint32_t *data = (uint32_t *)malloc(rgbaSize); for (size_t y = 0; y < mRawP010Image.height; ++y) { for (size_t x = 0; x < mRawP010Image.width; ++x) { Color hdr_yuv_gamma = getP010Pixel(&mRawP010Image, x, y); Color hdr_rgb_gamma = bt2100YuvToRgb(hdr_yuv_gamma); uint32_t rgba1010102 = colorToRgba1010102(hdr_rgb_gamma); size_t pixel_idx = x + y * mRawP010Image.width; reinterpret_cast<uint32_t*>(data)[pixel_idx] = rgba1010102; } } // Output image data to file std::string filePath = "/sdcard/Documents/input_from_p010.rgb10"; std::ofstream imageFile(filePath.c_str(), std::ofstream::binary); if (!imageFile.is_open()) { ALOGE("%s: Unable to create file %s", __FUNCTION__, filePath.c_str()); } imageFile.write((const char*)data, rgbaSize); free(data); } if (!loadFile(JPEG_IMAGE, mJpegImage.data, &mJpegImage.length)) { FAIL() << "Load file " << JPEG_IMAGE << " failed"; } Loading