|
36 | 36 | #include <ImfOutputFile.h> |
37 | 37 | #include <ImfTiledOutputFile.h> |
38 | 38 | #include <half.h> |
| 39 | + |
| 40 | +#include "internal_ht_common.cpp" |
| 41 | + |
39 | 42 | #ifdef __linux |
40 | 43 | # include <sys/types.h> |
41 | 44 | # include <sys/stat.h> |
@@ -1693,6 +1696,60 @@ testDWABCompression (const std::string& tempdir) |
1693 | 1696 | testComp (tempdir, EXR_COMPRESSION_DWAB); |
1694 | 1697 | } |
1695 | 1698 |
|
| 1699 | +struct ht_channel_map_tests { |
| 1700 | + exr_coding_channel_info_t channels[6]; |
| 1701 | + int channel_count; |
| 1702 | + bool pass; |
| 1703 | + int rgb_index[3]; |
| 1704 | +}; |
| 1705 | + |
| 1706 | +void |
| 1707 | +testHTChannelMap (const std::string& tempdir) |
| 1708 | +{ |
| 1709 | + std::vector<CodestreamChannelInfo> cs_to_file_ch; |
| 1710 | + ht_channel_map_tests tests[] = { |
| 1711 | + {{{"R"}, {"G"}, {"B"}}, 3, true, {0, 1, 2}}, |
| 1712 | + {{{"r"}, {"G"}, {"b"}}, 3, true, {0, 1, 2}}, |
| 1713 | + {{{"B"}, {"G"}, {"R"}}, 3, true, {2, 1, 0}}, |
| 1714 | + {{{"red"}, {"green"}, {"blue"}}, 3, true, {0, 1, 2}}, |
| 1715 | + {{{"Red"}, {"Green"}, {"Blue"}, {"alpha"}}, 4, true, {0, 1, 2}}, |
| 1716 | + {{{"hello.R"}, {"hello.G"}, {"hello.B"}}, 3, true, {0, 1, 2}}, |
| 1717 | + {{{"hello.R"}, {"bye.R"}, {"hello.G"}, {"bye.R"}, {"hello.B"}, {"bye.B"}}, 6, true, {0, 2, 4}}, |
| 1718 | + {{{"red"}, {"green"}, {"blue"}}, 3, true, {0, 1, 2}}, |
| 1719 | + /* the following are expected to fail */ |
| 1720 | + {{{"redqueen"}, {"greens"}, {"blueberry"}}, 3, false, {0, 1, 2}}, |
| 1721 | + {{{"hello.R"}, {"bye.G"}, {"hello.B"}}, 3, false, {0, 2, 4}}, |
| 1722 | + }; |
| 1723 | + int test_count = sizeof(tests) / sizeof(ht_channel_map_tests); |
| 1724 | + |
| 1725 | + for (size_t i = 0; i < test_count; i++) |
| 1726 | + { |
| 1727 | + EXRCORE_TEST ( |
| 1728 | + make_channel_map ( |
| 1729 | + tests[i].channel_count, tests[i].channels, cs_to_file_ch) == |
| 1730 | + tests[i].pass); |
| 1731 | + if (tests[i].pass) |
| 1732 | + { |
| 1733 | + for (size_t j = 0; j < 3; j++) |
| 1734 | + { |
| 1735 | + EXRCORE_TEST ( |
| 1736 | + tests[i].rgb_index[j] == cs_to_file_ch[j].file_index); |
| 1737 | + } |
| 1738 | + } |
| 1739 | + } |
| 1740 | + |
| 1741 | + exr_coding_channel_info_t channels_1[] = { |
| 1742 | + { "R" }, { "G" }, { "B" } |
| 1743 | + }; |
| 1744 | + |
| 1745 | + exr_coding_channel_info_t channels_2[] = { |
| 1746 | + { "R" }, { "G" }, { "1.B" } |
| 1747 | + }; |
| 1748 | + |
| 1749 | + EXRCORE_TEST (make_channel_map (3, channels_1, cs_to_file_ch)); |
| 1750 | + EXRCORE_TEST (! make_channel_map (3, channels_2, cs_to_file_ch)); |
| 1751 | +} |
| 1752 | + |
1696 | 1753 | void |
1697 | 1754 | testDeepNoCompression (const std::string& tempdir) |
1698 | 1755 | {} |
|
0 commit comments