Skip to content

Commit e8a93d8

Browse files
committed
Update test
1 parent 8f2e9ef commit e8a93d8

File tree

1 file changed

+79
-0
lines changed

1 file changed

+79
-0
lines changed

src/libOpenImageIO/imagebufalgo_test.cpp

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,51 @@ static bool verbose = false;
5555
static bool wedge = false;
5656
static int threadcounts[] = { 1, 2, 4, 8, 12, 16, 20, 24, 28, 32, 64, 128, 1024, 1<<30 };
5757

58+
namespace {
59+
60+
// Some pre-made specs and buffers -- make these once to unclutter the
61+
// test functions themselves.
62+
ImageSpec spec_2x2_f (2, 2, 1, TypeFloat);
63+
ImageSpec spec_2x2_rgb_f (2, 2, 3, TypeFloat);
64+
ImageSpec spec_1k_rgb_f (1024, 1024, 3, TypeFloat);
65+
ImageSpec spec_1k_rgb_u8 (1024, 1024, 3, TypeUInt8);
66+
ImageSpec spec_1k_rgb_u16 (1024, 1024, 3, TypeUInt16);
67+
ImageSpec spec_1k_rgba_f (1024, 1024, 4, TypeFloat);
68+
ImageSpec spec_1k_rgba_h (1024, 1024, 4, TypeHalf);
69+
ImageSpec spec_1k_rgba_u8 (1024, 1024, 4, TypeUInt8);
70+
ImageSpec spec_1k_rgba_u16 (1024, 1024, 4, TypeUInt16);
71+
ImageSpec spec_hd_rgb_f (1920, 1080, 3, TypeFloat);
72+
ImageSpec spec_hd_rgb_h (1920, 1080, 3, TypeHalf);
73+
ImageSpec spec_hd_rgb_u8 (1920, 1080, 3, TypeUInt8);
74+
ImageSpec spec_hd_rgb_u16 (1920, 1080, 3, TypeUInt16);
75+
ImageSpec spec_hd_rgba_f (1920, 1080, 4, TypeFloat);
76+
ImageSpec spec_hd_rgba_h (1920, 1080, 4, TypeHalf);
77+
ImageSpec spec_hd_rgba_u8 (1920, 1080, 4, TypeUInt8);
78+
ImageSpec spec_hd_rgba_u16 (1920, 1080, 4, TypeUInt16);
79+
80+
ImageBuf buf_2x2_f (spec_2x2_f);
81+
ImageBuf buf_2x2_rgb (spec_2x2_rgb_f);
82+
ImageBuf buf_1k_rgb_f (spec_1k_rgb_f);
83+
ImageBuf buf_1k_rgb_u8 (spec_1k_rgb_u8);
84+
ImageBuf buf_1k_rgb_u16 (spec_1k_rgb_u16);
85+
ImageBuf buf_1k_rgba_f (spec_1k_rgba_f);
86+
ImageBuf buf_1k_rgba_h (spec_1k_rgba_h);
87+
ImageBuf buf_1k_rgba_u8 (spec_1k_rgba_u8);
88+
ImageBuf buf_1k_rgba_u16(spec_1k_rgba_u16);
89+
ImageBuf buf_hd_rgb_f (spec_hd_rgb_f);
90+
ImageBuf buf_hd_rgb_h (spec_hd_rgb_h);
91+
ImageBuf buf_hd_rgb_u8 (spec_hd_rgb_u8);
92+
ImageBuf buf_hd_rgb_u16 (spec_hd_rgb_u16);
93+
ImageBuf buf_hd_rgba_f (spec_hd_rgba_f);
94+
ImageBuf buf_hd_rgba_h (spec_hd_rgba_h);
95+
ImageBuf buf_hd_rgba_u8 (spec_hd_rgba_u8);
96+
ImageBuf buf_hd_rgba_u16(spec_hd_rgba_u16);
97+
98+
// Some colors
99+
float red_rgba[] = { 1.0, 0.0, 0.0, 1.0 };
100+
}
101+
102+
58103

59104
static void
60105
getargs (int argc, char *argv[])
@@ -559,6 +604,39 @@ void test_over ()
559604

560605

561606

607+
// Test ImageBuf::resample
608+
void test_resample ()
609+
{
610+
std::cout << "test resample\n";
611+
612+
// Timing
613+
Benchmarker bench;
614+
ImageBufAlgo::fill (buf_hd_rgba_f, red_rgba);
615+
ImageBufAlgo::fill (buf_hd_rgba_u8, red_rgba);
616+
ImageBuf smallf (ImageSpec (1024, 512, 4, TypeFloat));
617+
ImageBuf smallu8 (ImageSpec (1024, 512, 4, TypeUInt8));
618+
bench (" IBA::resize 2k->1k rgba f->f interp ", [&](){
619+
ImageBufAlgo::resample (smallf, buf_hd_rgba_f, true);
620+
});
621+
bench (" IBA::resize 2k->1k rgba f->u8 interp ", [&](){
622+
ImageBufAlgo::resample (smallu8, buf_hd_rgba_f, true);
623+
});
624+
bench (" IBA::resize 2k->1k rgba u8->u8 interp ", [&](){
625+
ImageBufAlgo::resample (smallu8, buf_hd_rgba_u8, true);
626+
});
627+
bench (" IBA::resize 2k->1k rgba f->f no interp ", [&](){
628+
ImageBufAlgo::resample (smallf, buf_hd_rgba_f, false);
629+
});
630+
bench (" IBA::resize 2k->1k rgba f->u8 no interp ", [&](){
631+
ImageBufAlgo::resample (smallu8, buf_hd_rgba_f, false);
632+
});
633+
bench (" IBA::resize 2k->1k rgba u8->u8 no interp ", [&](){
634+
ImageBufAlgo::resample (smallu8, buf_hd_rgba_u8, false);
635+
});
636+
}
637+
638+
639+
562640
// Tests ImageBufAlgo::compare
563641
void test_compare ()
564642
{
@@ -941,6 +1019,7 @@ main (int argc, char **argv)
9411019
test_mul ();
9421020
test_mad ();
9431021
test_over ();
1022+
test_resample ();
9441023
test_compare ();
9451024
test_isConstantColor ();
9461025
test_isConstantChannel ();

0 commit comments

Comments
 (0)