Mercurial > mplayer.hg
annotate libmpcodecs/pullup.c @ 10788:c11c87536da4
some updates
author | alex |
---|---|
date | Mon, 01 Sep 2003 19:11:44 +0000 |
parents | cd4c523eaac4 |
children | 60f58eadd666 |
rev | line source |
---|---|
10664
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
1 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
2 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
3 #include <stdlib.h> |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
4 #include "pullup.h" |
10741
fec729835823
1000l, mmx code was not being used because of missing config.h, and
rfelker
parents:
10738
diff
changeset
|
5 #include "config.h" |
10664
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
6 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
7 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
8 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
9 #ifdef HAVE_MMX |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
10 static int diff_y_mmx(unsigned char *a, unsigned char *b, int s) |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
11 { |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
12 int ret; |
10741
fec729835823
1000l, mmx code was not being used because of missing config.h, and
rfelker
parents:
10738
diff
changeset
|
13 asm volatile ( |
10664
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
14 "movl $4, %%ecx \n\t" |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
15 "pxor %%mm4, %%mm4 \n\t" |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
16 "pxor %%mm7, %%mm7 \n\t" |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
17 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
18 ".balign 16 \n\t" |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
19 "1: \n\t" |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
20 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
21 "movq (%%esi), %%mm0 \n\t" |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
22 "movq (%%esi), %%mm2 \n\t" |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
23 "addl %%eax, %%esi \n\t" |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
24 "movq (%%edi), %%mm1 \n\t" |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
25 "addl %%eax, %%edi \n\t" |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
26 "psubusb %%mm1, %%mm2 \n\t" |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
27 "psubusb %%mm0, %%mm1 \n\t" |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
28 "movq %%mm2, %%mm0 \n\t" |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
29 "movq %%mm1, %%mm3 \n\t" |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
30 "punpcklbw %%mm7, %%mm0 \n\t" |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
31 "punpcklbw %%mm7, %%mm1 \n\t" |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
32 "punpckhbw %%mm7, %%mm2 \n\t" |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
33 "punpckhbw %%mm7, %%mm3 \n\t" |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
34 "paddw %%mm0, %%mm4 \n\t" |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
35 "paddw %%mm1, %%mm4 \n\t" |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
36 "paddw %%mm2, %%mm4 \n\t" |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
37 "paddw %%mm3, %%mm4 \n\t" |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
38 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
39 "decl %%ecx \n\t" |
10741
fec729835823
1000l, mmx code was not being used because of missing config.h, and
rfelker
parents:
10738
diff
changeset
|
40 "jnz 1b \n\t" |
fec729835823
1000l, mmx code was not being used because of missing config.h, and
rfelker
parents:
10738
diff
changeset
|
41 |
10664
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
42 "movq %%mm4, %%mm3 \n\t" |
10741
fec729835823
1000l, mmx code was not being used because of missing config.h, and
rfelker
parents:
10738
diff
changeset
|
43 "punpcklwd %%mm7, %%mm4 \n\t" |
fec729835823
1000l, mmx code was not being used because of missing config.h, and
rfelker
parents:
10738
diff
changeset
|
44 "punpckhwd %%mm7, %%mm3 \n\t" |
fec729835823
1000l, mmx code was not being used because of missing config.h, and
rfelker
parents:
10738
diff
changeset
|
45 "paddd %%mm4, %%mm3 \n\t" |
fec729835823
1000l, mmx code was not being used because of missing config.h, and
rfelker
parents:
10738
diff
changeset
|
46 "movd %%mm3, %%eax \n\t" |
fec729835823
1000l, mmx code was not being used because of missing config.h, and
rfelker
parents:
10738
diff
changeset
|
47 "psrlq $32, %%mm3 \n\t" |
10747
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
48 "movd %%mm3, %%edx \n\t" |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
49 "addl %%edx, %%eax \n\t" |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
50 "emms \n\t" |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
51 : "=a" (ret) |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
52 : "S" (a), "D" (b), "a" (s) |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
53 : "%edx" |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
54 ); |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
55 return ret; |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
56 } |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
57 |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
58 static int licomb_y_mmx(unsigned char *a, unsigned char *b, int s) |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
59 { |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
60 int ret; |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
61 asm volatile ( |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
62 "movl $8, %%ecx \n\t" |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
63 "pxor %%mm6, %%mm6 \n\t" |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
64 "pxor %%mm7, %%mm7 \n\t" |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
65 "subl %%eax, %%edi \n\t" |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
66 |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
67 ".balign 16 \n\t" |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
68 "2: \n\t" |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
69 |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
70 "movq (%%esi), %%mm0 \n\t" |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
71 "movq (%%edi), %%mm1 \n\t" |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
72 "punpcklbw %%mm7, %%mm0 \n\t" |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
73 "movq (%%edi,%%eax), %%mm2 \n\t" |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
74 "punpcklbw %%mm7, %%mm1 \n\t" |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
75 "punpcklbw %%mm7, %%mm2 \n\t" |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
76 "paddw %%mm0, %%mm0 \n\t" |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
77 "paddw %%mm2, %%mm1 \n\t" |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
78 "movq %%mm0, %%mm2 \n\t" |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
79 "psubusw %%mm1, %%mm0 \n\t" |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
80 "psubusw %%mm2, %%mm1 \n\t" |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
81 "paddw %%mm0, %%mm6 \n\t" |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
82 "paddw %%mm1, %%mm6 \n\t" |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
83 |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
84 "movq (%%esi), %%mm0 \n\t" |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
85 "movq (%%edi), %%mm1 \n\t" |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
86 "punpckhbw %%mm7, %%mm0 \n\t" |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
87 "movq (%%edi,%%eax), %%mm2 \n\t" |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
88 "punpckhbw %%mm7, %%mm1 \n\t" |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
89 "punpckhbw %%mm7, %%mm2 \n\t" |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
90 "paddw %%mm0, %%mm0 \n\t" |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
91 "paddw %%mm2, %%mm1 \n\t" |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
92 "movq %%mm0, %%mm2 \n\t" |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
93 "psubusw %%mm1, %%mm0 \n\t" |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
94 "psubusw %%mm2, %%mm1 \n\t" |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
95 "paddw %%mm0, %%mm6 \n\t" |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
96 "paddw %%mm1, %%mm6 \n\t" |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
97 |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
98 "movq (%%edi,%%eax), %%mm0 \n\t" |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
99 "movq (%%esi), %%mm1 \n\t" |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
100 "punpcklbw %%mm7, %%mm0 \n\t" |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
101 "movq (%%esi,%%eax), %%mm2 \n\t" |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
102 "punpcklbw %%mm7, %%mm1 \n\t" |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
103 "punpcklbw %%mm7, %%mm2 \n\t" |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
104 "paddw %%mm0, %%mm0 \n\t" |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
105 "paddw %%mm2, %%mm1 \n\t" |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
106 "movq %%mm0, %%mm2 \n\t" |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
107 "psubusw %%mm1, %%mm0 \n\t" |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
108 "psubusw %%mm2, %%mm1 \n\t" |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
109 "paddw %%mm0, %%mm6 \n\t" |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
110 "paddw %%mm1, %%mm6 \n\t" |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
111 |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
112 "movq (%%edi,%%eax), %%mm0 \n\t" |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
113 "movq (%%esi), %%mm1 \n\t" |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
114 "punpckhbw %%mm7, %%mm0 \n\t" |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
115 "movq (%%esi,%%eax), %%mm2 \n\t" |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
116 "punpckhbw %%mm7, %%mm1 \n\t" |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
117 "punpckhbw %%mm7, %%mm2 \n\t" |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
118 "paddw %%mm0, %%mm0 \n\t" |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
119 "paddw %%mm2, %%mm1 \n\t" |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
120 "movq %%mm0, %%mm2 \n\t" |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
121 "psubusw %%mm1, %%mm0 \n\t" |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
122 "psubusw %%mm2, %%mm1 \n\t" |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
123 "paddw %%mm0, %%mm6 \n\t" |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
124 "paddw %%mm1, %%mm6 \n\t" |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
125 |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
126 "addl %%eax, %%esi \n\t" |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
127 "addl %%eax, %%edi \n\t" |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
128 "decl %%ecx \n\t" |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
129 "jnz 2b \n\t" |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
130 |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
131 "movq %%mm6, %%mm5 \n\t" |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
132 "punpcklwd %%mm7, %%mm6 \n\t" |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
133 "punpckhwd %%mm7, %%mm5 \n\t" |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
134 "paddd %%mm6, %%mm5 \n\t" |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
135 "movd %%mm5, %%eax \n\t" |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
136 "psrlq $32, %%mm5 \n\t" |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
137 "movd %%mm5, %%edx \n\t" |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
138 "addl %%edx, %%eax \n\t" |
10664
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
139 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
140 "emms \n\t" |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
141 : "=a" (ret) |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
142 : "S" (a), "D" (b), "a" (s) |
10747
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
143 : "%edx" |
10664
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
144 ); |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
145 return ret; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
146 } |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
147 #endif |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
148 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
149 #define ABS(a) (((a)^((a)>>31))-((a)>>31)) |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
150 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
151 static int diff_y(unsigned char *a, unsigned char *b, int s) |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
152 { |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
153 int i, j, diff=0; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
154 for (i=4; i; i--) { |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
155 for (j=0; j<8; j++) diff += ABS(a[j]-b[j]); |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
156 a+=s; b+=s; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
157 } |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
158 return diff; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
159 } |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
160 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
161 static int licomb_y(unsigned char *a, unsigned char *b, int s) |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
162 { |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
163 int i, j, diff=0; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
164 for (i=8; i; i--) { |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
165 for (j=0; j<8; j++) |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
166 diff += ABS((a[j]<<1) - b[j-s] - b[j]) |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
167 + ABS((b[j]<<1) - a[j] - a[j+s]); |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
168 a+=s; b+=s; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
169 } |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
170 return diff; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
171 } |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
172 |
10747
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
173 static int licomb_y_test(unsigned char *a, unsigned char *b, int s) |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
174 { |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
175 int c = licomb_y(a,b,s); |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
176 int m = licomb_y_mmx(a,b,s); |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
177 if (c != m) printf("%d != %d\n", c, m); |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
178 return m; |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
179 } |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
180 |
10664
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
181 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
182 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
183 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
184 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
185 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
186 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
187 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
188 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
189 static void alloc_buffer(struct pullup_context *c, struct pullup_buffer *b) |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
190 { |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
191 int i; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
192 if (b->planes) return; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
193 b->planes = calloc(c->nplanes, sizeof(unsigned char *)); |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
194 for (i = 0; i < c->nplanes; i++) { |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
195 b->planes[i] = malloc(c->h[i]*c->stride[i]); |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
196 /* Deal with idiotic 128=0 for chroma: */ |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
197 memset(b->planes[i], c->background[i], c->h[i]*c->stride[i]); |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
198 } |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
199 } |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
200 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
201 struct pullup_buffer *pullup_lock_buffer(struct pullup_buffer *b, int parity) |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
202 { |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
203 if (parity+1 & 1) b->lock[0]++; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
204 if (parity+1 & 2) b->lock[1]++; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
205 return b; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
206 } |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
207 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
208 void pullup_release_buffer(struct pullup_buffer *b, int parity) |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
209 { |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
210 if (parity+1 & 1) b->lock[0]--; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
211 if (parity+1 & 2) b->lock[1]--; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
212 } |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
213 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
214 struct pullup_buffer *pullup_get_buffer(struct pullup_context *c, int parity) |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
215 { |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
216 int i; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
217 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
218 /* Try first to get the sister buffer for the previous field */ |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
219 if (parity < 2 && c->last && parity != c->last->parity |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
220 && !c->last->buffer->lock[parity]) { |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
221 alloc_buffer(c, c->last->buffer); |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
222 return pullup_lock_buffer(c->last->buffer, parity); |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
223 } |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
224 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
225 /* Prefer a buffer with both fields open */ |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
226 for (i = 0; i < c->nbuffers; i++) { |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
227 if (c->buffers[i].lock[0]) continue; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
228 if (c->buffers[i].lock[1]) continue; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
229 alloc_buffer(c, &c->buffers[i]); |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
230 return pullup_lock_buffer(&c->buffers[i], parity); |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
231 } |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
232 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
233 if (parity == 2) return 0; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
234 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
235 /* Search for any half-free buffer */ |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
236 for (i = 0; i < c->nbuffers; i++) { |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
237 if (parity+1 & 1 && c->buffers[i].lock[0]) continue; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
238 if (parity+1 & 2 && c->buffers[i].lock[1]) continue; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
239 alloc_buffer(c, &c->buffers[i]); |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
240 return pullup_lock_buffer(&c->buffers[i], parity); |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
241 } |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
242 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
243 return 0; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
244 } |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
245 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
246 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
247 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
248 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
249 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
250 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
251 static void compute_metric(struct pullup_context *c, |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
252 struct pullup_field *fa, int pa, |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
253 struct pullup_field *fb, int pb, |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
254 int (*func)(unsigned char *, unsigned char *, int), int *dest) |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
255 { |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
256 unsigned char *a, *b; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
257 int x, y; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
258 int xstep = c->bpp[0]; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
259 int ystep = c->stride[0]<<3; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
260 int s = c->stride[0]<<1; /* field stride */ |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
261 int w = c->metric_w*xstep; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
262 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
263 if (!fa->buffer || !fb->buffer) return; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
264 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
265 /* Shortcut for duplicate fields (e.g. from RFF flag) */ |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
266 if (fa->buffer == fb->buffer && pa == pb) { |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
267 memset(dest, 0, c->metric_len * sizeof(int)); |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
268 return; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
269 } |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
270 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
271 a = fa->buffer->planes[0] + pa * c->stride[0] + c->metric_offset; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
272 b = fb->buffer->planes[0] + pb * c->stride[0] + c->metric_offset; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
273 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
274 for (y = c->metric_h; y; y--) { |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
275 for (x = 0; x < w; x += xstep) { |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
276 *dest++ = func(a + x, b + x, s); |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
277 } |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
278 a += ystep; b += ystep; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
279 } |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
280 } |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
281 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
282 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
283 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
284 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
285 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
286 static void alloc_metrics(struct pullup_context *c, struct pullup_field *f) |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
287 { |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
288 f->diffs = calloc(c->metric_len, sizeof(int)); |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
289 f->licomb = calloc(c->metric_len, sizeof(int)); |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
290 /* add more metrics here as needed */ |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
291 } |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
292 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
293 static struct pullup_field *make_field_queue(struct pullup_context *c, int len) |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
294 { |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
295 struct pullup_field *head, *f; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
296 f = head = calloc(1, sizeof(struct pullup_field)); |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
297 alloc_metrics(c, f); |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
298 for (; len > 0; len--) { |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
299 f->next = calloc(1, sizeof(struct pullup_field)); |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
300 f->next->prev = f; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
301 f = f->next; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
302 alloc_metrics(c, f); |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
303 } |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
304 f->next = head; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
305 head->prev = f; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
306 return head; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
307 } |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
308 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
309 static void check_field_queue(struct pullup_context *c) |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
310 { |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
311 if (c->head->next == c->first) { |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
312 struct pullup_field *f = calloc(1, sizeof(struct pullup_field)); |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
313 alloc_metrics(c, f); |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
314 f->prev = c->head; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
315 f->next = c->first; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
316 c->head->next = f; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
317 c->first->prev = f; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
318 } |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
319 } |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
320 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
321 int pullup_submit_field(struct pullup_context *c, struct pullup_buffer *b, int parity) |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
322 { |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
323 struct pullup_field *f; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
324 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
325 /* Grow the circular list if needed */ |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
326 check_field_queue(c); |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
327 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
328 /* Cannot have two fields of same parity in a row; drop the new one */ |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
329 if (c->last && c->last->parity == parity) return 0; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
330 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
331 f = c->head; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
332 f->parity = parity; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
333 f->buffer = pullup_lock_buffer(b, parity); |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
334 f->flags = 0; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
335 f->breaks = 0; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
336 f->affinity = 0; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
337 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
338 compute_metric(c, f, parity, f->prev->prev, parity, c->diff, f->diffs); |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
339 compute_metric(c, parity?f->prev:f, 0, parity?f:f->prev, 1, c->licomb, f->licomb); |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
340 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
341 /* Advance the circular list */ |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
342 if (!c->first) c->first = c->head; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
343 c->last = c->head; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
344 c->head = c->head->next; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
345 } |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
346 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
347 void pullup_flush_fields(struct pullup_context *c) |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
348 { |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
349 struct pullup_field *f; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
350 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
351 for (f = c->first; f && f != c->head; f = f->next) { |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
352 pullup_release_buffer(f->buffer, f->parity); |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
353 f->buffer = 0; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
354 } |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
355 c->first = c->last = 0; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
356 } |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
357 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
358 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
359 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
360 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
361 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
362 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
363 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
364 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
365 #define F_HAVE_BREAKS 1 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
366 #define F_HAVE_AFFINITY 2 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
367 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
368 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
369 #define BREAK_LEFT 1 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
370 #define BREAK_RIGHT 2 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
371 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
372 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
373 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
374 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
375 static int queue_length(struct pullup_field *begin, struct pullup_field *end) |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
376 { |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
377 int count = 1; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
378 struct pullup_field *f; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
379 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
380 if (!begin || !end) return 0; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
381 for (f = begin; f != end; f = f->next) count++; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
382 return count; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
383 } |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
384 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
385 static int find_first_break(struct pullup_field *f, int max) |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
386 { |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
387 int i; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
388 for (i = 0; i < max; i++) { |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
389 if (f->breaks & BREAK_RIGHT || f->next->breaks & BREAK_LEFT) |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
390 return i+1; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
391 f = f->next; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
392 } |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
393 return 0; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
394 } |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
395 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
396 static void compute_breaks(struct pullup_context *c, struct pullup_field *f0) |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
397 { |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
398 int i; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
399 struct pullup_field *f1 = f0->next; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
400 struct pullup_field *f2 = f1->next; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
401 struct pullup_field *f3 = f2->next; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
402 int l, max_l=0, max_r=0; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
403 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
404 if (f0->flags & F_HAVE_BREAKS) return; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
405 f0->flags |= F_HAVE_BREAKS; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
406 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
407 /* Special case when fields are 100% identical */ |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
408 if (f0->buffer == f2->buffer && f1->buffer != f3->buffer) { |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
409 f0->breaks |= BREAK_LEFT; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
410 f2->breaks |= BREAK_RIGHT; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
411 return; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
412 } |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
413 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
414 for (i = 0; i < c->metric_len; i++) { |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
415 l = f2->diffs[i] - f3->diffs[i]; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
416 if (l > max_l) max_l = l; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
417 if (-l > max_r) max_r = -l; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
418 } |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
419 /* Don't get tripped up when differences are mostly quant error */ |
10738 | 420 if (max_l + max_r < 128) return; |
10664
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
421 if (max_l > 4*max_r) f1->breaks |= BREAK_LEFT; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
422 if (max_r > 4*max_l) f2->breaks |= BREAK_RIGHT; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
423 } |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
424 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
425 static void compute_affinity(struct pullup_context *c, struct pullup_field *f) |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
426 { |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
427 int i; |
10730
67449e5936f3
fix 10l (computation based on uninitialized data which led to
rfelker
parents:
10664
diff
changeset
|
428 int max_l=0, max_r=0, l, t; |
10664
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
429 if (f->flags & F_HAVE_AFFINITY) return; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
430 f->flags |= F_HAVE_AFFINITY; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
431 for (i = 0; i < c->metric_len; i++) { |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
432 l = f->licomb[i] - f->next->licomb[i]; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
433 if (l > max_l) max_l = l; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
434 if (-l > max_r) max_r = -l; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
435 } |
10738 | 436 if (max_l + max_r < 128) return; |
437 if (max_r > 2*max_l) f->affinity = -1; | |
438 else if (max_l > 2*max_r) f->affinity = 1; | |
10730
67449e5936f3
fix 10l (computation based on uninitialized data which led to
rfelker
parents:
10664
diff
changeset
|
439 else if (max_l + max_r > 2048) { |
10737 | 440 l = t = 0; |
10730
67449e5936f3
fix 10l (computation based on uninitialized data which led to
rfelker
parents:
10664
diff
changeset
|
441 for (i = 0; i < c->metric_len; i++) { |
67449e5936f3
fix 10l (computation based on uninitialized data which led to
rfelker
parents:
10664
diff
changeset
|
442 l += f->licomb[i] - f->next->licomb[i]; |
67449e5936f3
fix 10l (computation based on uninitialized data which led to
rfelker
parents:
10664
diff
changeset
|
443 t += ABS(f->licomb[i] - f->next->licomb[i]); |
67449e5936f3
fix 10l (computation based on uninitialized data which led to
rfelker
parents:
10664
diff
changeset
|
444 } |
67449e5936f3
fix 10l (computation based on uninitialized data which led to
rfelker
parents:
10664
diff
changeset
|
445 if (-l*4 > t) f->affinity = -1; |
67449e5936f3
fix 10l (computation based on uninitialized data which led to
rfelker
parents:
10664
diff
changeset
|
446 else if (l*4 > t) f->affinity = 1; |
67449e5936f3
fix 10l (computation based on uninitialized data which led to
rfelker
parents:
10664
diff
changeset
|
447 } |
10664
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
448 } |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
449 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
450 static void foo(struct pullup_context *c) |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
451 { |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
452 struct pullup_field *f = c->first; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
453 int i, n = queue_length(f, c->last); |
10730
67449e5936f3
fix 10l (computation based on uninitialized data which led to
rfelker
parents:
10664
diff
changeset
|
454 for (i = 0; i < n-1; i++) { |
10664
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
455 if (i < n-3) compute_breaks(c, f); |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
456 compute_affinity(c, f); |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
457 f = f->next; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
458 } |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
459 } |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
460 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
461 static int decide_frame_length(struct pullup_context *c) |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
462 { |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
463 int n; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
464 struct pullup_field *f0 = c->first; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
465 struct pullup_field *f1 = f0->next; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
466 struct pullup_field *f2 = f1->next; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
467 struct pullup_field *f3 = f2->next; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
468 struct pullup_field *f4 = f3->next; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
469 struct pullup_field *f5 = f4->next; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
470 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
471 if (queue_length(c->first, c->last) < 6) return 0; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
472 foo(c); |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
473 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
474 n = find_first_break(f0, 3); |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
475 |
10730
67449e5936f3
fix 10l (computation based on uninitialized data which led to
rfelker
parents:
10664
diff
changeset
|
476 if (f0->affinity == -1) return 1; |
67449e5936f3
fix 10l (computation based on uninitialized data which led to
rfelker
parents:
10664
diff
changeset
|
477 |
10664
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
478 switch (n) { |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
479 case 1: |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
480 return 1; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
481 case 2: |
10730
67449e5936f3
fix 10l (computation based on uninitialized data which led to
rfelker
parents:
10664
diff
changeset
|
482 if (f1->affinity == 1) return 1; |
10664
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
483 else return 2; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
484 case 3: |
10730
67449e5936f3
fix 10l (computation based on uninitialized data which led to
rfelker
parents:
10664
diff
changeset
|
485 if (f1->affinity == -1) return 2; |
67449e5936f3
fix 10l (computation based on uninitialized data which led to
rfelker
parents:
10664
diff
changeset
|
486 else if (f1->affinity == 1) return 1; |
10664
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
487 else return 3; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
488 default: |
10730
67449e5936f3
fix 10l (computation based on uninitialized data which led to
rfelker
parents:
10664
diff
changeset
|
489 if (f1->affinity == 1) return 1; |
67449e5936f3
fix 10l (computation based on uninitialized data which led to
rfelker
parents:
10664
diff
changeset
|
490 else if (f1->affinity == -1) return 2; |
67449e5936f3
fix 10l (computation based on uninitialized data which led to
rfelker
parents:
10664
diff
changeset
|
491 else if (f2->affinity == 1) return 2; |
67449e5936f3
fix 10l (computation based on uninitialized data which led to
rfelker
parents:
10664
diff
changeset
|
492 else if (f0->affinity == 1 && f2->affinity == -1) return 3; |
10738 | 493 else if (f2->affinity == -1) return 1; |
10730
67449e5936f3
fix 10l (computation based on uninitialized data which led to
rfelker
parents:
10664
diff
changeset
|
494 else if (f2->affinity == 0 && f3->affinity == 1) return 3; |
10664
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
495 else return 2; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
496 } |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
497 } |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
498 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
499 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
500 static void print_aff_and_breaks(struct pullup_context *c, struct pullup_field *f) |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
501 { |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
502 int i; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
503 int max_l, max_r, l; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
504 struct pullup_field *f0 = f; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
505 const char aff_l[] = "+..", aff_r[] = "..+"; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
506 printf("\naffinity: "); |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
507 for (i = 0; i < 6; i++) { |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
508 printf("%c%d%c", aff_l[1+f->affinity], i, aff_r[1+f->affinity]); |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
509 f = f->next; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
510 } |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
511 f = f0; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
512 printf("\nbreaks: "); |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
513 for (i=0; i<6; i++) { |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
514 printf("%c%d%c", f->breaks & BREAK_LEFT ? '|' : '.', i, f->breaks & BREAK_RIGHT ? '|' : '.'); |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
515 f = f->next; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
516 } |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
517 printf("\n"); |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
518 } |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
519 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
520 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
521 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
522 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
523 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
524 struct pullup_frame *pullup_get_frame(struct pullup_context *c) |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
525 { |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
526 int i; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
527 struct pullup_frame *fr = c->frame; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
528 int n = decide_frame_length(c); |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
529 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
530 if (!n) return 0; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
531 if (fr->lock) return 0; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
532 |
10738 | 533 if (c->verbose) { |
534 print_aff_and_breaks(c, c->first); | |
535 printf("duration: %d \n", n); | |
536 } | |
10664
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
537 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
538 fr->lock++; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
539 fr->length = n; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
540 fr->parity = c->first->parity; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
541 fr->buffer = 0; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
542 for (i = 0; i < n; i++) { |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
543 /* We cheat and steal the buffer without release+relock */ |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
544 fr->fields[i] = c->first->buffer; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
545 c->first->buffer = 0; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
546 c->first = c->first->next; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
547 } |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
548 /* Export the entire frame as one buffer, if possible! */ |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
549 if (n == 2 && fr->fields[0] == fr->fields[1]) { |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
550 fr->buffer = fr->fields[0]; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
551 pullup_lock_buffer(fr->buffer, 2); |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
552 return fr; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
553 } |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
554 /* (loop is in case we ever support frames longer than 3 fields) */ |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
555 for (i = 1; i < n-1; i++) { |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
556 if (fr->fields[i] == fr->fields[i-1] |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
557 || fr->fields[i] == fr->fields[i+1]) { |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
558 fr->buffer = fr->fields[i]; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
559 pullup_lock_buffer(fr->buffer, 2); |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
560 break; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
561 } |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
562 } |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
563 return fr; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
564 } |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
565 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
566 static void copy_field(struct pullup_context *c, struct pullup_buffer *dest, |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
567 struct pullup_buffer *src, int parity) |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
568 { |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
569 int i, j; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
570 unsigned char *d, *s; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
571 for (i = 0; i < c->nplanes; i++) { |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
572 s = src->planes[i] + parity*c->stride[i]; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
573 d = dest->planes[i] + parity*c->stride[i]; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
574 for (j = c->h[i]>>1; j; j--) { |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
575 memcpy(d, s, c->stride[i]); |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
576 s += c->stride[i]<<1; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
577 d += c->stride[i]<<1; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
578 } |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
579 } |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
580 } |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
581 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
582 void pullup_pack_frame(struct pullup_context *c, struct pullup_frame *fr) |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
583 { |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
584 int i; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
585 int par = fr->parity; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
586 if (fr->buffer) return; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
587 if (fr->length < 2) return; /* FIXME: deal with this */ |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
588 for (i = 0; i < fr->length; i++) |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
589 { |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
590 if (fr->fields[i]->lock[par ^ (i&1) ^ 1]) continue; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
591 fr->buffer = fr->fields[i]; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
592 pullup_lock_buffer(fr->buffer, 2); |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
593 copy_field(c, fr->buffer, fr->fields[i+(i>0?-1:1)], par^(i&1)^1); |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
594 return; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
595 } |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
596 fr->buffer = pullup_get_buffer(c, 2); |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
597 copy_field(c, fr->buffer, fr->fields[0], par); |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
598 copy_field(c, fr->buffer, fr->fields[1], par^1); |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
599 } |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
600 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
601 void pullup_release_frame(struct pullup_frame *fr) |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
602 { |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
603 int i; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
604 for (i = 0; i < fr->length; i++) |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
605 pullup_release_buffer(fr->fields[i], fr->parity ^ (i&1)); |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
606 if (fr->buffer) pullup_release_buffer(fr->buffer, 2); |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
607 fr->lock--; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
608 } |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
609 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
610 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
611 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
612 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
613 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
614 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
615 struct pullup_context *pullup_alloc_context() |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
616 { |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
617 struct pullup_context *c; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
618 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
619 c = calloc(1, sizeof(struct pullup_context)); |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
620 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
621 return c; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
622 } |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
623 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
624 void pullup_preinit_context(struct pullup_context *c) |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
625 { |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
626 c->bpp = calloc(c->nplanes, sizeof(int)); |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
627 c->w = calloc(c->nplanes, sizeof(int)); |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
628 c->h = calloc(c->nplanes, sizeof(int)); |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
629 c->stride = calloc(c->nplanes, sizeof(int)); |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
630 c->background = calloc(c->nplanes, sizeof(int)); |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
631 } |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
632 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
633 void pullup_init_context(struct pullup_context *c) |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
634 { |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
635 if (c->nbuffers < 10) c->nbuffers = 10; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
636 c->buffers = calloc(c->nbuffers, sizeof (struct pullup_buffer)); |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
637 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
638 c->metric_w = (c->w[0] - (c->junk_left + c->junk_right << 3)) >> 3; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
639 c->metric_h = (c->h[0] - (c->junk_top + c->junk_bottom << 1)) >> 3; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
640 c->metric_offset = c->junk_left*c->bpp[0] + (c->junk_top<<1)*c->stride[0]; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
641 c->metric_len = c->metric_w * c->metric_h; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
642 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
643 c->head = make_field_queue(c, 8); |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
644 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
645 c->frame = calloc(1, sizeof (struct pullup_frame)); |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
646 c->frame->fields = calloc(3, sizeof (struct pullup_buffer *)); |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
647 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
648 switch(c->format) { |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
649 case PULLUP_FMT_Y: |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
650 c->diff = diff_y; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
651 c->licomb = licomb_y; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
652 #ifdef HAVE_MMX |
10747
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
653 if (c->cpu & PULLUP_CPU_MMX) { |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
654 c->diff = diff_y_mmx; |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
655 c->licomb = licomb_y_mmx; |
cd4c523eaac4
more mmx and fix 100l sig11 in the previous mmx commit
rfelker
parents:
10741
diff
changeset
|
656 } |
10664
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
657 #endif |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
658 break; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
659 #if 0 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
660 case PULLUP_FMT_YUY2: |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
661 c->diff = diff_yuy2; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
662 break; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
663 case PULLUP_FMT_RGB32: |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
664 c->diff = diff_rgb32; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
665 break; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
666 #endif |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
667 } |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
668 } |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
669 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
670 void pullup_free_context(struct pullup_context *c) |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
671 { |
10738 | 672 struct pullup_field *f; |
673 free(c->buffers); | |
674 f = c->head; | |
675 do { | |
676 free(f->diffs); | |
677 free(f->licomb); | |
678 f = f->next; | |
679 free(f->prev); | |
680 } while (f != c->head); | |
681 free(c->frame); | |
682 free(c); | |
10664
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
683 } |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
684 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
685 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
686 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
687 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
688 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
689 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
690 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
691 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
692 |