50 unsigned short int odd;
53 } __attribute__ ((aligned (8)));
96 #define PPZ { 2000, 2000, 0, 2000 }
97 #define PPR { 2000, 2000, 0, 2000 }
102 #define MIN(a,b) (((a)<(b))?(a):(b))
105 #define MAX(a,b) (((a)>(b))?(a):(b))
108 #define PDIFFUB(X,Y,T) "movq " #X "," #T "\n\t" \
109 "psubusb " #Y "," #T "\n\t" \
110 "psubusb " #X "," #Y "\n\t" \
111 "paddusb " #Y "," #T "\n\t"
113 #define PDIFFUBT(X,Y,T) "movq " #X "," #T "\n\t" \
114 "psubusb " #Y "," #T "\n\t" \
115 "psubusb " #X "," #Y "\n\t" \
116 "paddusb " #T "," #Y "\n\t"
118 #define PSUMBW(X,T,Z) "movq " #X "," #T "\n\t" \
119 "punpcklbw " #Z "," #X "\n\t" \
120 "punpckhbw " #Z "," #T "\n\t" \
121 "paddw " #T "," #X "\n\t" \
122 "movq " #X "," #T "\n\t" \
123 "psllq $32, " #T "\n\t" \
124 "paddw " #T "," #X "\n\t" \
125 "movq " #X "," #T "\n\t" \
126 "psllq $16, " #T "\n\t" \
127 "paddw " #T "," #X "\n\t" \
128 "psrlq $48, " #X "\n\t"
130 #define PSADBW(X,Y,T,Z) PDIFFUBT(X,Y,T) PSUMBW(Y,T,Z)
132 #define PMAXUB(X,Y) "psubusb " #X "," #Y "\n\tpaddusb " #X "," #Y "\n\t"
133 #define PMAXUW(X,Y) "psubusw " #X "," #Y "\n\tpaddusw " #X "," #Y "\n\t"
134 #define PMINUBT(X,Y,T) "movq " #Y "," #T "\n\t" \
135 "psubusb " #X "," #T "\n\t" \
136 "psubusb " #T "," #Y "\n\t"
137 #define PAVGB(X,Y) "pavgusb " #X "," #Y "\n\t"
146 cmmx_t old_po = *(cmmx_t*)(a );
147 cmmx_t po = *(cmmx_t*)(b );
148 cmmx_t e = *(cmmx_t*)(b + bs);
149 cmmx_t old_o = *(cmmx_t*)(a + 2*as);
150 cmmx_t o = *(cmmx_t*)(b + 2*bs);
151 cmmx_t ne = *(cmmx_t*)(b + 3*bs);
152 cmmx_t old_no = *(cmmx_t*)(a + 4*as);
153 cmmx_t no = *(cmmx_t*)(b + 4*bs);
155 cmmx_t qup_old_odd = p31avgb(old_o, old_po);
156 cmmx_t qup_odd = p31avgb( o, po);
157 cmmx_t qdown_old_odd = p31avgb(old_o, old_no);
158 cmmx_t qdown_odd = p31avgb( o, no);
160 cmmx_t qup_even = p31avgb(ne, e);
161 cmmx_t qdown_even = p31avgb(e, ne);
163 cmmx_t temp_up_diff = pdiffub(qdown_even, qup_old_odd);
164 cmmx_t noise_up_diff = pdiffub(qdown_even, qup_odd);
165 cmmx_t temp_down_diff = pdiffub(qup_even, qdown_old_odd);
166 cmmx_t noise_down_diff = pdiffub(qup_even, qdown_odd);
168 cmmx_t odd_diff = pdiffub(o, old_o);
169 m->
odd += psumbw(odd_diff);
170 m->
even += psadbw(e, *(cmmx_t*)(a+as));
172 temp_up_diff = pminub(temp_up_diff, temp_down_diff);
173 temp_up_diff = pminub(temp_up_diff, odd_diff);
174 m->
temp += psumbw(temp_up_diff);
175 noise_up_diff = pminub(noise_up_diff, odd_diff);
176 noise_up_diff = pminub(noise_up_diff, noise_down_diff);
178 m->
noise += psumbw(noise_up_diff);
191 cmmx_t old_po = (*(cmmx_t*)(a ) >> 1) & ~SIGN_BITS;
192 cmmx_t po = (*(cmmx_t*)(b ) >> 1) & ~SIGN_BITS;
193 cmmx_t old_e = (*(cmmx_t*)(a + as) >> 1) & ~SIGN_BITS;
194 cmmx_t e = (*(cmmx_t*)(b + bs) >> 1) & ~SIGN_BITS;
195 cmmx_t old_o = (*(cmmx_t*)(a + 2*as) >> 1) & ~SIGN_BITS;
196 cmmx_t o = (*(cmmx_t*)(b + 2*bs) >> 1) & ~SIGN_BITS;
197 cmmx_t ne = (*(cmmx_t*)(b + 3*bs) >> 1) & ~SIGN_BITS;
198 cmmx_t old_no = (*(cmmx_t*)(a + 4*as) >> 1) & ~SIGN_BITS;
199 cmmx_t no = (*(cmmx_t*)(b + 4*bs) >> 1) & ~SIGN_BITS;
201 cmmx_t qup_old_odd = p31avgb_s(old_o, old_po);
202 cmmx_t qup_odd = p31avgb_s( o, po);
203 cmmx_t qdown_old_odd = p31avgb_s(old_o, old_no);
204 cmmx_t qdown_odd = p31avgb_s( o, no);
206 cmmx_t qup_even = p31avgb_s(ne, e);
207 cmmx_t qdown_even = p31avgb_s(e, ne);
209 cmmx_t temp_up_diff = pdiffub_s(qdown_even, qup_old_odd);
210 cmmx_t noise_up_diff = pdiffub_s(qdown_even, qup_odd);
211 cmmx_t temp_down_diff = pdiffub_s(qup_even, qdown_old_odd);
212 cmmx_t noise_down_diff = pdiffub_s(qup_even, qdown_odd);
214 cmmx_t odd_diff = pdiffub_s(o, old_o);
215 m->
odd += psumbw_s(odd_diff) << 1;
216 m->
even += psadbw_s(e, old_e) << 1;
218 temp_up_diff = pminub_s(temp_up_diff, temp_down_diff);
219 temp_up_diff = pminub_s(temp_up_diff, odd_diff);
220 m->
temp += psumbw_s(temp_up_diff) << 1;
221 noise_up_diff = pminub_s(noise_up_diff, odd_diff);
222 noise_up_diff = pminub_s(noise_up_diff, noise_down_diff);
224 m->
noise += psumbw_s(noise_up_diff) << 1;
237 cmmx_t old_po = (*(cmmx_t*)(a )>>1) & ~SIGN_BITS;
238 cmmx_t po = (*(cmmx_t*)(b )>>1) & ~SIGN_BITS;
239 cmmx_t old_e = (*(cmmx_t*)(a + as)>>1) & ~SIGN_BITS;
240 cmmx_t e = (*(cmmx_t*)(b + bs)>>1) & ~SIGN_BITS;
241 cmmx_t old_o = (*(cmmx_t*)(a + 2*as)>>1) & ~SIGN_BITS;
242 cmmx_t o = (*(cmmx_t*)(b + 2*bs)>>1) & ~SIGN_BITS;
243 cmmx_t ne = (*(cmmx_t*)(b + 3*bs)>>1) & ~SIGN_BITS;
245 cmmx_t down_even = p31avgb_s(e, ne);
246 cmmx_t up_odd = p31avgb_s(o, po);
247 cmmx_t up_old_odd = p31avgb_s(old_o, old_po);
249 cmmx_t odd_diff = pdiffub_s(o, old_o);
250 cmmx_t temp_diff = pdiffub_s(down_even, up_old_odd);
251 cmmx_t noise_diff = pdiffub_s(down_even, up_odd);
253 m->
even += psadbw_s(e, old_e) << 1;
254 m->
odd += psumbw_s(odd_diff) << 1;
256 temp_diff = pminub_s(temp_diff, odd_diff);
257 noise_diff = pminub_s(noise_diff, odd_diff);
259 m->
noise += psumbw_s(noise_diff) << 1;
260 m->
temp += psumbw_s(temp_diff) << 1;
275 unsigned e_big = m->
even >= (m->
odd + two_o + 1)/2;
276 unsigned o_big = m->
odd >= (m->
even + two_e + 1)/2;
277 unsigned n_big = m->
noise >= (m->
temp + two_t + 1)/2;
278 unsigned t_big = m->
temp >= (m->
noise + two_n + 1)/2;
280 unsigned e2x = m->
even >= two_o;
281 unsigned o2x = m->
odd >= two_e;
282 unsigned n2x = m->
noise >= two_t;
283 unsigned t2x = m->
temp >= two_n;
285 unsigned ntiny_e = m->
even > p->
thres.even ;
286 unsigned ntiny_o = m->
odd > p->
thres.odd ;
288 unsigned ntiny_t = m->
temp > p->
thres.temp ;
290 unsigned nlow_e = m->
even > 2*p->
thres.even ;
291 unsigned nlow_o = m->
odd > 2*p->
thres.odd ;
292 unsigned nlow_n = m->
noise > 2*p->
thres.noise;
293 unsigned nlow_t = m->
temp > 2*p->
thres.temp ;
295 unsigned high_e = m->
even > 4*p->
thres.even ;
296 unsigned high_o = m->
odd > 4*p->
thres.odd ;
297 unsigned high_n = m->
noise > 4*p->
thres.noise;
298 unsigned high_t = m->
temp > 4*p->
thres.temp ;
300 unsigned low_il = !n_big && !t_big && ntiny_n && ntiny_t;
301 unsigned high_il = !n_big && !t_big && nlow_n && nlow_t;
303 if (low_il | high_il) {
307 s->tiny.
even += ntiny_e;
308 s->tiny.
odd += ntiny_o;
309 s->tiny.
noise += ntiny_n;
310 s->tiny.
temp += ntiny_t;
312 s->low .
even += nlow_e ;
313 s->low .
odd += nlow_o ;
314 s->low .
noise += nlow_n ;
315 s->low .
temp += nlow_t ;
317 s->high.
even += high_e ;
318 s->high.
odd += high_o ;
319 s->high.
noise += high_n ;
320 s->high.
temp += high_t ;
333 s->bigger.
even += e_big ;
334 s->bigger.
odd += o_big ;
335 s->bigger.
noise += n_big ;
336 s->bigger.
temp += t_big ;
338 s->twox.
even += e2x ;
340 s->twox.
noise += n2x ;
341 s->twox.
temp += t2x ;
352 if (
sizeof(cmmx_t) < 8)
365 if (
sizeof(cmmx_t) < 8)
378 if (
sizeof(cmmx_t) < 8)
384 #define MEQ(X,Y) ((X).even == (Y).even && (X).odd == (Y).odd && (X).temp == (Y).temp && (X).noise == (Y).noise)
386 #define BLOCK_METRICS_TEMPLATE() \
387 __asm__ volatile("pxor %mm7, %mm7\n\t" \
388 "pxor %mm6, %mm6\n\t" \
394 "movq (%0,%2), %%mm0\n\t" \
395 "movq (%1,%3), %%mm1\n\t" \
396 PSADBW(%%mm1, %%mm0, %%mm4, %%mm6) \
397 "paddusw %%mm0, %%mm7\n\t" \
398 "movq (%0,%2,2), %%mm0\n\t" \
399 "movq (%1,%3,2), %%mm2\n\t" \
400 "movq (%0), %%mm3\n\t" \
401 "psubusb %4, %%mm3\n\t" \
402 PAVGB(%%mm0, %%mm3) \
403 PAVGB(%%mm0, %%mm3) \
404 "movq %%mm0, %%mm5\n\t" \
405 PSADBW(%%mm2, %%mm0, %%mm4, %%mm6) \
406 "psllq $16, %%mm0\n\t" \
407 "paddusw %%mm0, %%mm7\n\t" \
408 "movq (%1), %%mm4\n\t" \
409 "lea (%0,%2,2), %0\n\t" \
410 "lea (%1,%3,2), %1\n\t" \
411 "psubusb %4, %%mm4\n\t" \
412 PAVGB(%%mm2, %%mm4) \
413 PAVGB(%%mm2, %%mm4) \
414 PDIFFUBT(%%mm5, %%mm2, %%mm0) \
415 "movq (%1,%3), %%mm5\n\t" \
416 "psubusb %4, %%mm5\n\t" \
417 PAVGB(%%mm1, %%mm5) \
418 PAVGB(%%mm5, %%mm1) \
419 PAVGB((%1,%3), %%mm5) \
420 PDIFFUBT(%%mm1, %%mm3, %%mm0) \
421 PDIFFUBT(%%mm1, %%mm4, %%mm0) \
422 PMINUBT(%%mm2, %%mm3, %%mm0) \
423 PMINUBT(%%mm2, %%mm4, %%mm0) \
424 "movq (%1,%3,2), %%mm2\n\t" \
425 "psubusb %4, %%mm2\n\t" \
428 "movq (%0,%2,2), %%mm1\n\t" \
429 "psubusb %4, %%mm1\n\t" \
432 PDIFFUBT(%%mm5, %%mm2, %%mm0) \
433 PDIFFUBT(%%mm5, %%mm1, %%mm0) \
434 PMINUBT(%%mm4, %%mm2, %%mm0) \
435 PMINUBT(%%mm3, %%mm1, %%mm0) \
436 PSUMBW(%%mm2, %%mm0, %%mm6) \
437 PSUMBW(%%mm1, %%mm0, %%mm6) \
438 "psllq $32, %%mm2\n\t" \
439 "psllq $48, %%mm1\n\t" \
440 "paddusw %%mm2, %%mm7\n\t" \
441 "paddusw %%mm1, %%mm7\n\t" \
442 : "=r" (a), "=r" (b) \
443 : "r"((x86_reg)as), "r"((x86_reg)bs), "m" (ones), "0"(a), "1"(b), "X"(*a), "X"(*b) \
455 static const unsigned long long ones = 0x0101010101010101ull;
458 __asm__
volatile(
"movq %%mm7, %0\n\temms" :
"=m" (tm));
470 #define PSUMBW(X,T,Z) "psadbw " #Z "," #X "\n\t"
471 #define PSADBW(X,Y,T,Z) "psadbw " #X "," #Y "\n\t"
472 #define PMAXUB(X,Y) "pmaxub " #X "," #Y "\n\t"
473 #define PMINUBT(X,Y,T) "pminub " #X "," #Y "\n\t"
474 #define PAVGB(X,Y) "pavgb " #X "," #Y "\n\t"
484 static const unsigned long long ones = 0x0101010101010101ull;
486 x86_reg prefetch_line = (((long)a>>3) & 7) + 10;
490 __asm__
volatile(
"prefetcht0 (%0,%2)\n\t"
491 "prefetcht0 (%1,%3)\n\t" :
493 "r" (prefetch_line * as),
"r" (prefetch_line * bs));
500 "movq %%mm7, %%mm1\n\t"
501 "psubusw %%mm0, %%mm1\n\t"
502 "movq %%mm1, %%mm2\n\t"
503 "paddusw %%mm0, %%mm2\n\t"
504 "paddusw %%mm7, %%mm2\n\t"
505 "pshufw $0xb1, %%mm2, %%mm3\n\t"
506 "pavgw %%mm7, %%mm2\n\t"
507 "pshufw $0xb1, %%mm2, %%mm2\n\t"
508 "psubusw %%mm7, %%mm2\n\t"
509 "pcmpeqw %%mm6, %%mm2\n\t"
510 "psubusw %%mm7, %%mm3\n\t"
511 "pcmpeqw %%mm6, %%mm3\n\t"
514 "psubw %%mm2, %%mm4\n\t"
515 "psubw %%mm3, %%mm5\n\t"
518 "pxor %%mm4, %%mm4\n\t"
519 "pcmpeqw %%mm1, %%mm4\n\t"
520 "psubusw %%mm0, %%mm1\n\t"
521 "pxor %%mm5, %%mm5\n\t"
522 "pcmpeqw %%mm1, %%mm5\n\t"
523 "psubusw %%mm0, %%mm1\n\t"
524 "psubusw %%mm0, %%mm1\n\t"
525 "pcmpeqw %%mm6, %%mm1\n\t"
526 "pshufw $0xb1, %%mm2, %%mm0\n\t"
527 "por %%mm2, %%mm0\n\t"
528 "punpckhdq %%mm0, %%mm0\n\t"
529 "movq %%mm4, %%mm2\n\t"
530 "punpckhdq %%mm5, %%mm2\n\t"
531 "por %%mm2, %%mm0\n\t"
532 "pcmpeqd %%mm6, %%mm0\n\t"
533 "psrlq $16, %%mm0\n\t"
534 "psrlw $15, %%mm0\n\t"
536 :
"=r" (interlaced),
"=m" (s->bigger),
"=m" (s->twox)
541 s->interlaced_high += interlaced >> 16;
542 s->interlaced_low += interlaced;
545 "pcmpeqw %%mm0, %%mm0\n\t"
546 "psubw %%mm0, %%mm4\n\t"
547 "psubw %%mm0, %%mm5\n\t"
548 "psubw %%mm0, %%mm1\n\t"
549 "paddw %0, %%mm4\n\t"
550 "paddw %1, %%mm5\n\t"
551 "paddw %2, %%mm1\n\t"
555 :
"=m" (s->tiny),
"=m" (s->low),
"=m" (s->high)
559 "pshufw $0, %2, %%mm0\n\t"
560 "psubusw %%mm7, %%mm0\n\t"
561 "pcmpeqw %%mm6, %%mm0\n\t"
562 "pand %%mm7, %%mm0\n\t"
563 "movq %%mm0, %%mm1\n\t"
564 "punpcklwd %%mm6, %%mm0\n\t"
565 "punpckhwd %%mm6, %%mm1\n\t"
566 "paddd %0, %%mm0\n\t"
567 "paddd %1, %%mm1\n\t"
570 :
"=m" (s->sad.even),
"=m" (s->sad.noise)
576 "movq %%mm7, (%1)\n\t"
578 "movq %%mm7, (%0)\n\t"
580 : :
"r" (&s->max),
"r" (&tm),
"X" (s->max)
592 # define CHECK(X) if (!MEQ(s->X, ts.X)) \
593 ff_mp_msg(MSGT_VFILTER, MSGL_WARN, "Bad " #X "\n");
608 long cos,
int ds,
int ss,
int w,
int t)
614 unsigned long len = (w+7) >> 3;
617 "pxor %%mm6, %%mm6 \n\t"
618 "movd %0, %%mm7 \n\t"
619 "punpcklbw %%mm7, %%mm7 \n\t"
620 "punpcklwd %%mm7, %%mm7 \n\t"
621 "punpckldq %%mm7, %%mm7 \n\t"
627 "movq (%0), %%mm0\n\t"
628 "movq (%0,%3,2), %%mm1\n\t"
629 "movq %%mm0, (%2)\n\t"
630 "pmaxub %%mm1, %%mm0\n\t"
631 "pavgb (%0), %%mm1\n\t"
632 "psubusb %%mm1, %%mm0\n\t"
633 "paddusb %%mm7, %%mm0\n\t"
634 "movq (%0,%1), %%mm2\n\t"
635 "movq (%0,%5), %%mm3\n\t"
636 "movq %%mm2, %%mm4\n\t"
639 "pminub %%mm2, %%mm3\n\t"
640 "pcmpeqb %%mm3, %%mm2\n\t"
641 "pand %%mm2, %%mm4\n\t"
642 "pandn (%0,%5), %%mm2\n\t"
643 "por %%mm4, %%mm2\n\t"
644 "pminub %%mm0, %%mm3\n\t"
645 "pcmpeqb %%mm0, %%mm3\n\t"
646 "psubb %%mm3, %%mm6\n\t"
647 "pand %%mm3, %%mm1 \n\t"
648 "pandn %%mm2, %%mm3 \n\t"
649 "por %%mm3, %%mm1 \n\t"
650 "movq %%mm1, (%2,%4) \n\t"
658 __asm__
volatile (
"pxor %%mm7, %%mm7 \n\t"
659 "psadbw %%mm6, %%mm7 \n\t"
660 "movd %%mm7, %0 \n\t"
670 long cos,
int ds,
int ss,
int w,
int t)
672 unsigned long len = ((
unsigned long)w+
sizeof(cmmx_t)-1) /
sizeof(cmmx_t);
673 cmmx_t dint_count = 0;
677 if (
sizeof(cmmx_t) > 4)
678 thr |= thr << (
sizeof(cmmx_t)*4);
680 cmmx_t
e = *(cmmx_t*)a;
681 cmmx_t ne = *(cmmx_t*)(a+2*ss);
682 cmmx_t
o = *(cmmx_t*)(a+bos);
683 cmmx_t oo = *(cmmx_t*)(a+cos);
684 cmmx_t maxe = pmaxub(e, ne);
685 cmmx_t avge = pavgb(e, ne);
686 cmmx_t max_diff = maxe - avge + thr;
687 cmmx_t diffo = pdiffub(avge, o);
688 cmmx_t diffoo = pdiffub(avge, oo);
689 cmmx_t diffcmp = pcmpgtub(diffo, diffoo);
690 cmmx_t bo = ((oo ^
o) & diffcmp) ^
o;
691 cmmx_t diffbo = ((diffoo ^ diffo) & diffcmp) ^ diffo;
692 cmmx_t above_thr = ~pcmpgtub(max_diff, diffbo);
693 cmmx_t bo_or_avg = ((avge ^ bo) & above_thr) ^ bo;
694 dint_count += above_thr & ONE_BYTES;
696 *(cmmx_t*)(dst+ds) = bo_or_avg;
698 dst +=
sizeof(cmmx_t);
700 return psumbw(dint_count);
705 unsigned char *
c,
unsigned long w,
unsigned long h,
706 unsigned long ds,
unsigned long ss,
unsigned long threshold,
707 long field,
long mmx2)
709 unsigned long ret = 0;
721 if (threshold >= 128) {
724 }
else if (mmx2 == 1) {
740 unsigned char **old,
unsigned char **
new,
unsigned long show)
742 unsigned long threshold = 256;
743 unsigned long field = p->
swapped;
744 unsigned long dint_pixels = 0;
745 unsigned char **other = old;
746 if (show >= 12 || !(show & 3))
747 show >>= 2, other =
new,
new = old;
752 }
else if (show == 3)
757 other[0], p->
w, p->
h, dmpi->
stride[0],
761 old =
new, other =
new;
763 threshold = threshold/2 + 1;
772 if (dint_pixels > 0 && p->
verbose)
777 unsigned char *of,
unsigned char *nf,
778 int w,
int h,
int os,
int ns,
int swapped)
781 int align = -(long)nf & 7;
793 memset(s, 0,
sizeof(*s));
795 for (y = (h-8) >> 3;
y; y--) {
797 for (i = 0; i < w; i += 8)
799 }
else if (p->
mmx2 == 2) {
800 for (i = 0; i < w; i += 8)
802 }
else if (p->
fast > 3) {
803 for (i = 0; i < w; i += 8)
805 }
else if (p->
fast > 1) {
806 for (i = 0; i < w; i += 8)
809 for (i = 0; i < w; i += 8)
817 #define METRICS(X) (X).even, (X).odd, (X).noise, (X).temp
820 unsigned char **old,
unsigned char **
new)
830 "t:%d/%d/%d/%d, l:%d/%d/%d/%d, h:%d/%d/%d/%d, bg:%d/%d/%d/%d, "
831 "2x:%d/%d/%d/%d, sad:%d/%d/%d/%d, lil:%d, hil:%d, ios:%.1f\n",
842 while (args && *++args &&
844 sscanf(args,
"diff_thres=%hu", &p->
thres.even ) == 1 ||
845 sscanf(args,
"comb_thres=%hu", &p->
thres.noise) == 1 ||
846 sscanf(args,
"sad_thres=%lu", &p->
sad_thres ) == 1 ||
847 sscanf(args,
"dint_thres=%lu", &p->
dint_thres ) == 1 ||
848 sscanf(args,
"fast=%u", &p->
fast ) == 1 ||
849 sscanf(args,
"mmx2=%lu", &p->
mmx2 ) == 1 ||
850 sscanf(args,
"luma_only=%u", &p->
luma_only ) == 1 ||
851 sscanf(args,
"verbose=%u", &p->
verbose ) == 1 ||
852 sscanf(args,
"crop=%lu:%lu:%lu:%lu", &p->
w,
854 args = strchr(args,
'/');
858 static unsigned long gcd(
unsigned long x,
unsigned long y)
875 unsigned long plane_size, chroma_plane_size;
876 unsigned char *plane;
877 unsigned long cos, los;
881 p->
stride = (mpi->
w + 15) & ~15;
893 plane_size = mpi->
h * p->
stride;
897 malloc(
NUM_STORED * (plane_size+2*chroma_plane_size) +
904 for (i = 0; i !=
NUM_STORED; i++, plane += plane_size) {
910 memset(plane, 0x80,
NUM_STORED * 2 * chroma_plane_size);
914 plane += chroma_plane_size;
917 plane += chroma_plane_size;
931 gettimeofday(&tv, 0);
932 return tv.tv_sec + tv.tv_usec * 1e-6;
938 static unsigned char **
planes, planes_idx;
949 planes = p->
planes[planes_idx];
965 mpi->
planes[0] = planes[0];
968 mpi->
planes[1] = planes[1];
969 mpi->
planes[2] = planes[2];
979 cmpe(
unsigned long x,
unsigned long y,
unsigned long err,
unsigned long e)
982 long unit = ((x+y+err) >> e);
983 long ret = (diff > unit) - (diff < -unit);
985 return ret + (diff > unit) - (diff < -unit);
995 unsigned long ret = 8;
999 "@@@@@@@@ Bottom-first field??? @@@@@@@@\n");
1024 if (sad_comb_cmp == 2)
1026 if (sad_comb_cmp == -2)
1032 (!sad_comb_cmp || (s->low.
noise <= n/4 && s->low.
temp <= n/4)))
1036 s->low.
noise <= n/2 && s->high.
noise <= n/4 &&
1037 s->low.
temp <= n/2 && s->high.
temp <= n/4)
1049 (!sad_comb_cmp || (s->low.
noise <= n/4 && s->low.
temp <= n/4)))
1057 if (sad_comb_cmp == 1 && s->
sad.
noise < 64)
1059 if (sad_comb_cmp == -1 && s->
sad.
temp < 64)
1062 if (s->tiny.
odd <= n || (s->tiny.
noise <= n/2 && s->tiny.
temp <= n/2)) {
1066 if (s->tiny.
even <= n || ps->tiny.
noise <= n/2)
1076 if (s->low.
odd <= n/4) {
1080 if (s->low.
even <= n/4)
1103 s->bigger.
temp < n && s->bigger.
noise < n)
1137 #define ITOC(X) (!(X) ? ' ' : (X) + ((X)>9 ? 'a'-10 : '0'))
1149 int show_fields = 0;
1150 int dropped_fields = 0;
1152 char prev_chflag = p->
chflag;
1191 }
else if ((p->
fast & 1) && prev_chflag ==
'|')
1209 dropped_fields = -2;
1217 else if (p->
iosync > 0) {
1236 int prevbreak = ps->
sad.
noise >= 128;
1239 dropped_fields = prevbreak;
1241 show_fields = 4 | (!prevbreak << 3);
1243 dropped_fields = -!prevbreak;
1249 show_fields = 3 << (breaks & 1);
1253 show_fields = (1 << (2 + p->
num_fields)) - (1<<breaks);
1256 dropped_fields += p->
num_fields + 2 - breaks;
1289 p->
notout = !(show_fields & 1) + !(show_fields & 3);
1290 if (((show_fields & 3) == 3 &&
1293 ((show_fields & 12) == 12 &&
1300 if ((show_fields & 3) != 3) planes = old_planes;
1301 dmpi->
planes[0] = planes[0];
1305 dmpi->
planes[1] = planes[1];
1306 dmpi->
planes[2] = planes[2];
1324 breaks, breaks<8 && breaks>0 ? (
int) p->
prev_fields+
'0' :
' ',
1327 breaks>0 && ((prev&~1)!=2 || prev+p->
prev_fields!=5) ?
1328 " ######## bad telecine ########" :
"",
1329 dropped_fields ?
" ======== dropped ":
"",
ITOC(dropped_fields),
1330 !show_fields || (show_fields & (show_fields-1)) ?
1331 "" :
" @@@@@@@@@@@@@@@@@");
1354 unsigned int flags,
unsigned int outfmt)
1356 unsigned long cxm = 0;
1357 unsigned long cym = 0;
1385 if (!p->
w || p->
w > width ) p->
w =
width;
1386 if (!p->
h || p->
h > height) p->
h =
height;
1390 if(!opt_screen_size_x && !opt_screen_size_y){
1391 d_width = d_width * p->
w/
width;
1392 d_height = d_height * p->
h/
height;
1419 p->
thres.noise = 128;
1420 p->
thres.even = 128;
1427 const char *args_remain =
parse_args(p, args);
1430 "filmdint: unknown suboption: %s\n", args_remain);
1435 "filmdint: increasing the frame rate is not supported\n");
1455 "Advanced inverse telecine filer",