1
2 #include "ADM_default.h"
3 #include "decimate.h"
4
5 #ifdef DECIMATE_MMX_BUILD_PLANE
6 //
7 //
8 //
9 //
isse_blend_decimate_plane(uint8_t * dst,uint8_t * src,uint8_t * src_next,int w,int h)10 void isse_blend_decimate_plane(uint8_t * dst, uint8_t* src, uint8_t* src_next,
11 int w, int h)
12 {
13 uint32_t x;
14 if (!h) return; // Height == 0 - avoid silly crash.
15
16 x=w>>3; // 8 pixels at a time
17 for(;x>0;x--)
18 {
19 __asm__(
20 ADM_ASM_ALIGN16
21 "movq (%1), %%mm0 \n"
22 "movq (%2), %%mm2 \n"
23 "pavgb %%mm0,%%mm1 \n"
24 "movq %%mm1,(%0) \n"
25
26 : : "r" (dst), "r" (src), "r" (src_next));
27
28 dst+=8;
29 src+=8;
30 src_next+=8;
31 }
32 __asm__("emms");
33
34 }
isse_scenechange_32(const uint8_t * c_plane,const uint8_t * tplane,int height,int width)35 int isse_scenechange_32(const uint8_t *c_plane, const uint8_t *tplane, int height, int width)
36 {
37 int wp=width>>5;
38 int hp=height;
39 int returnvalue=0xbadbad00;
40
41 __asm__(
42 ADM_ASM_ALIGN16
43 "pxor %%mm6,%%mm6\n"
44 "pxor %%mm7,%%mm7\n"
45 ::);
46 for(uint32_t y=0;y<hp;y++)
47 {
48 for(uint32_t x=0;x<wp;x++)
49 {
50 __asm__(
51 ADM_ASM_ALIGN16
52 "movq (%0),%%mm0 \n"
53 "movq 8(%0),%%mm2 \n"
54 "movq (%1),%%mm1 \n"
55 "movq 8(%1),%%mm3 \n"
56 "psadbw %%mm1,%%mm0\n"
57 "psadbw %%mm3,%%mm2\n"
58 "paddd %%mm0,%%mm6 \n"
59 "paddd %%mm2,%%mm7 \n"
60
61 "movq 16(%0),%%mm0 \n"
62 "movq 24(%0),%%mm2 \n"
63 "movq 16(%1),%%mm1 \n"
64 "movq 24(%1),%%mm3 \n"
65 "psadbw %%mm1,%%mm0\n"
66 "psadbw %%mm3,%%mm2\n"
67 "paddd %%mm0,%%mm6 \n"
68 "paddd %%mm2,%%mm7 \n"
69
70
71 : : "r" (c_plane) , "r" (tplane)
72 );
73 c_plane+=32;
74 tplane+=32;
75 }
76
77 c_plane+=width-wp*32;
78 tplane+=width-wp*32;
79 }
80 __asm__(
81 ADM_ASM_ALIGN16
82 "paddd %%mm6,%%mm7\n"
83 "movd %%mm7,(%0)\n"
84 "emms \n"
85 : : "r" (&returnvalue)
86 );
87
88 return returnvalue;
89 }
isse_scenechange_16(const uint8_t * c_plane,const uint8_t * tplane,int height,int width)90 int isse_scenechange_16(const uint8_t *c_plane, const uint8_t *tplane, int height, int width)
91 {
92 int wp=width>>4;
93 int hp=height;
94 int returnvalue=0xbadbad00;
95
96 __asm__(
97 ADM_ASM_ALIGN16
98 "pxor %%mm6,%%mm6\n"
99 "pxor %%mm7,%%mm7\n"
100 ::);
101 for(uint32_t y=0;y<hp;y++)
102 {
103 for(uint32_t x=0;x<wp;x++)
104 {
105 __asm__(
106 ADM_ASM_ALIGN16
107 "movq (%0),%%mm0 \n"
108 "movq 8(%0),%%mm2 \n"
109 "movq (%1),%%mm1 \n"
110 "movq 8(%1),%%mm3 \n"
111 "psadbw %%mm1,%%mm0\n"
112 "psadbw %%mm3,%%mm2\n"
113 "paddd %%mm0,%%mm6 \n"
114 "paddd %%mm2,%%mm7 \n"
115
116
117 : : "r" (c_plane) , "r" (tplane)
118 );
119 c_plane+=16;
120 tplane+=16;
121 }
122
123 c_plane+=width-wp*16;
124 tplane+=width-wp*16;
125 }
126 __asm__(
127 ADM_ASM_ALIGN16
128 "paddd %%mm6,%%mm7\n"
129 "movd %%mm7,(%0)\n"
130 "emms \n"
131 : : "r" (&returnvalue)
132 );
133
134 return returnvalue;
135 }
isse_scenechange_8(const uint8_t * c_plane,const uint8_t * tplane,int height,int width)136 int isse_scenechange_8(const uint8_t *c_plane, const uint8_t *tplane, int height, int width)
137 {
138 int wp=width>>3;
139 int hp=height;
140 int returnvalue=0xbadbad00;
141
142 __asm__(
143 ADM_ASM_ALIGN16
144 "pxor %%mm6,%%mm6\n"
145 "pxor %%mm7,%%mm7\n"
146 ::);
147 for(uint32_t y=0;y<hp;y++)
148 {
149 for(uint32_t x=0;x<wp;x++)
150 {
151 __asm__(
152 ADM_ASM_ALIGN16
153 "movq (%0),%%mm0 \n"
154 "movq (%1),%%mm1 \n"
155 "psadbw %%mm1,%%mm0\n"
156 "paddd %%mm0,%%mm6 \n"
157
158 : : "r" (c_plane) , "r" (tplane)
159 );
160 c_plane+=8;
161 tplane+=8;
162 }
163
164 c_plane+=width-wp*8;
165 tplane+=width-wp*8;
166 }
167 __asm__(
168 ADM_ASM_ALIGN16
169 "movd %%mm6,(%0)\n"
170 "emms \n"
171 : : "r" (&returnvalue)
172 );
173
174 return returnvalue;
175 }
176
177 #endif
178