annotate libmpcodecs/vf_detc.c @ 9545:d1bbeae9f46a

tdfx_vid a new kernel driver for tdfx wich let use agp move :)
author albeu
date Fri, 07 Mar 2003 18:42:08 +0000
parents 9fae4150ec43
children 12eae4cb4e56
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9467
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
1 #include <stdio.h>
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
2 #include <stdlib.h>
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
3 #include <string.h>
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
4
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
5 #include "../config.h"
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
6 #include "../mp_msg.h"
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
7
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
8 #include "img_format.h"
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
9 #include "mp_image.h"
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
10 #include "vf.h"
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
11
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
12 #include "../libvo/fastmemcpy.h"
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
13
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
14 struct metrics {
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
15 int even;
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
16 int odd;
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
17 int noise;
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
18 int temp;
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
19 };
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
20
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
21 struct vf_priv_s {
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
22 int frame;
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
23 int autosync;
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
24 int lastsync;
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
25 int lastdrop;
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
26 int oddfactor, noisefactor;
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
27 int resync;
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
28 struct metrics pm, hi, lo;
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
29 int prevscore;
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
30 };
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
31
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
32 static inline void *my_memcpy_pic(void * dst, void * src, int bytesPerLine, int height, int dstStride, int srcStride)
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
33 {
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
34 int i;
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
35 void *retval=dst;
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
36
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
37 for(i=0; i<height; i++)
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
38 {
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
39 memcpy(dst, src, bytesPerLine);
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
40 src+= srcStride;
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
41 dst+= dstStride;
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
42 }
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
43
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
44 return retval;
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
45 }
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
46
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
47 static void block_diffs(struct metrics *m, unsigned char *old, unsigned char *new, int os, int ns)
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
48 {
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
49 int i, x, even=0, odd=0, noise=0, temp=0, sum=0;
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
50 for (i = 8; i; i--) {
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
51 for (x = 0; x < 16; x++) {
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
52 even += abs(new[x]-old[x]);
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
53 odd += abs(new[x+ns]-old[x+os]);
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
54 sum += new[x];
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
55 noise += new[x+ns];
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
56 temp += old[x+os];
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
57 }
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
58 old += 2*os; new += 2*ns;
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
59 }
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
60 m->even = even;
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
61 m->odd = odd;
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
62 m->noise = abs(noise-sum);
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
63 m->temp = abs(temp-sum);
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
64 }
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
65
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
66
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
67 static void diff_fields(struct metrics *m, unsigned char *old, unsigned char *new, int w, int h, int os, int ns)
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
68 {
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
69 int x, y, me=0, mo=0, mn=0, mt=0;
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
70 struct metrics l;
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
71 for (y = 0; y < h-15; y += 16) {
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
72 for (x = 0; x < w-15; x += 16) {
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
73 block_diffs(&l, old+x+y*os, new+x+y*ns, os, ns);
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
74 if (l.even > me) me = l.even;
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
75 if (l.odd > mo) mo = l.odd;
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
76 if (l.noise > mn) mn = l.noise;
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
77 if (l.temp > mt) mt = l.temp;
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
78 }
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
79 }
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
80 m->even = me;
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
81 m->odd = mo;
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
82 m->noise = mn;
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
83 m->temp = mt;
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
84 }
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
85
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
86 static status(int f, struct metrics *m, int s)
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
87 {
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
88 mp_msg(MSGT_VFILTER, MSGL_V, "frame %d: e=%d o=%d n=%d t=%d s=%d\n",
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
89 f, m->even, m->odd, m->noise, m->temp, s);
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
90 }
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
91
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
92 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi)
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
93 {
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
94 struct vf_priv_s *p = vf->priv;
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
95 mp_image_t *dmpi;
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
96 int i;
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
97 struct metrics m;
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
98 int isdup, notdup;
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
99 int islaced, notlaced;
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
100 int tcstart, tcend;
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
101 int tcscore;
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
102
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
103 if (p->frame >= 0)
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
104 p->frame = (p->frame+1)%5;
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
105
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
106 dmpi = vf_get_image(vf->next, mpi->imgfmt,
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
107 MP_IMGTYPE_STATIC, MP_IMGFLAG_ACCEPT_STRIDE |
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
108 MP_IMGFLAG_PRESERVE | MP_IMGFLAG_READABLE,
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
109 mpi->width, mpi->height);
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
110
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
111 diff_fields(&m, dmpi->planes[0], mpi->planes[0],
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
112 mpi->w, mpi->h, dmpi->stride[0], mpi->stride[0]);
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
113
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
114 isdup = m.even < p->lo.even;
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
115 notdup = m.even > p->hi.even;
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
116
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
117 tcscore = (m.odd > p->lo.odd) + (m.odd > p->hi.odd) + (m.odd > 4*m.even)
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
118 + (m.noise > p->lo.noise) + (m.noise > p->hi.noise)
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
119 + (m.noise > m.temp)
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
120 + (m.even * p->pm.odd > m.odd * p->pm.even);
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
121
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
122 status(p->frame, &m, tcscore);
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
123
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
124 vf->priv->pm = m;
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
125 vf->priv->prevscore = tcscore;
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
126
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
127 switch (vf->priv->frame) {
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
128 case 0:
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
129 case 1:
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
130 case 2:
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
131 if (isdup && (tcscore > 3)) {
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
132 //status(p->frame, &m, tcscore);
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
133 mp_msg(MSGT_VFILTER, MSGL_V, "heavy lacing, trying to resync with telecine!\n");
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
134 vf->priv->frame = 3;
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
135 return 0;
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
136 } else if (tcscore > 5) {
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
137 //status(p->frame, &m, tcscore);
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
138 mp_msg(MSGT_VFILTER, MSGL_V, "laced scene change, trying to resync with telecine!\n");
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
139 vf->priv->frame = 3;
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
140 return 0;
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
141 }
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
142 break;
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
143 case 3:
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
144 if (notdup && (m.noise < p->hi.noise)) {
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
145 //status(p->frame, &m, tcscore);
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
146 mp_msg(MSGT_VFILTER, MSGL_V, "non-duplicate field; lost telecine tracking!\n");
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
147 vf->priv->frame = -1;
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
148 }
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
149 break;
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
150 case 4:
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
151 if (m.temp > p->hi.temp) { /* bad match */
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
152 //status(p->frame, &m, tcscore);
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
153 if (m.noise < p->hi.noise) {
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
154 mp_msg(MSGT_VFILTER, MSGL_V, "mismatched non-interlaced frame; lost telecine tracking!\n");
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
155 vf->priv->frame = -1;
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
156 } else {
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
157 mp_msg(MSGT_VFILTER, MSGL_V, "mismatched interlaced frame; trying to resync!\n");
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
158 vf->priv->frame = 3;
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
159 }
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
160 }
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
161 break;
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
162 default:
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
163 if (!notdup && (tcscore > 2)) {
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
164 //status(p->frame, &m, tcscore);
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
165 mp_msg(MSGT_VFILTER, MSGL_V, "caught the telecine start!\n");
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
166 vf->priv->frame = 3;
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
167 }
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
168 break;
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
169 }
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
170
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
171 if (vf->priv->frame < 3) {
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
172 memcpy_pic(dmpi->planes[0], mpi->planes[0], mpi->w, mpi->h,
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
173 dmpi->stride[0], mpi->stride[0]);
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
174 if (mpi->flags & MP_IMGFLAG_PLANAR) {
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
175 memcpy_pic(dmpi->planes[1], mpi->planes[1],
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
176 mpi->chroma_width, mpi->chroma_height,
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
177 dmpi->stride[1], mpi->stride[1]);
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
178 memcpy_pic(dmpi->planes[2], mpi->planes[2],
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
179 mpi->chroma_width, mpi->chroma_height,
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
180 dmpi->stride[2], mpi->stride[2]);
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
181 }
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
182 } else if (vf->priv->frame == 3) {
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
183 my_memcpy_pic(dmpi->planes[0]+dmpi->stride[0],
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
184 mpi->planes[0]+mpi->stride[0], mpi->w, mpi->h/2,
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
185 dmpi->stride[0]*2, mpi->stride[0]*2);
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
186 if (mpi->flags & MP_IMGFLAG_PLANAR) {
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
187 my_memcpy_pic(dmpi->planes[1]+dmpi->stride[1],
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
188 mpi->planes[1]+mpi->stride[1],
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
189 mpi->chroma_width, mpi->chroma_height/2,
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
190 dmpi->stride[1]*2, mpi->stride[1]*2);
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
191 my_memcpy_pic(dmpi->planes[2]+dmpi->stride[2],
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
192 mpi->planes[2]+mpi->stride[2],
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
193 mpi->chroma_width, mpi->chroma_height/2,
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
194 dmpi->stride[2]*2, mpi->stride[2]*2);
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
195 }
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
196 p->lastdrop = 0;
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
197 return 0;
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
198 } else {
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
199 my_memcpy_pic(dmpi->planes[0], mpi->planes[0], mpi->w, mpi->h/2,
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
200 dmpi->stride[0]*2, mpi->stride[0]*2);
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
201 if (mpi->flags & MP_IMGFLAG_PLANAR) {
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
202 my_memcpy_pic(dmpi->planes[1], mpi->planes[1],
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
203 mpi->chroma_width, mpi->chroma_height/2,
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
204 dmpi->stride[1]*2, mpi->stride[1]*2);
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
205 my_memcpy_pic(dmpi->planes[2], mpi->planes[2],
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
206 mpi->chroma_width, mpi->chroma_height/2,
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
207 dmpi->stride[2]*2, mpi->stride[2]*2);
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
208 }
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
209 }
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
210 if (++p->lastdrop >= 5) {
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
211 mp_msg(MSGT_VFILTER, MSGL_V, "dropping frame!\n");
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
212 p->lastdrop = 0;
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
213 return 0;
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
214 }
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
215 return vf_next_put_image(vf, dmpi);
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
216 }
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
217
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
218 static int query_format(struct vf_instance_s* vf, unsigned int fmt)
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
219 {
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
220 /* FIXME - figure out which other formats work */
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
221 switch (fmt) {
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
222 case IMGFMT_YV12:
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
223 case IMGFMT_IYUV:
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
224 case IMGFMT_I420:
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
225 return vf_next_query_format(vf, fmt);
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
226 }
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
227 return 0;
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
228 }
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
229
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
230 static int config(struct vf_instance_s* vf,
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
231 int width, int height, int d_width, int d_height,
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
232 unsigned int flags, unsigned int outfmt)
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
233 {
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
234 return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt);
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
235 }
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
236
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
237 static void uninit(struct vf_instance_s* vf)
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
238 {
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
239 free(vf->priv);
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
240 }
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
241
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
242 static int open(vf_instance_t *vf, char* args)
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
243 {
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
244 struct vf_priv_s *p;
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
245 vf->config = config;
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
246 vf->put_image = put_image;
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
247 vf->query_format = query_format;
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
248 vf->uninit = uninit;
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
249 vf->default_reqs = VFCAP_ACCEPT_STRIDE;
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
250 vf->priv = p = calloc(1, sizeof(struct vf_priv_s));
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
251 if (args) sscanf(args, "%d:%d", &vf->priv->frame, &vf->priv->autosync);
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
252 p->frame = -1;
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
253 p->lastsync = 10;
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
254 p->lo.even = 1760;
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
255 p->hi.even = 2880;
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
256 p->lo.odd = 2560;
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
257 p->hi.odd = 10240;
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
258 p->lo.noise = 4480;
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
259 p->hi.noise = 10240;
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
260 p->lo.temp = 6400;
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
261 p->hi.temp = 12800;
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
262 vf->priv->oddfactor = 3;
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
263 vf->priv->noisefactor = 6;
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
264 return 1;
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
265 }
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
266
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
267 vf_info_t vf_info_detc = {
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
268 "de-telecine filter",
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
269 "detc",
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
270 "Rich Felker",
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
271 "",
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
272 open
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
273 };
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
274
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
275