aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/meh.h13
-rw-r--r--src/scale.c25
2 files changed, 17 insertions, 21 deletions
diff --git a/src/meh.h b/src/meh.h
index d7f160e..bec6724 100644
--- a/src/meh.h
+++ b/src/meh.h
@@ -36,3 +36,16 @@ void xinit();
void drawimage(XImage *ximg, unsigned int width, unsigned int height);
XImage *getimage(struct image *img, unsigned int width, unsigned int height);
+#ifdef TDEBUG
+#define TDEBUG_START \
+struct timeval t0;\
+struct timeval t1;\
+gettimeofday(&t0, NULL);
+#define TDEBUG_END(x) \
+gettimeofday(&t1, NULL); \
+printf("%s: %li x100us\n", (x), ((t1.tv_sec - t0.tv_sec) * 1000000 + t1.tv_usec - t0.tv_usec) / 100);
+#else
+#define TDEBUG_START
+#define TDEBUG_END(x)
+#endif
+
diff --git a/src/scale.c b/src/scale.c
index 5036738..4cd62f3 100644
--- a/src/scale.c
+++ b/src/scale.c
@@ -3,7 +3,6 @@
#include <sys/time.h>
#include "meh.h"
-#define TDEBUG 0
#define GETVAL0(c) ((ibuf[x0 + (c)] * (ur) + ibuf[x1 + (c)] * (u)) * (vr) >> 20)
#define GETVAL(c) (( \
@@ -16,12 +15,6 @@
(ibufn[x1 + (c)]) * (u)\
) * (v)) >> 20)
-
-#if TDEBUG
-struct timeval t0;
-struct timeval t1;
-#endif
-
#define XLOOP(F) \
for(x = 0; x < ximg->width*4;){ \
const unsigned int x0 = a[x++];\
@@ -51,9 +44,7 @@ void scale(struct image *img, XImage *ximg){
const unsigned int jdy = ximg->bytes_per_line / 4 - ximg->width;
const unsigned int dy = img->bufwidth * 3;
-#if TDEBUG
- gettimeofday(&t0, NULL);
-#endif
+ TDEBUG_START
unsigned int a[ximg->width * 4];
{
@@ -96,10 +87,7 @@ void scale(struct image *img, XImage *ximg){
y++;
}
-#if TDEBUG
- gettimeofday(&t1, NULL);
- printf("%li x100us\n", ((t1.tv_sec - t0.tv_sec) * 1000000 + t1.tv_usec - t0.tv_usec) / 100);
-#endif
+ TDEBUG_END("scale")
}
void linearscale(struct image *img, XImage *ximg){
@@ -109,9 +97,7 @@ void linearscale(struct image *img, XImage *ximg){
unsigned int jdy = ximg->bytes_per_line / 4 - ximg->width;
unsigned int dx = (img->bufwidth << 10) / ximg->width;
-#if TDEBUG
- gettimeofday(&t0, NULL);
-#endif
+ TDEBUG_START
for(y = 0; y < ximg->height; y++){
unsigned int bufx = img->bufwidth / ximg->width;
@@ -127,10 +113,7 @@ void linearscale(struct image *img, XImage *ximg){
newBuf += jdy;
}
-#if TDEBUG
- gettimeofday(&t1, NULL);
- printf("%li x100us\n", ((t1.tv_sec - t0.tv_sec) * 1000000 + t1.tv_usec - t0.tv_usec) / 100);
-#endif
+ TDEBUG_END("linearscale")
}