1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
#include <stdio.h>
#include <sys/param.h>
#include <sys/times.h>
#include "ccvt.h"
#define LOOPS 500
static struct tms OldTime, NewTime;
static void StartProfile(const char *txt)
{
printf("Performing %-15s ", txt);
times(&OldTime);
}
static void EndProfile()
{
int elap;
times(&NewTime);
elap = (int)(NewTime.tms_utime - OldTime.tms_utime);
printf("Elapsed: User=%5d (%5.2f msec/loop) System=%5d\n", elap , (float)(1000 * elap) / (LOOPS * HZ), (int)(NewTime.tms_stime - OldTime.tms_stime));
}
int main(int argc, char *argv[])
{
unsigned char Input[256 * 256 + 2 * 128 * 128];
unsigned char Output[4 * 256 * 256];
unsigned char *p;
int x, y, t;
/* Fill input buffer with pattern for testing. Use a gray gradient
from left to right, and two diagonal color gradients.
*/
p = &Input[0];
for (x = 0; x < 256; x++)
for (y = 0; y < 256; y++)
*p++ = (x + y) / 2;
for (x = 0; x < 128; x++)
for (y = 0; y < 128; y++)
*p++ = 2 * x;
for (x = 0; x < 128; x++)
for (y = 0; y < 128; y++)
*p++ = 2 * y;
StartProfile("420p_bgr32");
for (t = 0; t < LOOPS; t++)
ccvt_420p_bgr32(256, 256, Input, Output);
EndProfile();
StartProfile("420p_bgr24");
for (t = 0; t < LOOPS; t++)
ccvt_420p_bgr24(256, 256, Input, Output);
EndProfile();
StartProfile("420p_rgb32");
for (t = 0; t < LOOPS; t++)
ccvt_420p_rgb32(256, 256, Input, Output);
EndProfile();
StartProfile("420p_rgb24");
for (t = 0; t < LOOPS; t++)
ccvt_420p_rgb24(256, 256, Input, Output);
EndProfile();
}
|