41#include "gtest/gtest.h"
49#ifdef OJPH_COMPILER_MSVC
50 return _popen(command, modes);
52 return popen(command, modes);
62#ifdef OJPH_COMPILER_MSVC
63 return _pclose(stream);
65 return pclose(stream);
73int execute(
const std::string& cmd, std::string& result)
75 std::array<char, 128> buffer;
80 throw std::runtime_error(
"ojph_popen() failed!");
83 if (fgets(buffer.data(), 128, pipe) !=
nullptr)
84 result += buffer.data();
87 if (rc != EXIT_SUCCESS)
97#define SRC_FILE_DIR ".\\jp2k_test_codestreams\\openjph\\"
98#define OUT_FILE_DIR ".\\"
99#define REF_FILE_DIR ".\\jp2k_test_codestreams\\openjph\\references\\"
100#define MSE_PAE_PATH ".\\mse_pae"
101#define COMPARE_FILES_PATH ".\\compare_files"
102#define EXPAND_EXECUTABLE ".\\ojph_expand.exe"
103#define COMPRESS_EXECUTABLE ".\\ojph_compress.exe"
105#define SRC_FILE_DIR "./jp2k_test_codestreams/openjph/"
106#define OUT_FILE_DIR "./"
107#define REF_FILE_DIR "./jp2k_test_codestreams/openjph/references/"
108#define MSE_PAE_PATH "./mse_pae"
109#define COMPARE_FILES_PATH "./compare_files"
123#define EXPAND_EXECUTABLE "./ojph_expand"
124#define COMPRESS_EXECUTABLE "./ojph_compress"
132#define TOL_DOUBLE 0.01
139 const std::string& base_filename,
140 const std::string& extended_base_fname,
141 const std::string& out_ext,
142 const std::string& extra_options)
145 std::string result, command;
148 +
" -o " +
OUT_FILE_DIR + base_filename + extended_base_fname +
149 "." + out_ext +
" " + extra_options;
150 EXPECT_EQ(
execute(command, result), 0);
152 catch (
const std::runtime_error& error) {
153 FAIL() << error.what();
161 const std::string& src_ext,
162 const std::string& out_ext)
165 std::string result, command;
168 +
" -o " +
OUT_FILE_DIR + base_filename +
"." + out_ext;
169 EXPECT_EQ(
execute(command, result), 0);
171 catch (
const std::runtime_error& error) {
172 FAIL() << error.what();
180 const std::string& out_ext,
181 const std::string& decode_ext)
184 std::string result, command;
187 +
" -o " +
OUT_FILE_DIR + base_filename +
"." + decode_ext;
188 EXPECT_EQ(
execute(command, result), 0);
190 catch (
const std::runtime_error& error) {
191 FAIL() << error.what();
199 const std::string& out_ext,
200 const std::string& ref_filename,
201 const std::string& yuv_specs,
202 int num_components,
double* mse,
int* pae)
205 std::string result, command;
207 +
" " +
OUT_FILE_DIR + base_filename +
"." + out_ext + yuv_specs
209 EXPECT_EQ(
execute(command, result), 0);
212 for (
int c = 0; c < num_components; ++c) {
213 if (pos < result.length()) {
214 double valf = atof(result.c_str() + pos);
218 FAIL() <<
"mse_pae result string does not have enough entries.";
220 pos = result.find(
" ", pos);
221 if (pos != std::string::npos)
223 if (pos < result.length()) {
224 int vali = atoi(result.c_str() + pos);
228 FAIL() <<
"mse_pae result string does not have enough entries.";
230 pos = result.find(
"\n", pos);
231 if (pos != std::string::npos)
235 catch (
const std::runtime_error& error) {
236 FAIL() << error.what();
244 const std::string& extended_base_fname,
245 const std::string& ext)
248 std::string result, command;
250 +
" " +
OUT_FILE_DIR + base_filename + extended_base_fname +
"." + ext
252 EXPECT_EQ(
execute(command, result), 0);
254 catch (
const std::runtime_error& error) {
255 FAIL() << error.what();
265 const std::string& base_filename,
266 const std::string& out_ext,
267 const std::string& extra_options)
270 std::string result, command;
274 +
" " + extra_options;
275 EXPECT_EQ(
execute(command, result), 0);
277 catch (
const std::runtime_error& error) {
278 FAIL() << error.what();
292#define RAW_TEST_WIDTH 256
293#define RAW_TEST_HEIGHT 256
294#define RAW_TEST_NUM_SAMPLES (RAW_TEST_WIDTH * RAW_TEST_HEIGHT)
302 upper = ((
ojph::si64)1 << (bit_depth - 1)) - 1;
323 std::string name = std::string(
OUT_FILE_DIR) + filename;
324 FILE* f = fopen(name.c_str(),
"wb");
326 FAIL() <<
"Unable to open file " << name <<
" for writing.";
330 ojph::ui32 bytes_per_sample = (bit_depth + 7) >> 3;
338 for (
ojph::ui32 b = 0; b < bytes_per_sample; ++b)
339 *dp++ = (
ojph::ui8)((val >> (8 * b)) & 0xFFu);
341 EXPECT_EQ(fwrite(line, 1, line_size, f), line_size);
356 std::string name = std::string(
OUT_FILE_DIR) + filename;
357 FILE* f = fopen(name.c_str(),
"rb");
359 FAIL() <<
"Unable to open file " << name <<
" for reading.";
363 ojph::ui32 bytes_per_sample = (bit_depth + 7) >> 3;
366 ojph::si64 first_expected = 0, first_found = 0;
370 if (fread(line, 1, line_size, f) != line_size) {
372 FAIL() <<
"Not enough data in file " << name <<
".";
378 for (
ojph::ui32 b = 0; b < bytes_per_sample; ++b)
381 if (is_signed && (val & sign_bit))
386 if (found != expected) {
387 if (num_mismatches == 0) {
389 first_expected = expected;
398 EXPECT_EQ(num_mismatches, 0u) << num_mismatches <<
" of "
400 "first is sample " << first_idx <<
", which should be " << first_expected
401 <<
" but is " << first_found <<
".";
412 std::string src_filename = base_filename +
"_src.raw";
413 std::string signedness = is_signed ?
"true" :
"false";
414 char bit_depth_str[16];
415 snprintf(bit_depth_str,
sizeof(bit_depth_str),
"%d", (
int)bit_depth);
419 "-reversible true -dims \"{256,256}\" -num_comps 1"
420 " -downsamp \"{1,1}\" -bit_depth "
421 + std::string(bit_depth_str)
422 +
" -signed " + signedness);
433TEST(TestExecutables, OpenJPHCompressNoArguments) {
438 catch (
const std::runtime_error& error) {
439 FAIL() << error.what();
445TEST(TestExecutables, OpenJPHExpandNoArguments) {
450 catch (
const std::runtime_error& error) {
451 FAIL() << error.what();
463TEST(TestExecutables, SimpleDecIrv9764x64) {
464 double mse[3] = { 39.2812, 36.3819, 47.642};
465 int pae[3] = { 74, 77, 73};
467 run_mse_pae(
"simple_dec_irv97_64x64",
"ppm",
"Malamute.ppm",
475TEST(TestExecutables, SimpleDecIrv9732x32) {
476 double mse[3] = { 18.6979, 17.1208, 22.7539};
477 int pae[3] = { 51, 48, 46};
479 run_mse_pae(
"simple_dec_irv97_32x32",
"ppm",
"Malamute.ppm",
487TEST(TestExecutables, SimpleDecIrv9716x16) {
488 double mse[3] = { 20.1706, 18.5427, 24.6146};
489 int pae[3] = { 53, 51, 47};
491 run_mse_pae(
"simple_dec_irv97_16x16",
"ppm",
"Malamute.ppm",
499TEST(TestExecutables, SimpleDecIrv974x4) {
500 double mse[3] = { 40.8623, 37.9308, 49.7276};
501 int pae[3] = { 75, 77, 80};
503 run_mse_pae(
"simple_dec_irv97_4x4",
"ppm",
"Malamute.ppm",
511TEST(TestExecutables, SimpleDecIrv971024x4) {
512 double mse[3] = { 19.8275, 18.2511, 24.2832};
513 int pae[3] = { 53, 52, 50};
515 run_mse_pae(
"simple_dec_irv97_1024x4",
"ppm",
"Malamute.ppm",
523TEST(TestExecutables, SimpleDecIrv974x1024) {
524 double mse[3] = { 19.9635, 18.4063, 24.1719};
525 int pae[3] = { 51, 48, 51};
527 run_mse_pae(
"simple_dec_irv97_4x1024",
"ppm",
"Malamute.ppm",
535TEST(TestExecutables, SimpleDecIrv97512x8) {
536 double mse[3] = { 18.7929, 17.2026, 22.9922};
537 int pae[3] = { 53, 52, 50};
539 run_mse_pae(
"simple_dec_irv97_512x8",
"ppm",
"Malamute.ppm",
547TEST(TestExecutables, SimpleDecIrv978x512) {
548 double mse[3] = { 19.3661, 17.8067, 23.4574};
549 int pae[3] = { 51, 48, 52};
551 run_mse_pae(
"simple_dec_irv97_8x512",
"ppm",
"Malamute.ppm",
559TEST(TestExecutables, SimpleDecIrv97256x16) {
560 double mse[3] = { 18.6355, 17.0963, 22.6076};
561 int pae[3] = { 54, 51, 48};
563 run_mse_pae(
"simple_dec_irv97_256x16",
"ppm",
"Malamute.ppm",
571TEST(TestExecutables, SimpleDecIrv9716x256) {
572 double mse[3] = { 18.5933, 17.0208, 22.5709};
573 int pae[3] = { 51, 48, 47};
575 run_mse_pae(
"simple_dec_irv97_16x256",
"ppm",
"Malamute.ppm",
583TEST(TestExecutables, SimpleDecIrv97128x32) {
584 double mse[3] = { 18.4443, 16.9133, 22.4193};
585 int pae[3] = { 52, 50, 46};
587 run_mse_pae(
"simple_dec_irv97_128x32",
"ppm",
"Malamute.ppm",
595TEST(TestExecutables, SimpleDecIrv9732x128) {
596 double mse[3] = { 18.4874, 16.9379, 22.4855};
597 int pae[3] = { 51, 48, 45};
599 run_mse_pae(
"simple_dec_irv97_32x128",
"ppm",
"Malamute.ppm",
607TEST(TestExecutables, SimpleDecRev5364x64) {
608 double mse[3] = { 0, 0, 0};
609 int pae[3] = { 0, 0, 0};
611 run_mse_pae(
"simple_dec_rev53_64x64",
"ppm",
"Malamute.ppm",
620TEST(TestExecutables, SimpleDecRev5332x32) {
621 double mse[3] = { 0, 0, 0};
622 int pae[3] = { 0, 0, 0};
624 run_mse_pae(
"simple_dec_rev53_32x32",
"ppm",
"Malamute.ppm",
633TEST(TestExecutables, SimpleDecRev534x4) {
634 double mse[3] = { 0, 0, 0};
635 int pae[3] = { 0, 0, 0};
637 run_mse_pae(
"simple_dec_rev53_4x4",
"ppm",
"Malamute.ppm",
646TEST(TestExecutables, SimpleDecRev531024x4) {
647 double mse[3] = { 0, 0, 0};
648 int pae[3] = { 0, 0, 0};
650 run_mse_pae(
"simple_dec_rev53_1024x4",
"ppm",
"Malamute.ppm",
659TEST(TestExecutables, SimpleDecRev534x1024) {
660 double mse[3] = { 0, 0, 0};
661 int pae[3] = { 0, 0, 0};
663 run_mse_pae(
"simple_dec_rev53_4x1024",
"ppm",
"Malamute.ppm",
674TEST(TestExecutables, SimpleDecIrv9764x64Yuv) {
675 double mse[3] = { 20.2778, 6.27912, 4.15937};
676 int pae[3] = { 52, 22, 31};
678 run_mse_pae(
"simple_dec_irv97_64x64_yuv",
"yuv",
"foreman_420.yuv",
679 ":352x288x8x420", 3, mse, pae);
689TEST(TestExecutables, SimpleDecRev5364x64Yuv) {
690 double mse[3] = { 0, 0, 0};
691 int pae[3] = { 0, 0, 0};
693 run_mse_pae(
"simple_dec_rev53_64x64_yuv",
"yuv",
"foreman_420.yuv",
694 ":352x288x8x420", 3, mse, pae);
704TEST(TestExecutables, SimpleDecIrv9764x64TilesYuv) {
705 double mse[3] = { 34.4972, 10.1112, 7.96331};
706 int pae[3] = { 67, 30, 39};
708 run_mse_pae(
"simple_dec_irv97_64x64_tiles_yuv",
"yuv",
"foreman_420.yuv",
709 ":352x288x8x420", 3, mse, pae);
719TEST(TestExecutables, SimpleDecRev5364x64TilesYuv) {
720 double mse[3] = { 0, 0, 0};
721 int pae[3] = { 0, 0, 0};
723 run_mse_pae(
"simple_dec_rev53_64x64_tiles_yuv",
"yuv",
"foreman_420.yuv",
724 ":352x288x8x420", 3, mse, pae);
733TEST(TestExecutables, SimpleDecIrv9764x64TilesLRCP) {
734 double mse[3] = { 71.8149, 68.7115, 89.4001};
735 int pae[3] = { 78, 78, 83};
737 run_mse_pae(
"simple_dec_irv97_64x64_tiles_LRCP",
"ppm",
"Malamute.ppm",
747TEST(TestExecutables, SimpleDecIrv9764x64TilesRLCP) {
748 double mse[3] = { 71.8149, 68.7115, 89.4001};
749 int pae[3] = { 78, 78, 83};
751 run_mse_pae(
"simple_dec_irv97_64x64_tiles_RLCP",
"ppm",
"Malamute.ppm",
761TEST(TestExecutables, SimpleDecIrv9764x64TilesRPCL) {
762 double mse[3] = { 71.8149, 68.7115, 89.4001};
763 int pae[3] = { 78, 78, 83};
765 run_mse_pae(
"simple_dec_irv97_64x64_tiles_RPCL",
"ppm",
"Malamute.ppm",
775TEST(TestExecutables, SimpleDecIrv9764x64TilesPCRL) {
776 double mse[3] = { 71.8149, 68.7115, 89.4001};
777 int pae[3] = { 78, 78, 83};
779 run_mse_pae(
"simple_dec_irv97_64x64_tiles_PCRL",
"ppm",
"Malamute.ppm",
789TEST(TestExecutables, SimpleDecIrv9764x64TilesCPRL) {
790 double mse[3] = { 71.8149, 68.7115, 89.4001};
791 int pae[3] = { 78, 78, 83};
793 run_mse_pae(
"simple_dec_irv97_64x64_tiles_CPRL",
"ppm",
"Malamute.ppm",
803TEST(TestExecutables, SimpleDecIrv9764x64TilesLRCP33) {
804 double mse[3] = { 56.2139, 51.4121, 69.0107};
805 int pae[3] = { 80, 81, 98};
807 run_mse_pae(
"simple_dec_irv97_64x64_tiles_LRCP33",
"ppm",
"Malamute.ppm",
817TEST(TestExecutables, SimpleDecIrv9764x64TilesRLCP33) {
818 double mse[3] = { 56.2139, 51.4121, 69.0107};
819 int pae[3] = { 80, 81, 98};
821 run_mse_pae(
"simple_dec_irv97_64x64_tiles_RLCP33",
"ppm",
"Malamute.ppm",
831TEST(TestExecutables, SimpleDecIrv9764x64TilesRPCL33) {
832 double mse[3] = { 56.2139, 51.4121, 69.0107};
833 int pae[3] = { 80, 81, 98};
835 run_mse_pae(
"simple_dec_irv97_64x64_tiles_RPCL33",
"ppm",
"Malamute.ppm",
845TEST(TestExecutables, SimpleDecIrv9764x64TilesPCRL33) {
846 double mse[3] = { 56.2139, 51.4121, 69.0107};
847 int pae[3] = { 80, 81, 98};
849 run_mse_pae(
"simple_dec_irv97_64x64_tiles_PCRL33",
"ppm",
"Malamute.ppm",
859TEST(TestExecutables, SimpleDecIrv9764x64TilesCPRL33) {
860 double mse[3] = { 56.2139, 51.4121, 69.0107};
861 int pae[3] = { 80, 81, 98};
863 run_mse_pae(
"simple_dec_irv97_64x64_tiles_CPRL33",
"ppm",
"Malamute.ppm",
873TEST(TestExecutables, SimpleDecIrv9764x64TilesLRCP33x33) {
874 double mse[3] = { 210.283, 210.214, 257.276};
875 int pae[3] = { 165, 161, 166};
876 run_ojph_expand(
"simple_dec_irv97_64x64_tiles_LRCP33x33",
"jph",
"ppm");
877 run_mse_pae(
"simple_dec_irv97_64x64_tiles_LRCP33x33",
"ppm",
"Malamute.ppm",
887TEST(TestExecutables, SimpleDecIrv9764x64TilesRLCP33x33) {
888 double mse[3] = { 210.283, 210.214, 257.276};
889 int pae[3] = { 165, 161, 166};
890 run_ojph_expand(
"simple_dec_irv97_64x64_tiles_RLCP33x33",
"jph",
"ppm");
891 run_mse_pae(
"simple_dec_irv97_64x64_tiles_RLCP33x33",
"ppm",
"Malamute.ppm",
901TEST(TestExecutables, SimpleDecIrv9764x64TilesRPCL33x33) {
902 double mse[3] = { 210.283, 210.214, 257.276};
903 int pae[3] = { 165, 161, 166};
904 run_ojph_expand(
"simple_dec_irv97_64x64_tiles_RPCL33x33",
"jph",
"ppm");
905 run_mse_pae(
"simple_dec_irv97_64x64_tiles_RPCL33x33",
"ppm",
"Malamute.ppm",
915TEST(TestExecutables, SimpleDecIrv9764x64TilesPCRL33x33) {
916 double mse[3] = { 210.283, 210.214, 257.276};
917 int pae[3] = { 165, 161, 166};
918 run_ojph_expand(
"simple_dec_irv97_64x64_tiles_PCRL33x33",
"jph",
"ppm");
919 run_mse_pae(
"simple_dec_irv97_64x64_tiles_PCRL33x33",
"ppm",
"Malamute.ppm",
929TEST(TestExecutables, SimpleDecIrv9764x64TilesCPRL33x33) {
930 double mse[3] = { 210.283, 210.214, 257.276};
931 int pae[3] = { 165, 161, 166};
932 run_ojph_expand(
"simple_dec_irv97_64x64_tiles_CPRL33x33",
"jph",
"ppm");
933 run_mse_pae(
"simple_dec_irv97_64x64_tiles_CPRL33x33",
"ppm",
"Malamute.ppm",
942TEST(TestExecutables, SimpleDecRev5364x64GrayTiles) {
943 double mse[1] = { 0};
946 run_mse_pae(
"simple_dec_rev53_64x64_gray_tiles",
"pgm",
"monarch.pgm",
955TEST(TestExecutables, SimpleDecIrv9764x64GrayTiles) {
956 double mse[1] = { 18.9601};
959 run_mse_pae(
"simple_dec_irv97_64x64_gray_tiles",
"pgm",
"monarch.pgm",
967TEST(TestExecutables, SimpleDecIrv9764x6416bit) {
968 double mse[3] = { 60507.2, 36672.5, 64809.8};
969 int pae[3] = { 2547, 1974, 1922};
971 run_mse_pae(
"simple_dec_irv97_64x64_16bit",
"ppm",
"mm.ppm",
979TEST(TestExecutables, SimpleDecIrv9764x6416bitGray) {
980 double mse[1] = { 19382.9};
981 int pae[1] = { 1618};
983 run_mse_pae(
"simple_dec_irv97_64x64_16bit_gray",
"pgm",
"mm.pgm",
991TEST(TestExecutables, SimpleDecRev5364x6416bit) {
992 double mse[3] = { 0, 0, 0};
993 int pae[3] = { 0, 0, 0};
995 run_mse_pae(
"simple_dec_rev53_64x64_16bit",
"ppm",
"mm.ppm",
1004TEST(TestExecutables, SimpleDecRev5364x6416bitGray) {
1005 double mse[1] = { 0};
1008 run_mse_pae(
"simple_dec_rev53_64x64_16bit_gray",
"pgm",
"mm.pgm",
1020TEST(TestExecutables, SimpleDecIrv53BhvhbLowLatency) {
1021 double mse[3] = { 5.52392, 4.01405, 6.8166};
1022 int pae[3] = { 16, 17, 23};
1024 run_mse_pae(
"simple_dec_irv53_bhvhb_low_latency",
"ppm",
"Malamute.ppm",
1033TEST(TestExecutables, SimpleEncIrv9764x64) {
1034 double mse[3] = { 46.2004, 43.622, 56.7452};
1035 int pae[3] = { 48, 46, 52};
1037 "simple_enc_irv97_64x64",
"",
"j2c",
1041 "Malamute.ppm",
"", 3, mse, pae);
1049TEST(TestExecutables, SimpleEncIrv9732x32) {
1050 double mse[3] = { 1.78779, 1.26001, 2.38395};
1051 int pae[3] = { 7, 6, 9};
1053 "simple_enc_irv97_32x32",
"",
"j2c",
1054 "-qstep 0.01 -block_size \"{32,32}\"");
1057 "Malamute.ppm",
"", 3, mse, pae);
1065TEST(TestExecutables, SimpleEncIrv9716x16) {
1066 double mse[3] = { 1.78779, 1.26001, 2.38395};
1067 int pae[3] = { 7, 6, 9};
1069 "simple_enc_irv97_16x16",
"",
"j2c",
1070 "-qstep 0.01 -block_size \"{16,16}\"");
1073 "Malamute.ppm",
"", 3, mse, pae);
1081TEST(TestExecutables, SimpleEncIrv974x4) {
1082 double mse[3] = { 1.78779, 1.26001, 2.38395};
1083 int pae[3] = { 7, 6, 9};
1085 "simple_enc_irv97_4x4",
"",
"j2c",
1086 "-qstep 0.01 -block_size \"{4,4}\"");
1089 "Malamute.ppm",
"", 3, mse, pae);
1097TEST(TestExecutables, SimpleEncIrv971024x4) {
1098 double mse[3] = { 1.78779, 1.26001, 2.38395};
1099 int pae[3] = { 7, 6, 9};
1101 "simple_enc_irv97_1024x4",
"",
"j2c",
1102 "-qstep 0.01 -block_size \"{4,1024}\"");
1105 "Malamute.ppm",
"", 3, mse, pae);
1113TEST(TestExecutables, SimpleEncIrv974x1024) {
1114 double mse[3] = { 1.78779, 1.26001, 2.38395};
1115 int pae[3] = { 7, 6, 9};
1117 "simple_enc_irv97_4x1024",
"",
"j2c",
1118 "-qstep 0.01 -block_size \"{1024,4}\"");
1121 "Malamute.ppm",
"", 3, mse, pae);
1129TEST(TestExecutables, SimpleEncIrv97512x8) {
1130 double mse[3] = { 1.78779, 1.26001, 2.38395};
1131 int pae[3] = { 7, 6, 9};
1133 "simple_enc_irv97_512x8",
"",
"j2c",
1134 "-qstep 0.01 -block_size \"{8,512}\"");
1137 "Malamute.ppm",
"", 3, mse, pae);
1145TEST(TestExecutables, SimpleEncIrv978x512) {
1146 double mse[3] = { 1.78779, 1.26001, 2.38395};
1147 int pae[3] = { 7, 6, 9};
1149 "simple_enc_irv97_8x512",
"",
"j2c",
1150 "-qstep 0.01 -block_size \"{512,8}\"");
1153 "Malamute.ppm",
"", 3, mse, pae);
1161TEST(TestExecutables, SimpleEncIrv97256x16) {
1162 double mse[3] = { 1.78779, 1.26001, 2.38395};
1163 int pae[3] = { 7, 6, 9};
1165 "simple_enc_irv97_256x16",
"",
"j2c",
1166 "-qstep 0.01 -block_size \"{16,256}\"");
1169 "Malamute.ppm",
"", 3, mse, pae);
1177TEST(TestExecutables, SimpleEncIrv9716x256) {
1178 double mse[3] = { 1.78779, 1.26001, 2.38395};
1179 int pae[3] = { 7, 6, 9};
1181 "simple_enc_irv97_16x256",
"",
"j2c",
1182 "-qstep 0.01 -block_size \"{256,16}\"");
1185 "Malamute.ppm",
"", 3, mse, pae);
1193TEST(TestExecutables, SimpleEncIrv97128x32) {
1194 double mse[3] = { 1.78779, 1.26001, 2.38395};
1195 int pae[3] = { 7, 6, 9};
1197 "simple_enc_irv97_128x32",
"",
"j2c",
1198 "-qstep 0.01 -block_size \"{32,128}\"");
1201 "Malamute.ppm",
"", 3, mse, pae);
1209TEST(TestExecutables, SimpleEncIrv9732x128) {
1210 double mse[3] = { 1.78779, 1.26001, 2.38395};
1211 int pae[3] = { 7, 6, 9};
1213 "simple_enc_irv97_32x128",
"",
"j2c",
1214 "-qstep 0.01 -block_size \"{128,32}\"");
1217 "Malamute.ppm",
"", 3, mse, pae);
1226TEST(TestExecutables, SimpleEncIrv9764x64Tiles33x33D5) {
1227 double mse[3] = { 1.88906, 1.30757, 2.5347};
1228 int pae[3] = { 9, 6, 10};
1230 "simple_enc_irv97_64x64_tiles_33x33_d5",
"",
"j2c",
1231 "-qstep 0.01 -tile_size \"{33,33}\" -num_decomps 5");
1233 run_mse_pae(
"simple_enc_irv97_64x64_tiles_33x33_d5",
"ppm",
1234 "Malamute.ppm",
"", 3, mse, pae);
1243TEST(TestExecutables, SimpleEncIrv9764x64Tiles33x33D6) {
1244 double mse[3] = { 1.88751, 1.30673, 2.53378};
1245 int pae[3] = { 8, 6, 10};
1247 "simple_enc_irv97_64x64_tiles_33x33_d6",
"",
"j2c",
1248 "-qstep 0.01 -tile_size \"{33,33}\" -num_decomps 6");
1250 run_mse_pae(
"simple_enc_irv97_64x64_tiles_33x33_d6",
"ppm",
1251 "Malamute.ppm",
"", 3, mse, pae);
1259TEST(TestExecutables, SimpleEncIrv9764x6416bit) {
1260 double mse[3] = { 51727.3, 32596.4, 45897.8};
1261 int pae[3] = { 1512, 1481, 1778};
1263 "simple_enc_irv97_64x64_16bit",
"",
"j2c",
1266 run_mse_pae(
"simple_enc_irv97_64x64_16bit",
"ppm",
1267 "mm.ppm",
"", 3, mse, pae);
1275TEST(TestExecutables, SimpleEncIrv9764x6416bitGray) {
1276 double mse[1] = { 25150.6};
1277 int pae[1] = { 1081};
1279 "simple_enc_irv97_64x64_16bit_gray",
"",
"j2c",
1282 run_mse_pae(
"simple_enc_irv97_64x64_16bit_gray",
"pgm",
1283 "mm.pgm",
"", 1, mse, pae);
1291TEST(TestExecutables, SimpleEncRev5364x6416bit) {
1292 double mse[3] = { 0, 0, 0};
1293 int pae[3] = { 0, 0, 0};
1295 "simple_enc_rev53_64x64_16bit",
"",
"j2c",
1296 "-reversible true");
1298 run_mse_pae(
"simple_enc_rev53_64x64_16bit",
"ppm",
1299 "mm.ppm",
"", 3, mse, pae);
1307TEST(TestExecutables, SimpleEncRev5364x6416bitGray) {
1308 double mse[1] = { 0};
1311 "simple_enc_rev53_64x64_16bit_gray",
"",
"j2c",
1312 "-reversible true");
1314 run_mse_pae(
"simple_enc_rev53_64x64_16bit_gray",
"pgm",
1315 "mm.pgm",
"", 1, mse, pae);
1323TEST(TestExecutables, SimpleEncRev5364x64) {
1324 double mse[3] = { 0, 0, 0};
1325 int pae[3] = { 0, 0, 0};
1327 "simple_enc_rev53_64x64",
"",
"j2c",
1328 "-reversible true");
1331 "Malamute.ppm",
"", 3, mse, pae);
1339TEST(TestExecutables, SimpleEncRev5332x32) {
1340 double mse[3] = { 0, 0, 0};
1341 int pae[3] = { 0, 0, 0};
1343 "simple_enc_rev53_32x32",
"",
"j2c",
1344 "-reversible true -block_size \"{32,32}\"");
1347 "Malamute.ppm",
"", 3, mse, pae);
1355TEST(TestExecutables, SimpleEncRev534x4) {
1356 double mse[3] = { 0, 0, 0};
1357 int pae[3] = { 0, 0, 0};
1359 "simple_enc_rev53_4x4",
"",
"j2c",
1360 "-reversible true -block_size \"{4,4}\"");
1363 "Malamute.ppm",
"", 3, mse, pae);
1371TEST(TestExecutables, SimpleEncRev531024x4) {
1372 double mse[3] = { 0, 0, 0};
1373 int pae[3] = { 0, 0, 0};
1375 "simple_enc_rev53_1024x4",
"",
"j2c",
1376 "-reversible true -block_size \"{4,1024}\"");
1379 "Malamute.ppm",
"", 3, mse, pae);
1387TEST(TestExecutables, SimpleEncRev534x1024) {
1388 double mse[3] = { 0, 0, 0};
1389 int pae[3] = { 0, 0, 0};
1391 "simple_enc_rev53_4x1024",
"",
"j2c",
1392 "-reversible true -block_size \"{1024,4}\"");
1395 "Malamute.ppm",
"", 3, mse, pae);
1404TEST(TestExecutables, SimpleEncRev5364x64Tiles33x33D5) {
1405 double mse[3] = { 0, 0, 0};
1406 int pae[3] = { 0, 0, 0};
1408 "simple_enc_rev53_64x64_tiles_33x33_d5",
"",
"j2c",
1409 "-reversible true -tile_size \"{32,32}\" -num_decomps 5");
1411 run_mse_pae(
"simple_enc_rev53_64x64_tiles_33x33_d5",
"ppm",
1412 "Malamute.ppm",
"", 3, mse, pae);
1421TEST(TestExecutables, SimpleEncRev5364x64Tiles33x33D6) {
1422 double mse[3] = { 0, 0, 0};
1423 int pae[3] = { 0, 0, 0};
1425 "simple_enc_rev53_64x64_tiles_33x33_d6",
"",
"j2c",
1426 "-reversible true -tile_size \"{32,32}\" -num_decomps 6");
1428 run_mse_pae(
"simple_enc_rev53_64x64_tiles_33x33_d6",
"ppm",
1429 "Malamute.ppm",
"", 3, mse, pae);
1438TEST(TestExecutables, SimpleEncIrv9764x64Yuv) {
1439 double mse[3] = { 30.3548, 7.69602, 5.22246};
1440 int pae[3] = { 49, 27, 26};
1442 "simple_enc_irv97_64x64_yuv",
"",
"j2c",
1443 "-qstep 0.1 -dims \"{352,288}\" -num_comps 3 -downsamp"
1444 " \"{1,1}\",\"{2,2}\",\"{2,2}\" -bit_depth 8,8,8"
1445 " -signed false,false,false");
1448 "foreman_420.yuv",
":352x288x8x420", 3, mse, pae);
1458TEST(TestExecutables, SimpleEncRev5364x64Yuv) {
1459 double mse[3] = { 0, 0, 0};
1460 int pae[3] = { 0, 0, 0};
1462 "simple_enc_rev53_64x64_yuv",
"",
"j2c",
1463 "-reversible true -qstep 0.1 -dims \"{352,288}\""
1464 " -num_comps 3 -downsamp \"{1,1}\",\"{2,2}\",\"{2,2}\""
1465 " -bit_depth 8,8,8 -signed false,false,false");
1468 "foreman_420.yuv",
":352x288x8x420", 3, mse, pae);
1476TEST(TestExecutables, SimpleEncIrv97TallNarrow) {
1477 double mse[3] = { 112.097, 79.2214, 71.1367};
1478 int pae[3] = { 56, 41, 32};
1480 "simple_enc_irv97_tall_narrow",
"",
"j2c",
1483 run_mse_pae(
"simple_enc_irv97_tall_narrow",
"ppm",
1484 "tall_narrow.ppm",
"", 3, mse, pae);
1492TEST(TestExecutables, SimpleEncIrv97TallNarrow1) {
1493 double mse[3] = { 100.906, 76.113, 72.8347};
1494 int pae[3] = { 39, 35, 34};
1496 "simple_enc_irv97_tall_narrow1",
"",
"j2c",
1497 "-image_offset \"{1,0}\" -qstep 0.1");
1499 run_mse_pae(
"simple_enc_irv97_tall_narrow1",
"ppm",
1500 "tall_narrow.ppm",
"", 3, mse, pae);
1508TEST(TestExecutables, SimpleEncRev53TallNarrow) {
1509 double mse[3] = { 0, 0, 0};
1510 int pae[3] = { 0, 0, 0};
1512 "simple_enc_rev53_tall_narrow",
"",
"j2c",
1513 "-reversible true");
1515 run_mse_pae(
"simple_enc_rev53_tall_narrow",
"ppm",
1516 "tall_narrow.ppm",
"", 3, mse, pae);
1524TEST(TestExecutables, SimpleEncRev53TallNarrow1) {
1525 double mse[3] = { 0, 0, 0};
1526 int pae[3] = { 0, 0, 0};
1528 "simple_enc_rev53_tall_narrow1",
"",
"j2c",
1529 "-image_offset \"{1,0}\" -reversible true");
1531 run_mse_pae(
"simple_enc_rev53_tall_narrow1",
"ppm",
1532 "tall_narrow.ppm",
"", 3, mse, pae);
1540TEST(TestExecutables, DpxEnc1280x72010bitLeNuke11) {
1541 double mse[3] = { 0, 0, 0};
1542 int pae[3] = { 0, 0, 0};
1544 "dpx_enc_1280x720_10bit_le_nuke11",
"",
"j2c",
1545 "-reversible true");
1547 run_mse_pae(
"dpx_enc_1280x720_10bit_le_nuke11",
"ppm",
1548 "dpx_1280x720_10bit.ppm",
"", 3, mse, pae);
1556TEST(TestExecutables, DpxEnc1280x72010bitBeNuke11) {
1557 double mse[3] = { 0, 0, 0};
1558 int pae[3] = { 0, 0, 0};
1560 "dpx_enc_1280x720_10bit_be_nuke11",
"",
"j2c",
1561 "-reversible true");
1563 run_mse_pae(
"dpx_enc_1280x720_10bit_be_nuke11",
"ppm",
1564 "dpx_1280x720_10bit.ppm",
"", 3, mse, pae);
1572TEST(TestExecutables, DpxEnc1280x72016bitLeNuke11) {
1573 double mse[3] = { 0, 0, 0};
1574 int pae[3] = { 0, 0, 0};
1576 "dpx_enc_1280x720_16bit_le_nuke11",
"",
"j2c",
1577 "-reversible true");
1579 run_mse_pae(
"dpx_enc_1280x720_16bit_le_nuke11",
"ppm",
1580 "dpx_1280x720_16bit.ppm",
"", 3, mse, pae);
1588TEST(TestExecutables, DpxEnc1280x72016bitBeNuke11) {
1589 double mse[3] = { 0, 0, 0};
1590 int pae[3] = { 0, 0, 0};
1592 "dpx_enc_1280x720_16bit_be_nuke11",
"",
"j2c",
1593 "-reversible true");
1595 run_mse_pae(
"dpx_enc_1280x720_16bit_be_nuke11",
"ppm",
1596 "dpx_1280x720_16bit.ppm",
"", 3, mse, pae);
1604TEST(TestExecutables, DpxEnc1280x72010bitResolve18) {
1605 double mse[3] = { 0, 0, 0};
1606 int pae[3] = { 0, 0, 0};
1608 "dpx_enc_1280x720_10bit_resolve18",
"",
"j2c",
1609 "-reversible true");
1611 run_mse_pae(
"dpx_enc_1280x720_10bit_resolve18",
"ppm",
1612 "dpx_1280x720_10bit.ppm",
"", 3, mse, pae);
1620TEST(TestExecutables, DpxEnc1280x72016bitResolve18) {
1621 double mse[3] = { 0, 0, 0};
1622 int pae[3] = { 0, 0, 0};
1624 "dpx_enc_1280x720_16bit_resolve18",
"",
"j2c",
1625 "-reversible true");
1627 run_mse_pae(
"dpx_enc_1280x720_16bit_resolve18",
"ppm",
1628 "dpx_1280x720_16bit.ppm",
"", 3, mse, pae);
1636TEST(TestExecutables, SimpleEncIrv97Qfactor50) {
1637 double mse[3] = { 34.1747, 31.8416, 41.5334 };
1638 int pae[3] = { 54, 55, 54 };
1640 "simple_enc_irv97_qfactor50",
"",
"j2c",
1644 "Malamute.ppm",
"", 3, mse, pae);
1654TEST(TestExecutables, SimpleEncIrv97Qfactor50Yuv) {
1655 double mse[3] = { 23.5159, 4.0584, 1.9829 };
1656 int pae[3] = { 60, 17, 23 };
1658 "simple_enc_irv97_qfactor50_yuv",
"",
"j2c",
1659 "-qfactor 50 -dims \"{352,288}\" -num_comps 3 -downsamp"
1660 " \"{1,1}\",\"{2,2}\",\"{2,2}\" -bit_depth 8,8,8"
1661 " -signed false,false,false");
1663 run_mse_pae(
"simple_enc_irv97_qfactor50_yuv",
"yuv",
1664 "foreman_420.yuv",
":352x288x8x420", 3, mse, pae);
1672TEST(TestExecutables, SimpleEncIrv97Qfactor50Gray) {
1673 double mse[1] = { 23.245 };
1674 int pae[1] = { 72 };
1676 "simple_enc_irv97_qfactor50_gray",
"",
"j2c",
1679 run_mse_pae(
"simple_enc_irv97_qfactor50_gray",
"pgm",
1680 "monarch.pgm",
"", 1, mse, pae);
1698TEST(TestExecutables, SimpleEncRev53Raw8Signed) {
1702TEST(TestExecutables, SimpleEncRev53Raw8Unsigned) {
1706TEST(TestExecutables, SimpleEncRev53Raw16Signed) {
1710TEST(TestExecutables, SimpleEncRev53Raw16Unsigned) {
1714TEST(TestExecutables, SimpleEncRev53Raw24Signed) {
1718TEST(TestExecutables, SimpleEncRev53Raw24Unsigned) {
1722TEST(TestExecutables, SimpleEncRev53Raw32Signed) {
1726TEST(TestExecutables, SimpleEncRev53Raw32Unsigned) {
1734 ::testing::InitGoogleTest(&argc, argv);
1735 return RUN_ALL_TESTS();
int main(int argc, char *argv[])
static int ojph_pclose(FILE *stream)
void compare_raw_test_file(const std::string &filename, ojph::ui32 bit_depth, bool is_signed)
#define COMPRESS_EXECUTABLE
void run_ojph_compress_expand(const std::string &base_filename, const std::string &out_ext, const std::string &decode_ext)
#define COMPARE_FILES_PATH
#define RAW_TEST_NUM_SAMPLES
void run_raw_round_trip_test(const std::string &base_filename, ojph::ui32 bit_depth, bool is_signed)
void write_raw_test_file(const std::string &filename, ojph::ui32 bit_depth, bool is_signed)
void run_ojph_expand(const std::string &base_filename, const std::string &src_ext, const std::string &out_ext)
static ojph::si64 raw_test_sample(ojph::ui32 idx, ojph::ui32 bit_depth, bool is_signed)
static int execute(const std::string &cmd, std::string &result)
#define EXPAND_EXECUTABLE
void run_ojph_compress_raw(const std::string &src_filename, const std::string &base_filename, const std::string &out_ext, const std::string &extra_options)
static FILE * ojph_popen(const char *command, const char *modes)
void run_mse_pae(const std::string &base_filename, const std::string &out_ext, const std::string &ref_filename, const std::string &yuv_specs, int num_components, double *mse, int *pae)
void compare_files(const std::string &base_filename, const std::string &extended_base_fname, const std::string &ext)
TEST(TestExecutables, OpenJPHCompressNoArguments)
void run_ojph_compress(const std::string &ref_filename, const std::string &base_filename, const std::string &extended_base_fname, const std::string &out_ext, const std::string &extra_options)