summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorM Joonas Pihlaja <jpihlaja@cc.helsinki.fi>2009-01-14 19:43:17 +0200
committerM Joonas Pihlaja <jpihlaja@cc.helsinki.fi>2009-01-14 19:43:17 +0200
commit5fbaebc3c69c8d475e7d57532d7ed37be11ee2bd (patch)
tree7ca3e3dd17042a52579a7d07619cf873cacfeb67
parent64bf5415f6b03a78aa83e8ecf95ebd5996bb7a28 (diff)
Added some usage text to the driver.
-rw-r--r--unpremultiply.c59
1 files changed, 56 insertions, 3 deletions
diff --git a/unpremultiply.c b/unpremultiply.c
index 1919a15..9beebd0 100644
--- a/unpremultiply.c
+++ b/unpremultiply.c
@@ -185,6 +185,57 @@ main(int argc, char **argv)
double elapsed_ms;
int i;
+ if (1 == argc) {
+ printf(
+ "usage: unpremultiply [aliased] <data> [solid] [method] [verify]\n"
+ "\n"
+ "Prints out the time in ms taken to unpremultiply a data buffer\n"
+ "using the given method. Optionally verifies the result.\n"
+ "If 'aliased' is given on the command line then the source\n"
+ "and destination buffers are the same.\n"
+ "\n"
+ "Available methods:\n"
+ " div The reference unpremultiplier using three\n"
+ " divisions per pixel.\n"
+ " lut A division table based unpremultiplier.\n"
+ " inv A reciprocal table based unpremultiplier.\n"
+ " lutb 'lut' with special casings for constant and\n"
+ " solid pixel runs.\n"
+ " invb 'inv' with special casings for constant and\n"
+ " solid pixel runs.\n"
+ " sse2 An AMD64/SSE2 unpremultiplier.\n"
+ "\n"
+ "Methods suitable as timing references:\n"
+ " copy memcpy(dst, src, pixels);\n"
+ " write memset(dst, 0, pixels);\n"
+ " read Sums the source pixels.\n"
+ "\n"
+ "Available data generators:\n"
+ " random Random pixel values.\n"
+ " gradient A smoothly varying alpha gradient.\n"
+ " Usually gives the same results as\n"
+ " the random data.\n"
+ " clear All zeros.\n"
+ "\n"
+ "If the 'solid' suffix is given after the data, then the\n"
+ "data is forced to be completely opaque by setting the alpha\n"
+ "of every pixel to 255. If 'verify' is given on the command\n"
+ "line then the final result is verified against a reference\n"
+ "unpremultiplier. Verification using aliased data buffers\n"
+ "works correctly when loops=1.\n"
+ "\n"
+ "Environment variables affecting the run:\n"
+ " loops [500] Number of times to do the\n"
+ " unpremultiplication\n"
+ " pixels [2097152] Size of the data buffers in pixels.\n"
+ " offset [0] Byte offset added to the data buffer\n"
+ " pointers to misalign the pixel data.\n"
+ " This option is liable to segfault the\n"
+ " program.\n"
+ );
+ return 1;
+ }
+
udst.u8 = calloc(n*4+offset, 1) + offset;
usrc.u8 = calloc(n*4+offset, 1) + offset;
#define dst udst.u32
@@ -290,7 +341,7 @@ main(int argc, char **argv)
printf("%f\n", elapsed_ms);
if (verify) {
- size_t i;
+ unsigned i;
int maxdiff = 0;
for (i=0; i<n; i++) {
uint32_t x = dst[i];
@@ -300,8 +351,10 @@ main(int argc, char **argv)
int diff = (x & 255) - (y & 255);
if (diff < 0) diff = -diff;
if (diff > maxdiff) {
- printf("src:%08x dst:%08x ref:%08x diff:%d, i:%ld.%d\n",
- src[i], dst[i], ref[i], diff, i,j);
+ printf("maxdiff now %d: "
+ "src[%u]=%08x dst[%u]=%08x ref[%u]=%08x "
+ "(component %d)\n",
+ diff, i, src[i], i, dst[i], i, ref[i], j);
maxdiff = diff;
}
x >>= 8;