annotate libmpcodecs/vf_ilpack.c @ 23359:48004718b734

synced with r23370
author Gabrov
date Tue, 22 May 2007 20:08:13 +0000
parents d2fa2322ce83
children f8d4f8eff72b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9933
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
1 #include <stdio.h>
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
2 #include <stdlib.h>
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
3 #include <string.h>
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
4 #include <inttypes.h>
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
5
17012
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 13720
diff changeset
6 #include "config.h"
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 13720
diff changeset
7 #include "mp_msg.h"
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 13720
diff changeset
8 #include "cpudetect.h"
9933
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
9
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
10 #include "img_format.h"
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
11 #include "mp_image.h"
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
12 #include "vf.h"
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
13
17012
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 13720
diff changeset
14 #include "libvo/fastmemcpy.h"
9933
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
15
11643
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
16 typedef void (pack_func_t)(unsigned char *dst, unsigned char *y,
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
17 unsigned char *u, unsigned char *v, int w, int us, int vs);
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
18
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
19 struct vf_priv_s {
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
20 int mode;
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
21 pack_func_t *pack[2];
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
22 };
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
23
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
24 static void pack_nn_C(unsigned char *dst, unsigned char *y,
9933
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
25 unsigned char *u, unsigned char *v, int w)
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
26 {
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
27 int j;
11643
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
28 for (j = w/2; j; j--) {
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
29 *dst++ = *y++;
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
30 *dst++ = *u++;
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
31 *dst++ = *y++;
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
32 *dst++ = *v++;
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
33 }
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
34 }
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
35
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
36 static void pack_li_0_C(unsigned char *dst, unsigned char *y,
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
37 unsigned char *u, unsigned char *v, int w, int us, int vs)
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
38 {
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
39 int j;
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
40 for (j = w/2; j; j--) {
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
41 *dst++ = *y++;
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
42 *dst++ = (u[us+us] + 7*u[0])>>3;
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
43 *dst++ = *y++;
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
44 *dst++ = (v[vs+vs] + 7*v[0])>>3;
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
45 u++; v++;
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
46 }
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
47 }
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
48
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
49 static void pack_li_1_C(unsigned char *dst, unsigned char *y,
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
50 unsigned char *u, unsigned char *v, int w, int us, int vs)
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
51 {
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
52 int j;
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
53 for (j = w/2; j; j--) {
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
54 *dst++ = *y++;
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
55 *dst++ = (3*u[us+us] + 5*u[0])>>3;
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
56 *dst++ = *y++;
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
57 *dst++ = (3*v[vs+vs] + 5*v[0])>>3;
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
58 u++; v++;
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
59 }
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
60 }
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
61
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
62 #ifdef HAVE_MMX
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
63 static void pack_nn_MMX(unsigned char *dst, unsigned char *y,
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
64 unsigned char *u, unsigned char *v, int w)
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
65 {
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
66 asm volatile (""
19372
6334c14b38eb Replace asmalign.h hack by ASMALIGN cpp macros from config.h.
diego
parents: 18746
diff changeset
67 ASMALIGN(4)
9933
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
68 "1: \n\t"
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
69 "movq (%0), %%mm1 \n\t"
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
70 "movq (%0), %%mm2 \n\t"
11648
57372aa1d655 mmx simplifications
michael
parents: 11645
diff changeset
71 "movq (%1), %%mm4 \n\t"
57372aa1d655 mmx simplifications
michael
parents: 11645
diff changeset
72 "movq (%2), %%mm6 \n\t"
57372aa1d655 mmx simplifications
michael
parents: 11645
diff changeset
73 "punpcklbw %%mm6, %%mm4 \n\t"
57372aa1d655 mmx simplifications
michael
parents: 11645
diff changeset
74 "punpcklbw %%mm4, %%mm1 \n\t"
57372aa1d655 mmx simplifications
michael
parents: 11645
diff changeset
75 "punpckhbw %%mm4, %%mm2 \n\t"
9933
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
76
13720
821f464b4d90 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents: 11648
diff changeset
77 "add $8, %0 \n\t"
821f464b4d90 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents: 11648
diff changeset
78 "add $4, %1 \n\t"
821f464b4d90 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents: 11648
diff changeset
79 "add $4, %2 \n\t"
9933
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
80 "movq %%mm1, (%3) \n\t"
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
81 "movq %%mm2, 8(%3) \n\t"
13720
821f464b4d90 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents: 11648
diff changeset
82 "add $16, %3 \n\t"
9933
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
83 "decl %4 \n\t"
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
84 "jnz 1b \n\t"
11643
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
85 "emms \n\t"
9933
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
86 :
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
87 : "r" (y), "r" (u), "r" (v), "r" (dst), "r" (w/8)
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
88 : "memory"
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
89 );
11643
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
90 pack_nn_C(dst, y, u, v, (w&7));
9933
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
91 }
11645
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
92
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
93 static void pack_li_0_MMX(unsigned char *dst, unsigned char *y,
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
94 unsigned char *u, unsigned char *v, int w, int us, int vs)
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
95 {
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
96 asm volatile (""
13720
821f464b4d90 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents: 11648
diff changeset
97 "push %%"REG_BP" \n\t"
821f464b4d90 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents: 11648
diff changeset
98 #ifdef ARCH_X86_64
821f464b4d90 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents: 11648
diff changeset
99 "mov %6, %%"REG_BP" \n\t"
821f464b4d90 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents: 11648
diff changeset
100 #else
821f464b4d90 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents: 11648
diff changeset
101 "movl 4(%%"REG_d"), %%"REG_BP" \n\t"
821f464b4d90 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents: 11648
diff changeset
102 "movl (%%"REG_d"), %%"REG_d" \n\t"
821f464b4d90 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents: 11648
diff changeset
103 #endif
11645
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
104 "pxor %%mm0, %%mm0 \n\t"
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
105
19372
6334c14b38eb Replace asmalign.h hack by ASMALIGN cpp macros from config.h.
diego
parents: 18746
diff changeset
106 ASMALIGN(4)
11645
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
107 ".Lli0: \n\t"
13720
821f464b4d90 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents: 11648
diff changeset
108 "movq (%%"REG_S"), %%mm1 \n\t"
821f464b4d90 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents: 11648
diff changeset
109 "movq (%%"REG_S"), %%mm2 \n\t"
11645
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
110
13720
821f464b4d90 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents: 11648
diff changeset
111 "movq (%%"REG_a",%%"REG_d",2), %%mm4 \n\t"
821f464b4d90 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents: 11648
diff changeset
112 "movq (%%"REG_b",%%"REG_BP",2), %%mm6 \n\t"
11645
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
113 "punpcklbw %%mm0, %%mm4 \n\t"
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
114 "punpcklbw %%mm0, %%mm6 \n\t"
13720
821f464b4d90 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents: 11648
diff changeset
115 "movq (%%"REG_a"), %%mm3 \n\t"
821f464b4d90 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents: 11648
diff changeset
116 "movq (%%"REG_b"), %%mm5 \n\t"
11645
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
117 "punpcklbw %%mm0, %%mm3 \n\t"
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
118 "punpcklbw %%mm0, %%mm5 \n\t"
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
119 "paddw %%mm3, %%mm4 \n\t"
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
120 "paddw %%mm5, %%mm6 \n\t"
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
121 "paddw %%mm3, %%mm4 \n\t"
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
122 "paddw %%mm5, %%mm6 \n\t"
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
123 "paddw %%mm3, %%mm4 \n\t"
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
124 "paddw %%mm5, %%mm6 \n\t"
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
125 "paddw %%mm3, %%mm4 \n\t"
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
126 "paddw %%mm5, %%mm6 \n\t"
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
127 "paddw %%mm3, %%mm4 \n\t"
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
128 "paddw %%mm5, %%mm6 \n\t"
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
129 "paddw %%mm3, %%mm4 \n\t"
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
130 "paddw %%mm5, %%mm6 \n\t"
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
131 "paddw %%mm3, %%mm4 \n\t"
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
132 "paddw %%mm5, %%mm6 \n\t"
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
133 "psrlw $3, %%mm4 \n\t"
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
134 "psrlw $3, %%mm6 \n\t"
11648
57372aa1d655 mmx simplifications
michael
parents: 11645
diff changeset
135 "packuswb %%mm4, %%mm4 \n\t"
57372aa1d655 mmx simplifications
michael
parents: 11645
diff changeset
136 "packuswb %%mm6, %%mm6 \n\t"
57372aa1d655 mmx simplifications
michael
parents: 11645
diff changeset
137 "punpcklbw %%mm6, %%mm4 \n\t"
57372aa1d655 mmx simplifications
michael
parents: 11645
diff changeset
138 "punpcklbw %%mm4, %%mm1 \n\t"
57372aa1d655 mmx simplifications
michael
parents: 11645
diff changeset
139 "punpckhbw %%mm4, %%mm2 \n\t"
11645
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
140
13720
821f464b4d90 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents: 11648
diff changeset
141 "movq %%mm1, (%%"REG_D") \n\t"
821f464b4d90 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents: 11648
diff changeset
142 "movq %%mm2, 8(%%"REG_D") \n\t"
11645
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
143
13720
821f464b4d90 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents: 11648
diff changeset
144 "movq 8(%%"REG_S"), %%mm1 \n\t"
821f464b4d90 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents: 11648
diff changeset
145 "movq 8(%%"REG_S"), %%mm2 \n\t"
11645
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
146
13720
821f464b4d90 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents: 11648
diff changeset
147 "movq (%%"REG_a",%%"REG_d",2), %%mm4 \n\t"
821f464b4d90 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents: 11648
diff changeset
148 "movq (%%"REG_b",%%"REG_BP",2), %%mm6 \n\t"
11645
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
149 "punpckhbw %%mm0, %%mm4 \n\t"
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
150 "punpckhbw %%mm0, %%mm6 \n\t"
13720
821f464b4d90 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents: 11648
diff changeset
151 "movq (%%"REG_a"), %%mm3 \n\t"
821f464b4d90 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents: 11648
diff changeset
152 "movq (%%"REG_b"), %%mm5 \n\t"
11645
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
153 "punpckhbw %%mm0, %%mm3 \n\t"
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
154 "punpckhbw %%mm0, %%mm5 \n\t"
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
155 "paddw %%mm3, %%mm4 \n\t"
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
156 "paddw %%mm5, %%mm6 \n\t"
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
157 "paddw %%mm3, %%mm4 \n\t"
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
158 "paddw %%mm5, %%mm6 \n\t"
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
159 "paddw %%mm3, %%mm4 \n\t"
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
160 "paddw %%mm5, %%mm6 \n\t"
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
161 "paddw %%mm3, %%mm4 \n\t"
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
162 "paddw %%mm5, %%mm6 \n\t"
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
163 "paddw %%mm3, %%mm4 \n\t"
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
164 "paddw %%mm5, %%mm6 \n\t"
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
165 "paddw %%mm3, %%mm4 \n\t"
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
166 "paddw %%mm5, %%mm6 \n\t"
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
167 "paddw %%mm3, %%mm4 \n\t"
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
168 "paddw %%mm5, %%mm6 \n\t"
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
169 "psrlw $3, %%mm4 \n\t"
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
170 "psrlw $3, %%mm6 \n\t"
11648
57372aa1d655 mmx simplifications
michael
parents: 11645
diff changeset
171 "packuswb %%mm4, %%mm4 \n\t"
57372aa1d655 mmx simplifications
michael
parents: 11645
diff changeset
172 "packuswb %%mm6, %%mm6 \n\t"
57372aa1d655 mmx simplifications
michael
parents: 11645
diff changeset
173 "punpcklbw %%mm6, %%mm4 \n\t"
57372aa1d655 mmx simplifications
michael
parents: 11645
diff changeset
174 "punpcklbw %%mm4, %%mm1 \n\t"
57372aa1d655 mmx simplifications
michael
parents: 11645
diff changeset
175 "punpckhbw %%mm4, %%mm2 \n\t"
11645
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
176
13720
821f464b4d90 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents: 11648
diff changeset
177 "add $16, %%"REG_S" \n\t"
821f464b4d90 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents: 11648
diff changeset
178 "add $8, %%"REG_a" \n\t"
821f464b4d90 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents: 11648
diff changeset
179 "add $8, %%"REG_b" \n\t"
11645
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
180
13720
821f464b4d90 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents: 11648
diff changeset
181 "movq %%mm1, 16(%%"REG_D") \n\t"
821f464b4d90 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents: 11648
diff changeset
182 "movq %%mm2, 24(%%"REG_D") \n\t"
821f464b4d90 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents: 11648
diff changeset
183 "add $32, %%"REG_D" \n\t"
11645
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
184
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
185 "decl %%ecx \n\t"
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
186 "jnz .Lli0 \n\t"
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
187 "emms \n\t"
13720
821f464b4d90 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents: 11648
diff changeset
188 "pop %%"REG_BP" \n\t"
11645
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
189 :
13720
821f464b4d90 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents: 11648
diff changeset
190 : "S" (y), "D" (dst), "a" (u), "b" (v), "c" (w/16),
821f464b4d90 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents: 11648
diff changeset
191 #ifdef ARCH_X86_64
821f464b4d90 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents: 11648
diff changeset
192 "d" ((long)us), "r" ((long)vs)
821f464b4d90 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents: 11648
diff changeset
193 #else
821f464b4d90 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents: 11648
diff changeset
194 "d" (&us)
821f464b4d90 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents: 11648
diff changeset
195 #endif
11645
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
196 : "memory"
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
197 );
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
198 pack_li_0_C(dst, y, u, v, (w&15), us, vs);
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
199 }
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
200
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
201 static void pack_li_1_MMX(unsigned char *dst, unsigned char *y,
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
202 unsigned char *u, unsigned char *v, int w, int us, int vs)
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
203 {
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
204 asm volatile (""
13720
821f464b4d90 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents: 11648
diff changeset
205 "push %%"REG_BP" \n\t"
821f464b4d90 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents: 11648
diff changeset
206 #ifdef ARCH_X86_64
821f464b4d90 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents: 11648
diff changeset
207 "mov %6, %%"REG_BP" \n\t"
821f464b4d90 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents: 11648
diff changeset
208 #else
821f464b4d90 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents: 11648
diff changeset
209 "movl 4(%%"REG_d"), %%"REG_BP" \n\t"
821f464b4d90 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents: 11648
diff changeset
210 "movl (%%"REG_d"), %%"REG_d" \n\t"
821f464b4d90 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents: 11648
diff changeset
211 #endif
11645
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
212 "pxor %%mm0, %%mm0 \n\t"
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
213
19372
6334c14b38eb Replace asmalign.h hack by ASMALIGN cpp macros from config.h.
diego
parents: 18746
diff changeset
214 ASMALIGN(4)
11645
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
215 ".Lli1: \n\t"
13720
821f464b4d90 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents: 11648
diff changeset
216 "movq (%%"REG_S"), %%mm1 \n\t"
821f464b4d90 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents: 11648
diff changeset
217 "movq (%%"REG_S"), %%mm2 \n\t"
11645
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
218
13720
821f464b4d90 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents: 11648
diff changeset
219 "movq (%%"REG_a",%%"REG_d",2), %%mm4 \n\t"
821f464b4d90 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents: 11648
diff changeset
220 "movq (%%"REG_b",%%"REG_BP",2), %%mm6 \n\t"
11645
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
221 "punpcklbw %%mm0, %%mm4 \n\t"
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
222 "punpcklbw %%mm0, %%mm6 \n\t"
13720
821f464b4d90 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents: 11648
diff changeset
223 "movq (%%"REG_a"), %%mm3 \n\t"
821f464b4d90 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents: 11648
diff changeset
224 "movq (%%"REG_b"), %%mm5 \n\t"
11645
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
225 "punpcklbw %%mm0, %%mm3 \n\t"
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
226 "punpcklbw %%mm0, %%mm5 \n\t"
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
227 "movq %%mm4, %%mm7 \n\t"
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
228 "paddw %%mm4, %%mm4 \n\t"
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
229 "paddw %%mm7, %%mm4 \n\t"
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
230 "movq %%mm6, %%mm7 \n\t"
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
231 "paddw %%mm6, %%mm6 \n\t"
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
232 "paddw %%mm7, %%mm6 \n\t"
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
233 "paddw %%mm3, %%mm4 \n\t"
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
234 "paddw %%mm5, %%mm6 \n\t"
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
235 "paddw %%mm3, %%mm4 \n\t"
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
236 "paddw %%mm5, %%mm6 \n\t"
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
237 "paddw %%mm3, %%mm4 \n\t"
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
238 "paddw %%mm5, %%mm6 \n\t"
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
239 "paddw %%mm3, %%mm4 \n\t"
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
240 "paddw %%mm5, %%mm6 \n\t"
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
241 "paddw %%mm3, %%mm4 \n\t"
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
242 "paddw %%mm5, %%mm6 \n\t"
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
243 "psrlw $3, %%mm4 \n\t"
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
244 "psrlw $3, %%mm6 \n\t"
11648
57372aa1d655 mmx simplifications
michael
parents: 11645
diff changeset
245 "packuswb %%mm4, %%mm4 \n\t"
57372aa1d655 mmx simplifications
michael
parents: 11645
diff changeset
246 "packuswb %%mm6, %%mm6 \n\t"
57372aa1d655 mmx simplifications
michael
parents: 11645
diff changeset
247 "punpcklbw %%mm6, %%mm4 \n\t"
57372aa1d655 mmx simplifications
michael
parents: 11645
diff changeset
248 "punpcklbw %%mm4, %%mm1 \n\t"
57372aa1d655 mmx simplifications
michael
parents: 11645
diff changeset
249 "punpckhbw %%mm4, %%mm2 \n\t"
11645
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
250
13720
821f464b4d90 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents: 11648
diff changeset
251 "movq %%mm1, (%%"REG_D") \n\t"
821f464b4d90 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents: 11648
diff changeset
252 "movq %%mm2, 8(%%"REG_D") \n\t"
11645
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
253
13720
821f464b4d90 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents: 11648
diff changeset
254 "movq 8(%%"REG_S"), %%mm1 \n\t"
821f464b4d90 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents: 11648
diff changeset
255 "movq 8(%%"REG_S"), %%mm2 \n\t"
11645
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
256
13720
821f464b4d90 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents: 11648
diff changeset
257 "movq (%%"REG_a",%%"REG_d",2), %%mm4 \n\t"
821f464b4d90 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents: 11648
diff changeset
258 "movq (%%"REG_b",%%"REG_BP",2), %%mm6 \n\t"
11645
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
259 "punpckhbw %%mm0, %%mm4 \n\t"
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
260 "punpckhbw %%mm0, %%mm6 \n\t"
13720
821f464b4d90 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents: 11648
diff changeset
261 "movq (%%"REG_a"), %%mm3 \n\t"
821f464b4d90 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents: 11648
diff changeset
262 "movq (%%"REG_b"), %%mm5 \n\t"
11645
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
263 "punpckhbw %%mm0, %%mm3 \n\t"
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
264 "punpckhbw %%mm0, %%mm5 \n\t"
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
265 "movq %%mm4, %%mm7 \n\t"
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
266 "paddw %%mm4, %%mm4 \n\t"
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
267 "paddw %%mm7, %%mm4 \n\t"
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
268 "movq %%mm6, %%mm7 \n\t"
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
269 "paddw %%mm6, %%mm6 \n\t"
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
270 "paddw %%mm7, %%mm6 \n\t"
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
271 "paddw %%mm3, %%mm4 \n\t"
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
272 "paddw %%mm5, %%mm6 \n\t"
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
273 "paddw %%mm3, %%mm4 \n\t"
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
274 "paddw %%mm5, %%mm6 \n\t"
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
275 "paddw %%mm3, %%mm4 \n\t"
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
276 "paddw %%mm5, %%mm6 \n\t"
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
277 "paddw %%mm3, %%mm4 \n\t"
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
278 "paddw %%mm5, %%mm6 \n\t"
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
279 "paddw %%mm3, %%mm4 \n\t"
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
280 "paddw %%mm5, %%mm6 \n\t"
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
281 "psrlw $3, %%mm4 \n\t"
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
282 "psrlw $3, %%mm6 \n\t"
11648
57372aa1d655 mmx simplifications
michael
parents: 11645
diff changeset
283 "packuswb %%mm4, %%mm4 \n\t"
57372aa1d655 mmx simplifications
michael
parents: 11645
diff changeset
284 "packuswb %%mm6, %%mm6 \n\t"
57372aa1d655 mmx simplifications
michael
parents: 11645
diff changeset
285 "punpcklbw %%mm6, %%mm4 \n\t"
57372aa1d655 mmx simplifications
michael
parents: 11645
diff changeset
286 "punpcklbw %%mm4, %%mm1 \n\t"
57372aa1d655 mmx simplifications
michael
parents: 11645
diff changeset
287 "punpckhbw %%mm4, %%mm2 \n\t"
11645
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
288
13720
821f464b4d90 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents: 11648
diff changeset
289 "add $16, %%"REG_S" \n\t"
821f464b4d90 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents: 11648
diff changeset
290 "add $8, %%"REG_a" \n\t"
821f464b4d90 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents: 11648
diff changeset
291 "add $8, %%"REG_b" \n\t"
11645
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
292
13720
821f464b4d90 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents: 11648
diff changeset
293 "movq %%mm1, 16(%%"REG_D") \n\t"
821f464b4d90 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents: 11648
diff changeset
294 "movq %%mm2, 24(%%"REG_D") \n\t"
821f464b4d90 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents: 11648
diff changeset
295 "add $32, %%"REG_D" \n\t"
11645
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
296
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
297 "decl %%ecx \n\t"
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
298 "jnz .Lli1 \n\t"
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
299 "emms \n\t"
13720
821f464b4d90 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents: 11648
diff changeset
300 "pop %%"REG_BP" \n\t"
11645
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
301 :
13720
821f464b4d90 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents: 11648
diff changeset
302 : "S" (y), "D" (dst), "a" (u), "b" (v), "c" (w/16),
821f464b4d90 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents: 11648
diff changeset
303 #ifdef ARCH_X86_64
821f464b4d90 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents: 11648
diff changeset
304 "d" ((long)us), "r" ((long)vs)
821f464b4d90 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents: 11648
diff changeset
305 #else
821f464b4d90 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents: 11648
diff changeset
306 "d" (&us)
821f464b4d90 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents: 11648
diff changeset
307 #endif
11645
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
308 : "memory"
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
309 );
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
310 pack_li_1_C(dst, y, u, v, (w&15), us, vs);
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
311 }
9933
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
312 #endif
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
313
11643
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
314 static pack_func_t *pack_nn;
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
315 static pack_func_t *pack_li_0;
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
316 static pack_func_t *pack_li_1;
9933
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
317
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
318 static void ilpack(unsigned char *dst, unsigned char *src[3],
11643
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
319 int dststride, int srcstride[3], int w, int h, pack_func_t *pack[2])
9933
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
320 {
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
321 int i;
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
322 unsigned char *y, *u, *v;
11643
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
323 int ys = srcstride[0], us = srcstride[1], vs = srcstride[2];
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
324 int a, b;
9933
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
325
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
326 y = src[0];
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
327 u = src[1];
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
328 v = src[2];
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
329
11643
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
330 pack_nn(dst, y, u, v, w, 0, 0);
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
331 y += ys; dst += dststride;
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
332 pack_nn(dst, y, u+us, v+vs, w, 0, 0);
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
333 y += ys; dst += dststride;
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
334 for (i=2; i<h-2; i++) {
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
335 a = (i&2) ? 1 : -1;
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
336 b = (i&1) ^ ((i&2)>>1);
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
337 pack[b](dst, y, u, v, w, us*a, vs*a);
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
338 y += ys;
9933
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
339 if ((i&3) == 1) {
11643
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
340 u -= us;
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
341 v -= vs;
9933
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
342 } else {
11643
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
343 u += us;
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
344 v += vs;
9933
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
345 }
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
346 dst += dststride;
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
347 }
11643
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
348 pack_nn(dst, y, u, v, w, 0, 0);
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
349 y += ys; dst += dststride; u += us; v += vs;
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
350 pack_nn(dst, y, u, v, w, 0, 0);
9933
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
351 }
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
352
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
353
17906
20aca9baf5d8 passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents: 17012
diff changeset
354 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts)
9933
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
355 {
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
356 mp_image_t *dmpi;
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
357
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
358 // hope we'll get DR buffer:
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
359 dmpi=vf_get_image(vf->next, IMGFMT_YUY2,
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
360 MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE,
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
361 mpi->w, mpi->h);
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
362
11643
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
363 ilpack(dmpi->planes[0], mpi->planes, dmpi->stride[0], mpi->stride, mpi->w, mpi->h, vf->priv->pack);
9933
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
364
17906
20aca9baf5d8 passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents: 17012
diff changeset
365 return vf_next_put_image(vf,dmpi, pts);
9933
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
366 }
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
367
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
368 static int config(struct vf_instance_s* vf,
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
369 int width, int height, int d_width, int d_height,
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
370 unsigned int flags, unsigned int outfmt)
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
371 {
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
372 /* FIXME - also support UYVY output? */
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
373 return vf_next_config(vf, width, height, d_width, d_height, flags, IMGFMT_YUY2);
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
374 }
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
375
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
376
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
377 static int query_format(struct vf_instance_s* vf, unsigned int fmt)
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
378 {
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
379 /* FIXME - really any YUV 4:2:0 input format should work */
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
380 switch (fmt) {
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
381 case IMGFMT_YV12:
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
382 case IMGFMT_IYUV:
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
383 case IMGFMT_I420:
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
384 return vf_next_query_format(vf,IMGFMT_YUY2);
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
385 }
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
386 return 0;
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
387 }
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
388
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
389 static int open(vf_instance_t *vf, char* args)
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
390 {
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
391 vf->config=config;
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
392 vf->query_format=query_format;
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
393 vf->put_image=put_image;
11643
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
394 vf->priv = calloc(1, sizeof(struct vf_priv_s));
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
395 vf->priv->mode = 1;
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
396 if (args) sscanf(args, "%d", &vf->priv->mode);
9933
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
397
11643
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
398 pack_nn = (pack_func_t *)pack_nn_C;
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
399 pack_li_0 = pack_li_0_C;
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
400 pack_li_1 = pack_li_1_C;
9933
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
401 #ifdef HAVE_MMX
11645
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
402 if(gCpuCaps.hasMMX) {
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
403 pack_nn = (pack_func_t *)pack_nn_MMX;
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
404 pack_li_0 = pack_li_0_MMX;
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
405 pack_li_1 = pack_li_1_MMX;
3837fd1bfa5b mmx optimizations
rfelker
parents: 11643
diff changeset
406 }
9933
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
407 #endif
11643
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
408
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
409 switch(vf->priv->mode) {
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
410 case 0:
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
411 vf->priv->pack[0] = vf->priv->pack[1] = pack_nn;
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
412 break;
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
413 default:
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
414 mp_msg(MSGT_VFILTER, MSGL_WARN,
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
415 "ilpack: unknown mode %d (fallback to linear)\n",
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
416 vf->priv->mode);
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
417 case 1:
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
418 vf->priv->pack[0] = pack_li_0;
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
419 vf->priv->pack[1] = pack_li_1;
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
420 break;
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
421 }
3ddfe9316ca9 big updates to ilpack: do proper interpolation rather than just
rfelker
parents: 9933
diff changeset
422
9933
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
423 return 1;
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
424 }
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
425
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
426 vf_info_t vf_info_ilpack = {
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
427 "4:2:0 planar -> 4:2:2 packed reinterlacer",
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
428 "ilpack",
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
429 "Richard Felker",
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
430 "",
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
431 open,
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
432 NULL
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
433 };
3548701a13fe 1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff changeset
434