Imported Debian version 1.0~trusty
[deb_vid.stab.git] / src / orc / motiondetectorc.orc
1 ################################################################################
2 # Optimized functions
3 ################################################################################
4
5 # Image Difference
6 #
7 # for (j = 0; j < field->size; j++) {
8 # for (k = 0; k < field->size * bytesPerPixel; k++) {
9 # sum += abs((int) *p1 - (int) *p2);
10 # p1++;
11 # p2++;
12 # }
13 # p1 += (width - field->size) * bytesPerPixel;
14 # p2 += (width - field->size) * bytesPerPixel;
15 # }
16
17 .function image_difference_optimized
18 .flags 2d
19 .source 1 s1 uint8_t
20 .source 1 s2 uint8_t
21 .accumulator 4 sum uint32_t
22 accsadubl sum, s1, s2
23
24
25 .function image_line_difference_optimized
26 .source 1 s1 uint8_t
27 .source 1 s2 uint8_t
28 .accumulator 4 sum uint32_t
29 accsadubl sum, s1, s2
30
31
32
33 # Image Contrast
34 # SUM
35 # p = pstart;
36 # for (j = 0; j < field->size; j++) {
37 # for (k = 0; k < field->size; k++, p++) {
38 # sum+=*p;
39 # }
40 # p += (width - field->size);
41 # }
42 # mean=sum/numpixel;
43 # p = pstart;
44 # VARIANCE
45 # for (j = 0; j < field->size; j++) {
46 # for (k = 0; k < field->size; k++, p++) {
47 # var+=abs(*p-mean);
48 # }
49 # p += (width - field->size);
50 # }
51
52
53 # Image Contrast functions
54 # Sum of all pixels (used to calculate mean)
55 .function image_sum_optimized
56 .flags 2d
57 .accumulator 4 sum int
58 .source 1 s uint8_t
59 .temp 2 t1
60 .temp 4 t2
61 convubw t1 s
62 convuwl t2 t1
63 accl sum, t2
64
65 # this implementation appears to be slower
66 # .function image_sum_optimized
67 # .flags 2d
68 # .accumulator 4 sum int
69 # .source 1 s uint8_t
70 # .const 1 c1 0
71 # accsadubl sum, s, c1
72
73 # Variance of the image in Manhattan-Norm (absolute value)
74 .function image_variance_optimized
75 .flags 2d
76 .accumulator 4 var int
77 .source 1 s uint8_t
78 .param 1 mean uint8_t
79 accsadubl var, s, mean
80
81
82
83
84