12 #include "mythconfig.h"
22 #include "libavutil/mem.h"
23 #include "libavcodec/dsputil.h"
45 uint64_t *ybuf = (uint64_t*) (frame->
buf + frame->
offsets[0]);
46 uint64_t *ubuf = (uint64_t*) (frame->
buf + frame->
offsets[1]);
47 uint64_t *vbuf = (uint64_t*) (frame->
buf + frame->
offsets[2]);
48 const uint64_t Y_black = 0x1010101010101010LL;
49 const uint64_t UV_black = 0x8080808080808080LL;
61 for (y = 0; (y < tf->
yp1 * frame->
pitches[0] << 1) && (y < sz); y += 2)
63 ybuf[y + 0] = Y_black;
64 ybuf[y + 1] = Y_black;
71 ybuf[y + 0] = Y_black;
72 ybuf[y + 1] = Y_black;
77 for (y = 0; (y < tf->
yp1 * frame->
pitches[1]) && (y < sz); y++)
94 for (y = tf->
yp1 * t1;
95 (y < ((frame->
height >> 4) - tf->
yp2) * t1) && (y < sz); y += t2)
97 for (x = 0; (x < (tf->
xp1 << 1)) && (x < t1); x += 2)
99 ybuf[y + x + 0] = Y_black;
100 ybuf[y + x + 1] = Y_black;
103 for (x = t2 - (tf->
xp2 << 1); (x < t2) && (x < t1); x += 2)
105 ybuf[y + x + 0] = Y_black;
106 ybuf[y + x + 1] = Y_black;
114 for (y = (frame->
pitches[1] * tf->
yp1) >> 1; (y < t1) && (y < sz); y += t2)
116 for (x = 0; x < tf->
xp1; x++)
118 ubuf[y +
x] = UV_black;
119 vbuf[y +
x] = UV_black;
122 for (x = t2 - tf->
xp2; x < t2; x++)
124 ubuf[y +
x] = UV_black;
125 vbuf[y +
x] = UV_black;
129 TF_END(tf,
"Crop: ");
138 uint64_t *ybuf = (uint64_t*) (frame->
buf + frame->
offsets[0]);
139 uint64_t *ubuf = (uint64_t*) (frame->
buf + frame->
offsets[1]);
140 uint64_t *vbuf = (uint64_t*) (frame->
buf + frame->
offsets[2]);
141 const uint64_t Y_black = 0x1010101010101010LL;
142 const uint64_t UV_black = 0x8080808080808080LL;
143 int x,
y, sz, t1, t2;
152 __asm__
volatile(
"emms\n\t");
154 __asm__
volatile(
"movq (%1),%%mm0 \n\t"
155 "movq (%0),%%mm1 \n\t"
156 : :
"r" (&UV_black),
"r"(&Y_black));
160 for (y = 0; (y < tf->
yp1 * frame->
pitches[0] << 1) && (y < sz); y += 2)
162 __asm__
volatile(
"movq %%mm0, (%0) \n\t"
163 "movq %%mm0, 8(%0) \n\t"
171 __asm__
volatile(
"movq %%mm0, (%0) \n\t"
172 "movq %%mm0, 8(%0) \n\t"
178 for (y = 0; (y < tf->
yp1 * frame->
pitches[1]) && (y < sz); y++)
180 __asm__
volatile(
"movq %%mm1, (%0) \n\t"
181 "movq %%mm1, (%1) \n\t"
182 : :
"r" (ubuf +
y),
"r" (vbuf + y));
188 __asm__
volatile(
"movq %%mm1, (%0) \n\t"
189 "movq %%mm1, (%1) \n\t"
190 : :
"r" (ubuf +
y),
"r" (vbuf + y));
197 for (y = tf->
yp1 * t1;
198 (y < ((frame->
height >> 4) - tf->
yp2) * t1) && (y < sz); y += t2)
200 for (x = 0; (x < (tf->
xp1 << 1)) && (x < t1); x += 2)
202 __asm__
volatile(
"movq %%mm0, (%0) \n\t"
203 "movq %%mm0, 8(%0) \n\t"
204 : :
"r" (ybuf + y +
x));
207 for (x = t2 - (tf->
xp2 << 1); (x < t2) && (x < t1); x += 2)
209 __asm__
volatile(
"movq %%mm0, (%0) \n\t"
210 "movq %%mm0, 8(%0) \n\t"
211 : :
"r" (ybuf + y +
x));
219 for (y = (frame->
pitches[1] * tf->
yp1) >> 1; (y < t1) && (y < sz); y += t2)
221 for (x = 0; x < tf->
xp1; x++)
223 __asm__
volatile(
"movq %%mm1, (%0) \n\t"
224 "movq %%mm1, (%1) \n\t"
225 : :
"r" (ubuf + y +
x),
"r" (vbuf + y + x));
228 for (x = t2 - tf->
xp2; x < t2; x++)
230 __asm__
volatile(
"movq %%mm1, (%0) \n\t"
231 "movq %%mm1, (%1) \n\t"
232 : :
"r" (ubuf + y +
x),
"r" (vbuf + y + x));
236 __asm__
volatile(
"emms\n\t");
238 TF_END(tf,
"CropMMX: ");
245 int *
width,
int *height,
char *options,
257 "crop: Attempt to initialize with unsupported format\n");
265 fprintf(stderr,
"crop: Couldn't allocate memory for filter\n");
269 filter->
yp1 = filter->
yp2 = filter->
xp1 = filter->
xp2 = 1;
273 unsigned int param1, param2, param3, param4;
274 if (sscanf(options,
"%20u:%20u:%20u:%20u",
275 ¶m1, ¶m2, ¶m3, ¶m4) == 4)
277 filter->
yp1 = param1;
278 filter->
yp2 = param3;
279 filter->
xp1 = param2;
280 filter->
xp2 = param4;
288 if (av_get_cpu_flags() & AV_CPU_FLAG_MMX)
307 .name= (
char*)
"crop",
308 .descript= (
char*)
"crops picture by macroblock intervals",