Lines Matching +full:test +full:. +full:rawimg

5  * you may not use this file except in compliance with the License.
8 * http://www.apache.org/licenses/LICENSE-2.0
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * limitations under the License.
21 #include <benchmark/benchmark.h>
23 #include "ultrahdr_api.h"
26 std::string kTestImagesPath = "/sdcard/test/UltrahdrBenchmarkTestRes-1.2/";
29 #include "android/log.h"
36 #define ALOGE(...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__) argument
40 #define ALOGE(...) ((void)0) argument
44 std::string kTestImagesPath = "./data/UltrahdrBenchmarkTestRes-1.2/";
49 #define ALOGE(...) \ argument
56 #define ALOGE(...) ((void)0) argument
62 "mountains_singlechannelgainmap.jpg",
63 "mountains_multichannelgainmap.jpg",
64 "mountains_singlechannelgamma.jpg",
65 "mountains_multichannelgamma.jpg",
69 "mountains_rgba1010102.raw",
70 "mountains_rgba16F.raw",
71 "mountains_p010.p010",
75 {"mountains_rgba1010102.raw", "mountains_rgba8888.raw"},
76 {"mountains_rgba16F.raw", "mountains_rgba8888.raw"},
77 {"mountains_p010.p010", "mountains_yuv420.yuv"},
133 DESC.read(static_cast<char*>(ADDR), (LEN)); \
134 if (DESC.gcount() != (LEN)) { \
135 ALOGE("Failed to read: %u bytes, read: %zu bytes", LEN, DESC.gcount()); \
141 if (ifd.good()) { in loadFile()
167 if (ifd.good()) { in loadFile()
168 int size = ifd.tellg(); in loadFile()
174 ifd.seekg(0, std::ios::beg); in loadFile()
203 if (mUhdrImg.data) { in ~DecBenchmark()
204 free(mUhdrImg.data); in ~DecBenchmark()
205 mUhdrImg.data = nullptr; in ~DecBenchmark()
214 if (ifd.good()) { in fillJpegImageHandle()
215 int size = ifd.tellg(); in fillJpegImageHandle()
222 ifd.close(); in fillJpegImageHandle()
223 return loadFile(filename.c_str(), uhdrImg->data, size); in fillJpegImageHandle()
266 int count = sizeof mHdrImg.planes / sizeof mHdrImg.planes[0]; in ~EncBenchmark()
268 if (mHdrImg.planes[i]) { in ~EncBenchmark()
269 free(mHdrImg.planes[i]); in ~EncBenchmark()
270 mHdrImg.planes[i] = nullptr; in ~EncBenchmark()
272 if (mSdrImg.planes[i]) { in ~EncBenchmark()
273 free(mSdrImg.planes[i]); in ~EncBenchmark()
274 mSdrImg.planes[i] = nullptr; in ~EncBenchmark()
279 bool fillRawImageHandle(uhdr_raw_image_t* rawImg, int width, int height, std::string file,
283 bool EncBenchmark::fillRawImageHandle(uhdr_raw_image_t* rawImg, int width, int height, in fillRawImageHandle() argument
286 rawImg->fmt = cf; in fillRawImageHandle()
287 rawImg->cg = cg; in fillRawImageHandle()
288 rawImg->ct = ct; in fillRawImageHandle()
289 rawImg->w = width; in fillRawImageHandle()
290 rawImg->h = height; in fillRawImageHandle()
293 rawImg->range = std::rand() % 2 ? UHDR_CR_FULL_RANGE : UHDR_CR_LIMITED_RANGE; in fillRawImageHandle()
294 rawImg->planes[UHDR_PLANE_Y] = malloc(width * height * bpp); in fillRawImageHandle()
295 rawImg->planes[UHDR_PLANE_UV] = malloc((width / 2) * (height / 2) * bpp * 2); in fillRawImageHandle()
296 rawImg->planes[UHDR_PLANE_V] = nullptr; in fillRawImageHandle()
297 rawImg->stride[UHDR_PLANE_Y] = width; in fillRawImageHandle()
298 rawImg->stride[UHDR_PLANE_UV] = width; in fillRawImageHandle()
299 rawImg->stride[UHDR_PLANE_V] = 0; in fillRawImageHandle()
300 return loadFile(file.c_str(), rawImg); in fillRawImageHandle()
304 rawImg->range = UHDR_CR_FULL_RANGE; in fillRawImageHandle()
305 rawImg->planes[UHDR_PLANE_PACKED] = malloc(width * height * bpp); in fillRawImageHandle()
306 rawImg->planes[UHDR_PLANE_UV] = nullptr; in fillRawImageHandle()
307 rawImg->planes[UHDR_PLANE_V] = nullptr; in fillRawImageHandle()
308 rawImg->stride[UHDR_PLANE_PACKED] = width; in fillRawImageHandle()
309 rawImg->stride[UHDR_PLANE_UV] = 0; in fillRawImageHandle()
310 rawImg->stride[UHDR_PLANE_V] = 0; in fillRawImageHandle()
311 return loadFile(file.c_str(), rawImg); in fillRawImageHandle()
313 rawImg->range = UHDR_CR_FULL_RANGE; in fillRawImageHandle()
314 rawImg->planes[UHDR_PLANE_Y] = malloc(width * height); in fillRawImageHandle()
315 rawImg->planes[UHDR_PLANE_U] = malloc((width / 2) * (height / 2)); in fillRawImageHandle()
316 rawImg->planes[UHDR_PLANE_V] = malloc((width / 2) * (height / 2)); in fillRawImageHandle()
317 rawImg->stride[UHDR_PLANE_Y] = width; in fillRawImageHandle()
318 rawImg->stride[UHDR_PLANE_U] = width / 2; in fillRawImageHandle()
319 rawImg->stride[UHDR_PLANE_V] = width / 2; in fillRawImageHandle()
320 return loadFile(file.c_str(), rawImg); in fillRawImageHandle()
328 s.SetLabel(benchmark.mUhdrFile + ", OutputFormat: " + imgFmtToString(benchmark.mOfmt) + in BM_UHDRDecode()
329 ", ColorTransfer: " + tfToString(benchmark.mTf) + in BM_UHDRDecode()
330 ", enableGLES: " + (benchmark.mEnableGLES ? "true" : "false")); in BM_UHDRDecode()
332 benchmark.mUhdrFile = kTestImagesPath + "jpegr/" + benchmark.mUhdrFile; in BM_UHDRDecode()
334 if (!benchmark.fillJpegImageHandle(&benchmark.mUhdrImg, benchmark.mUhdrFile)) { in BM_UHDRDecode()
335 s.SkipWithError("unable to load file : " + benchmark.mUhdrFile); in BM_UHDRDecode()
342 if (status.error_code != UHDR_CODEC_OK) { \ in BM_UHDRDecode()
344 s.SkipWithError(status.has_detail ? status.detail : "Unknown error"); \ in BM_UHDRDecode()
351 RET_IF_ERR(uhdr_dec_set_image(decHandle, &benchmark.mUhdrImg)) in BM_UHDRDecode()
352 RET_IF_ERR(uhdr_dec_set_out_color_transfer(decHandle, benchmark.mTf)) in BM_UHDRDecode()
353 RET_IF_ERR(uhdr_dec_set_out_img_format(decHandle, benchmark.mOfmt)) in BM_UHDRDecode()
354 RET_IF_ERR(uhdr_enable_gpu_acceleration(decHandle, benchmark.mEnableGLES)) in BM_UHDRDecode()
365 if (status.error_code != UHDR_CODEC_OK) { \
367 s.SkipWithError(status.has_detail ? status.detail : "Unknown error"); \
375 s.SetLabel( in BM_UHDREncode_Api0()
376 benchmark.mHdrFile + ", " + std::to_string(benchmark.mWidth) + "x" + in BM_UHDREncode_Api0()
377 std::to_string(benchmark.mHeight) + ", " + colorGamutToString(benchmark.mHdrCg) + ", " + in BM_UHDREncode_Api0()
378 (benchmark.mHdrFile.find("rgba16F") != std::string::npos ? "linear" in BM_UHDREncode_Api0()
379 : tfToString(benchmark.mHdrCt)) + in BM_UHDREncode_Api0()
381 (benchmark.mUseMultiChannelGainMap == 0 ? "singlechannelgainmap" : "multichannelgainmap") + in BM_UHDREncode_Api0()
382 ", gamma: " + std::to_string(benchmark.mGamma)); in BM_UHDREncode_Api0()
384 if (benchmark.mHdrFile.find("p010") != std::string::npos) { in BM_UHDREncode_Api0()
385 benchmark.mHdrFile = kTestImagesPath + "p010/" + benchmark.mHdrFile; in BM_UHDREncode_Api0()
386 benchmark.mHdrCf = UHDR_IMG_FMT_24bppYCbCrP010; in BM_UHDREncode_Api0()
387 } else if (benchmark.mHdrFile.find("rgba1010102") != std::string::npos) { in BM_UHDREncode_Api0()
388 benchmark.mHdrFile = kTestImagesPath + "rgba1010102/" + benchmark.mHdrFile; in BM_UHDREncode_Api0()
389 benchmark.mHdrCf = UHDR_IMG_FMT_32bppRGBA1010102; in BM_UHDREncode_Api0()
390 } else if (benchmark.mHdrFile.find("rgba16F") != std::string::npos) { in BM_UHDREncode_Api0()
391 benchmark.mHdrFile = kTestImagesPath + "rgba16F/" + benchmark.mHdrFile; in BM_UHDREncode_Api0()
392 benchmark.mHdrCf = UHDR_IMG_FMT_64bppRGBAHalfFloat; in BM_UHDREncode_Api0()
393 benchmark.mHdrCt = UHDR_CT_LINEAR; in BM_UHDREncode_Api0()
395 s.SkipWithError("Invalid file format : " + benchmark.mHdrFile); in BM_UHDREncode_Api0()
399 if (!benchmark.fillRawImageHandle(&benchmark.mHdrImg, benchmark.mWidth, benchmark.mHeight, in BM_UHDREncode_Api0()
400 benchmark.mHdrFile, benchmark.mHdrCf, benchmark.mHdrCg, in BM_UHDREncode_Api0()
401 benchmark.mHdrCt)) { in BM_UHDREncode_Api0()
402 s.SkipWithError("unable to load file : " + benchmark.mHdrFile); in BM_UHDREncode_Api0()
408 RET_IF_ERR(uhdr_enc_set_raw_image(encHandle, &benchmark.mHdrImg, UHDR_HDR_IMG)) in BM_UHDREncode_Api0()
410 uhdr_enc_set_using_multi_channel_gainmap(encHandle, benchmark.mUseMultiChannelGainMap)) in BM_UHDREncode_Api0()
411 RET_IF_ERR(uhdr_enc_set_gainmap_scale_factor(encHandle, benchmark.mMapDimensionScaleFactor)) in BM_UHDREncode_Api0()
412 RET_IF_ERR(uhdr_enc_set_gainmap_gamma(encHandle, benchmark.mGamma)) in BM_UHDREncode_Api0()
422 s.SetLabel( in BM_UHDREncode_Api1()
423 benchmark.mHdrFile + ", " + benchmark.mSdrFile + ", " + std::to_string(benchmark.mWidth) + in BM_UHDREncode_Api1()
424 "x" + std::to_string(benchmark.mHeight) + ", hdrCg: " + colorGamutToString(benchmark.mHdrCg) + in BM_UHDREncode_Api1()
426 (benchmark.mHdrFile.find("rgba16F") != std::string::npos ? "linear" in BM_UHDREncode_Api1()
427 : tfToString(benchmark.mHdrCt)) + in BM_UHDREncode_Api1()
428 ", sdrCg: " + colorGamutToString(benchmark.mSdrCg) + ", " + in BM_UHDREncode_Api1()
429 (benchmark.mUseMultiChannelGainMap == 0 ? "singlechannelgainmap" : "multichannelgainmap") + in BM_UHDREncode_Api1()
430 ", gamma: " + std::to_string(benchmark.mGamma) + ", " + in BM_UHDREncode_Api1()
431 (benchmark.mEncPreset == UHDR_USAGE_BEST_QUALITY ? "best_quality" : "realtime")); in BM_UHDREncode_Api1()
433 if (benchmark.mHdrFile.find("p010") != std::string::npos) { in BM_UHDREncode_Api1()
434 benchmark.mHdrFile = kTestImagesPath + "p010/" + benchmark.mHdrFile; in BM_UHDREncode_Api1()
435 benchmark.mHdrCf = UHDR_IMG_FMT_24bppYCbCrP010; in BM_UHDREncode_Api1()
436 } else if (benchmark.mHdrFile.find("rgba1010102") != std::string::npos) { in BM_UHDREncode_Api1()
437 benchmark.mHdrFile = kTestImagesPath + "rgba1010102/" + benchmark.mHdrFile; in BM_UHDREncode_Api1()
438 benchmark.mHdrCf = UHDR_IMG_FMT_32bppRGBA1010102; in BM_UHDREncode_Api1()
439 } else if (benchmark.mHdrFile.find("rgba16F") != std::string::npos) { in BM_UHDREncode_Api1()
440 benchmark.mHdrFile = kTestImagesPath + "rgba16F/" + benchmark.mHdrFile; in BM_UHDREncode_Api1()
441 benchmark.mHdrCf = UHDR_IMG_FMT_64bppRGBAHalfFloat; in BM_UHDREncode_Api1()
442 benchmark.mHdrCt = UHDR_CT_LINEAR; in BM_UHDREncode_Api1()
444 s.SkipWithError("Invalid hdr file format : " + benchmark.mHdrFile); in BM_UHDREncode_Api1()
448 if (benchmark.mSdrFile.find("yuv420") != std::string::npos) { in BM_UHDREncode_Api1()
449 benchmark.mSdrFile = kTestImagesPath + "yuv420/" + benchmark.mSdrFile; in BM_UHDREncode_Api1()
450 benchmark.mSdrCf = UHDR_IMG_FMT_12bppYCbCr420; in BM_UHDREncode_Api1()
451 } else if (benchmark.mSdrFile.find("rgba8888") != std::string::npos) { in BM_UHDREncode_Api1()
452 benchmark.mSdrFile = kTestImagesPath + "rgba8888/" + benchmark.mSdrFile; in BM_UHDREncode_Api1()
453 benchmark.mSdrCf = UHDR_IMG_FMT_32bppRGBA8888; in BM_UHDREncode_Api1()
455 s.SkipWithError("Invalid sdr file format : " + benchmark.mSdrFile); in BM_UHDREncode_Api1()
459 if (!benchmark.fillRawImageHandle(&benchmark.mHdrImg, benchmark.mWidth, benchmark.mHeight, in BM_UHDREncode_Api1()
460 benchmark.mHdrFile, benchmark.mHdrCf, benchmark.mHdrCg, in BM_UHDREncode_Api1()
461 benchmark.mHdrCt)) { in BM_UHDREncode_Api1()
462 s.SkipWithError("unable to load file : " + benchmark.mHdrFile); in BM_UHDREncode_Api1()
465 if (!benchmark.fillRawImageHandle(&benchmark.mSdrImg, benchmark.mWidth, benchmark.mHeight, in BM_UHDREncode_Api1()
466 benchmark.mSdrFile, benchmark.mSdrCf, benchmark.mSdrCg, in BM_UHDREncode_Api1()
467 benchmark.mSdrCt)) { in BM_UHDREncode_Api1()
468 s.SkipWithError("unable to load sdr file : " + benchmark.mSdrFile); in BM_UHDREncode_Api1()
474 RET_IF_ERR(uhdr_enc_set_raw_image(encHandle, &benchmark.mHdrImg, UHDR_HDR_IMG)) in BM_UHDREncode_Api1()
475 RET_IF_ERR(uhdr_enc_set_raw_image(encHandle, &benchmark.mSdrImg, UHDR_SDR_IMG)) in BM_UHDREncode_Api1()
477 uhdr_enc_set_using_multi_channel_gainmap(encHandle, benchmark.mUseMultiChannelGainMap)) in BM_UHDREncode_Api1()
478 RET_IF_ERR(uhdr_enc_set_gainmap_scale_factor(encHandle, benchmark.mMapDimensionScaleFactor)) in BM_UHDREncode_Api1()
479 RET_IF_ERR(uhdr_enc_set_gainmap_gamma(encHandle, benchmark.mGamma)) in BM_UHDREncode_Api1()
480 RET_IF_ERR(uhdr_enc_set_preset(encHandle, benchmark.mEncPreset)) in BM_UHDREncode_Api1()
490 testParamsDecodeAPI.push_back({uhdrFile, UHDR_CT_HLG, UHDR_IMG_FMT_32bppRGBA1010102, false}); in addTestVectors()
491 testParamsDecodeAPI.push_back({uhdrFile, UHDR_CT_PQ, UHDR_IMG_FMT_32bppRGBA1010102, false}); in addTestVectors()
492 testParamsDecodeAPI.push_back( in addTestVectors()
494 testParamsDecodeAPI.push_back({uhdrFile, UHDR_CT_HLG, UHDR_IMG_FMT_32bppRGBA1010102, true}); in addTestVectors()
495 testParamsDecodeAPI.push_back({uhdrFile, UHDR_CT_PQ, UHDR_IMG_FMT_32bppRGBA1010102, true}); in addTestVectors()
496 testParamsDecodeAPI.push_back( in addTestVectors()
498 testParamsDecodeAPI.push_back({uhdrFile, UHDR_CT_SRGB, UHDR_IMG_FMT_32bppRGBA8888, false}); in addTestVectors()
504 testParamsAPI0.push_back({hdrFile, 4080, 3072, UHDR_CG_BT_2100, UHDR_CT_PQ, 0, 1.0f}); in addTestVectors()
505 testParamsAPI0.push_back({hdrFile, 4080, 3072, UHDR_CG_BT_2100, UHDR_CT_PQ, 1, 1.0f}); in addTestVectors()
506 testParamsAPI0.push_back({hdrFile, 4080, 3072, UHDR_CG_BT_2100, UHDR_CT_PQ, 0, 1.571f}); in addTestVectors()
507 testParamsAPI0.push_back({hdrFile, 4080, 3072, UHDR_CG_BT_2100, UHDR_CT_PQ, 1, 1.616f}); in addTestVectors()
513 testParamsAPI1.push_back({inputFiles.first, inputFiles.second, 4080, 3072, UHDR_CG_BT_2100, in addTestVectors()
515 testParamsAPI1.push_back({inputFiles.first, inputFiles.second, 4080, 3072, UHDR_CG_BT_2100, in addTestVectors()
517 testParamsAPI1.push_back({inputFiles.first, inputFiles.second, 4080, 3072, UHDR_CG_BT_2100, in addTestVectors()
519 testParamsAPI1.push_back({inputFiles.first, inputFiles.second, 4080, 3072, UHDR_CG_BT_2100, in addTestVectors()
521 testParamsAPI1.push_back({inputFiles.first, inputFiles.second, 4080, 3072, UHDR_CG_BT_2100, in addTestVectors()
523 testParamsAPI1.push_back({inputFiles.first, inputFiles.second, 4080, 3072, UHDR_CG_BT_2100, in addTestVectors()
525 testParamsAPI1.push_back({inputFiles.first, inputFiles.second, 4080, 3072, UHDR_CG_BT_2100, in addTestVectors()
527 testParamsAPI1.push_back({inputFiles.first, inputFiles.second, 4080, 3072, UHDR_CG_BT_2100, in addTestVectors()