|
25 | 25 | //////////////////////////////////////////////////////////////////////////////// |
26 | 26 |
|
27 | 27 | #include "benchmark_runner.h" |
| 28 | +#include "verify_utils.h" |
28 | 29 | #include <VX/vx.h> |
29 | 30 | #include <VX/vx_nodes.h> |
| 31 | +#include <VX/vxu.h> |
30 | 32 | #include <vector> |
31 | 33 |
|
32 | 34 | std::vector<BenchmarkCase> registerColorBenchmarks() { |
@@ -62,6 +64,17 @@ std::vector<BenchmarkCase> registerColorBenchmarks() { |
62 | 64 | return true; |
63 | 65 | }; |
64 | 66 | bc.immediate_func = nullptr; |
| 67 | + bc.verify_fn = [](vx_context ctx) -> bool { |
| 68 | + // 2x2 RGB image (3 bytes per pixel) |
| 69 | + uint8_t rgb[12] = {255, 0, 0, 0, 255, 0, 0, 0, 255, 128, 128, 128}; |
| 70 | + vx_image in = verify::createImage(ctx, 2, 2, VX_DF_IMAGE_RGB, rgb); |
| 71 | + vx_image out = vxCreateImage(ctx, 2, 2, VX_DF_IMAGE_IYUV); |
| 72 | + vxuColorConvert(ctx, in, out); |
| 73 | + // Just verify the Y plane has non-zero data (R=255 should produce Y~76) |
| 74 | + bool ok = verify::imageNonZero(out, 2, 2); |
| 75 | + vxReleaseImage(&in); vxReleaseImage(&out); |
| 76 | + return ok; |
| 77 | + }; |
65 | 78 | cases.push_back(bc); |
66 | 79 | } |
67 | 80 |
|
@@ -95,6 +108,15 @@ std::vector<BenchmarkCase> registerColorBenchmarks() { |
95 | 108 | return true; |
96 | 109 | }; |
97 | 110 | bc.immediate_func = nullptr; |
| 111 | + bc.verify_fn = [](vx_context ctx) -> bool { |
| 112 | + uint8_t rgb[12] = {255, 0, 0, 0, 255, 0, 0, 0, 255, 128, 128, 128}; |
| 113 | + vx_image in = verify::createImage(ctx, 2, 2, VX_DF_IMAGE_RGB, rgb); |
| 114 | + vx_image out = vxCreateImage(ctx, 2, 2, VX_DF_IMAGE_NV12); |
| 115 | + vxuColorConvert(ctx, in, out); |
| 116 | + bool ok = verify::imageNonZero(out, 2, 2); |
| 117 | + vxReleaseImage(&in); vxReleaseImage(&out); |
| 118 | + return ok; |
| 119 | + }; |
98 | 120 | cases.push_back(bc); |
99 | 121 | } |
100 | 122 |
|
@@ -123,6 +145,18 @@ std::vector<BenchmarkCase> registerColorBenchmarks() { |
123 | 145 | return true; |
124 | 146 | }; |
125 | 147 | bc.immediate_func = nullptr; |
| 148 | + bc.verify_fn = [](vx_context ctx) -> bool { |
| 149 | + // 2x2 RGB: R=10,G=20,B=30 for each pixel |
| 150 | + uint8_t rgb[12] = {10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120}; |
| 151 | + vx_image in = verify::createImage(ctx, 2, 2, VX_DF_IMAGE_RGB, rgb); |
| 152 | + vx_image out = vxCreateImage(ctx, 2, 2, VX_DF_IMAGE_U8); |
| 153 | + vxuChannelExtract(ctx, in, VX_CHANNEL_R, out); |
| 154 | + auto result = verify::readImage(out, 2, 2); |
| 155 | + uint8_t exp[] = {10, 40, 70, 100}; |
| 156 | + bool ok = verify::compareU8(result, {exp, exp + 4}); |
| 157 | + vxReleaseImage(&in); vxReleaseImage(&out); |
| 158 | + return ok; |
| 159 | + }; |
126 | 160 | cases.push_back(bc); |
127 | 161 | } |
128 | 162 |
|
@@ -159,6 +193,24 @@ std::vector<BenchmarkCase> registerColorBenchmarks() { |
159 | 193 | return true; |
160 | 194 | }; |
161 | 195 | bc.immediate_func = nullptr; |
| 196 | + bc.verify_fn = [](vx_context ctx) -> bool { |
| 197 | + uint8_t r[] = {10, 40, 70, 100}; |
| 198 | + uint8_t g[] = {20, 50, 80, 110}; |
| 199 | + uint8_t b[] = {30, 60, 90, 120}; |
| 200 | + vx_image ch0 = verify::createImage(ctx, 2, 2, VX_DF_IMAGE_U8, r); |
| 201 | + vx_image ch1 = verify::createImage(ctx, 2, 2, VX_DF_IMAGE_U8, g); |
| 202 | + vx_image ch2 = verify::createImage(ctx, 2, 2, VX_DF_IMAGE_U8, b); |
| 203 | + vx_image out = vxCreateImage(ctx, 2, 2, VX_DF_IMAGE_RGB); |
| 204 | + vxuChannelCombine(ctx, ch0, ch1, ch2, nullptr, out); |
| 205 | + // Extract R channel back and verify |
| 206 | + vx_image r_out = vxCreateImage(ctx, 2, 2, VX_DF_IMAGE_U8); |
| 207 | + vxuChannelExtract(ctx, out, VX_CHANNEL_R, r_out); |
| 208 | + auto result = verify::readImage(r_out, 2, 2); |
| 209 | + bool ok = verify::compareU8(result, {r, r + 4}); |
| 210 | + vxReleaseImage(&ch0); vxReleaseImage(&ch1); vxReleaseImage(&ch2); |
| 211 | + vxReleaseImage(&out); vxReleaseImage(&r_out); |
| 212 | + return ok; |
| 213 | + }; |
162 | 214 | cases.push_back(bc); |
163 | 215 | } |
164 | 216 |
|
@@ -193,6 +245,22 @@ std::vector<BenchmarkCase> registerColorBenchmarks() { |
193 | 245 | return true; |
194 | 246 | }; |
195 | 247 | bc.immediate_func = nullptr; |
| 248 | + bc.verify_fn = [](vx_context ctx) -> bool { |
| 249 | + uint8_t a[] = {0, 128, 255, 42}; |
| 250 | + vx_image in = verify::createImage(ctx, 2, 2, VX_DF_IMAGE_U8, a); |
| 251 | + vx_image out = vxCreateImage(ctx, 2, 2, VX_DF_IMAGE_S16); |
| 252 | + vx_int32 shift = 0; |
| 253 | + vx_scalar s_shift = vxCreateScalar(ctx, VX_TYPE_INT32, &shift); |
| 254 | + vx_graph g = vxCreateGraph(ctx); |
| 255 | + vx_node n = vxConvertDepthNode(g, in, out, VX_CONVERT_POLICY_SATURATE, s_shift); |
| 256 | + vxVerifyGraph(g); |
| 257 | + vxProcessGraph(g); |
| 258 | + auto result = verify::readImageS16(out, 2, 2); |
| 259 | + bool ok = verify::compareS16(result, {0, 128, 255, 42}); |
| 260 | + vxReleaseNode(&n); vxReleaseGraph(&g); vxReleaseScalar(&s_shift); |
| 261 | + vxReleaseImage(&in); vxReleaseImage(&out); |
| 262 | + return ok; |
| 263 | + }; |
196 | 264 | cases.push_back(bc); |
197 | 265 | } |
198 | 266 |
|
|
0 commit comments