Commit | Line | Data |
---|---|---|
80f575fc DM |
1 | #define NUMCMP 2000 |
2 | ||
3 | int checkCompareImg(VSMotionDetect* md, const VSFrame* frame){ | |
4 | int i; | |
5 | int error; | |
6 | uint8_t *Y_c; | |
7 | Field field; | |
8 | field.x=400; | |
9 | field.y=400; | |
10 | field.size=12; | |
11 | ||
12 | Y_c = frame->data[0]; | |
13 | int linesize = frame->linesize[0]; | |
14 | ||
15 | for(i=-10;i<10; i+=2){ | |
16 | printf("\nCheck: shiftX = %i\n",i); | |
17 | error = compareSubImg(Y_c, Y_c, &field, | |
18 | linesize, linesize, md->fi.height, | |
19 | 1, i, 0, INT_MAX); | |
20 | fprintf(stderr,"mismatch %i: %i\n", i, error); | |
21 | } | |
22 | return 1; | |
23 | } | |
24 | ||
25 | void test_checkCompareImg(const TestData* testdata){ | |
26 | VSMotionDetect md; | |
27 | VSMotionDetectConfig conf = vsMotionDetectGetDefaultConfig("test_checkCompareImg"); | |
28 | conf.shakiness=6; | |
29 | conf.accuracy=12; | |
30 | test_bool(vsMotionDetectInit(&md, &conf, &testdata->fi) == VS_OK); | |
31 | fflush(stdout); | |
32 | test_bool(checkCompareImg(&md,&testdata->frames[0])); | |
33 | vsMotionDetectionCleanup(&md); | |
34 | } | |
35 | ||
36 | ||
37 | typedef unsigned int (*cmpSubImgFunc)(unsigned char* const I1, unsigned char* const I2, | |
38 | const Field* field, | |
39 | int width1, int width2, int height, int bytesPerPixel, | |
40 | int d_x, int d_y, unsigned int threshold); | |
41 | ||
42 | // runs the compareSubImg routine and returns the time and stores the difference. | |
43 | // if diffsRef is given than the results are validated | |
44 | int runcompare( cmpSubImgFunc cmpsubfunc, | |
45 | VSFrame frame1, VSFrame frame2, Field f, | |
46 | VSFrameInfo fi, int* diffs, int* diffsRef, int numruns){ | |
47 | int start = timeOfDayinMS(); | |
48 | int i; | |
49 | for(i=0; i<numruns; i++){ | |
50 | diffs[i]=cmpsubfunc(frame1.data[0], frame2.data[0], | |
51 | &f, frame1.linesize[0], frame2.linesize[0], fi.height, | |
52 | 2, i%200, i/200, INT_MAX); | |
53 | } | |
54 | int end = timeOfDayinMS(); | |
55 | if(diffsRef) | |
56 | for(i=0; i<numruns; i++){ | |
57 | if(diffs[i]!=diffsRef[i]){ | |
58 | fprintf(stderr, "ERROR! Ref difference %i, Opt difference %i\n", | |
59 | diffsRef[i], diffs[i]); | |
60 | } | |
61 | } | |
62 | return end-start; | |
63 | } | |
64 | ||
65 | ||
66 | ||
67 | void test_compareImg_performance(const TestData* testdata){ | |
68 | Field f; | |
69 | f.size=128; | |
70 | f.x = 400; | |
71 | f.y = 300; | |
72 | fprintf(stderr,"********** Compare speedtest:\n"); | |
73 | ||
74 | int numruns = NUMCMP; | |
75 | int diffsC[numruns]; | |
76 | int diffsO[numruns]; | |
77 | int timeC, timeO; | |
78 | timeC=runcompare(compareSubImg_thr, testdata->frames[0], testdata->frames[1], | |
79 | f, testdata->fi, diffsC, 0, numruns); | |
80 | fprintf(stderr,"***C time for %i runs: %i ms ****\n", numruns, timeC); | |
81 | #ifdef USE_ORC | |
82 | timeO=runcompare(compareSubImg_orc, testdata->frames[0], testdata->frames[1], | |
83 | f, testdata->fi, diffsO, diffsC, numruns); | |
84 | fprintf(stderr,"***orc time for %i runs: %i ms \tSpeedup %3.2f\n", | |
85 | numruns, timeO, (double)timeC/timeO); | |
86 | timeO=runcompare(compareSubImg_thr_orc, testdata->frames[0], testdata->frames[1], | |
87 | f, testdata->fi, diffsO, diffsC, numruns); | |
88 | fprintf(stderr,"***thr_orc time for %i runs: %i ms \tSpeedup %3.2f\n", | |
89 | numruns, timeO, (double)timeC/timeO); | |
90 | #endif | |
91 | #ifdef USE_SSE2 | |
92 | timeO=runcompare(compareSubImg_thr_sse2, testdata->frames[0], testdata->frames[1], | |
93 | f, testdata->fi, diffsO, diffsC, numruns); | |
94 | fprintf(stderr,"***thr_sse2 time for %i runs: %i ms \tSpeedup %3.2f\n", | |
95 | numruns, timeO, (double)timeC/timeO); | |
96 | #endif | |
97 | #ifdef USE_SSE2_ASM | |
98 | timeO=runcompare(compareSubImg_thr_sse2_asm, testdata->frames[0], testdata->frames[1], | |
99 | f, testdata->fi, diffsO, diffsC, numruns); | |
100 | fprintf(stderr,"***thr_asm time for %i runs: %i ms \tSpeedup %3.2f\n", | |
101 | numruns, timeO, (double)timeC/timeO); | |
102 | #endif | |
103 | } |