annotate libmpcodecs/vf_detc.c @ 34448:6dc79618ec0e

Fix directory creation in refupdate script.
author reimar
date Sun, 08 Jan 2012 15:38:22 +0000
parents 12e6ac943b41
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
30421
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
1 /*
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
2 * This file is part of MPlayer.
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
3 *
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
4 * MPlayer is free software; you can redistribute it and/or modify
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
5 * it under the terms of the GNU General Public License as published by
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
6 * the Free Software Foundation; either version 2 of the License, or
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
7 * (at your option) any later version.
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
8 *
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
9 * MPlayer is distributed in the hope that it will be useful,
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
12 * GNU General Public License for more details.
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
13 *
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
14 * You should have received a copy of the GNU General Public License along
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
17 */
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
18
9467
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
19 #include <stdio.h>
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
20 #include <stdlib.h>
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
21 #include <string.h>
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
22
17012
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 9665
diff changeset
23 #include "config.h"
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 9665
diff changeset
24 #include "mp_msg.h"
9467
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
25
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
26 #include "img_format.h"
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
27 #include "mp_image.h"
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
28 #include "vf.h"
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
29
17012
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 9665
diff changeset
30 #include "libvo/fastmemcpy.h"
9467
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 struct metrics {
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
33 int even;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
34 int odd;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
35 int noise;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
36 int temp;
9467
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
37 };
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 struct vf_priv_s {
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
40 int frame;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
41 int drop, lastdrop;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
42 struct metrics pm;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
43 int thres[5];
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
44 int inframes, outframes;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
45 int mode;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
46 int (*analyze)(struct vf_priv_s *, mp_image_t *, mp_image_t *);
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
47 int needread;
9554
12eae4cb4e56 new version of the de-telecine filter, largely rewritten. should work
rfelker
parents: 9467
diff changeset
48 };
12eae4cb4e56 new version of the de-telecine filter, largely rewritten. should work
rfelker
parents: 9467
diff changeset
49
12eae4cb4e56 new version of the de-telecine filter, largely rewritten. should work
rfelker
parents: 9467
diff changeset
50 #define COMPE(a,b,e) (abs((a)-(b)) < (((a)+(b))>>(e)))
12eae4cb4e56 new version of the de-telecine filter, largely rewritten. should work
rfelker
parents: 9467
diff changeset
51 #define COMPARABLE(a,b) COMPE((a),(b),2)
12eae4cb4e56 new version of the de-telecine filter, largely rewritten. should work
rfelker
parents: 9467
diff changeset
52 #define VERYCLOSE(a,b) COMPE((a),(b),3)
12eae4cb4e56 new version of the de-telecine filter, largely rewritten. should work
rfelker
parents: 9467
diff changeset
53
12eae4cb4e56 new version of the de-telecine filter, largely rewritten. should work
rfelker
parents: 9467
diff changeset
54 #define OUTER_TC_NBHD(s) ( \
12eae4cb4e56 new version of the de-telecine filter, largely rewritten. should work
rfelker
parents: 9467
diff changeset
55 COMPARABLE((s)[-1].m.even,(s)[-1].m.odd) && \
12eae4cb4e56 new version of the de-telecine filter, largely rewritten. should work
rfelker
parents: 9467
diff changeset
56 COMPARABLE((s)[1].m.even,(s)[0].m.odd) && \
12eae4cb4e56 new version of the de-telecine filter, largely rewritten. should work
rfelker
parents: 9467
diff changeset
57 COMPARABLE((s)[2].m.even,(s)[1].m.odd) && \
12eae4cb4e56 new version of the de-telecine filter, largely rewritten. should work
rfelker
parents: 9467
diff changeset
58 COMPARABLE((s)[-1].m.noise,(s)[0].m.temp) && \
12eae4cb4e56 new version of the de-telecine filter, largely rewritten. should work
rfelker
parents: 9467
diff changeset
59 COMPARABLE((s)[2].m.noise,(s)[2].m.temp) )
12eae4cb4e56 new version of the de-telecine filter, largely rewritten. should work
rfelker
parents: 9467
diff changeset
60
12eae4cb4e56 new version of the de-telecine filter, largely rewritten. should work
rfelker
parents: 9467
diff changeset
61 #define INNER_TC_NBHD(s,l,h) ( \
12eae4cb4e56 new version of the de-telecine filter, largely rewritten. should work
rfelker
parents: 9467
diff changeset
62 COMPARABLE((s)[0].m.even,(l)) && \
12eae4cb4e56 new version of the de-telecine filter, largely rewritten. should work
rfelker
parents: 9467
diff changeset
63 COMPARABLE((s)[2].m.odd,(l)) && ( \
12eae4cb4e56 new version of the de-telecine filter, largely rewritten. should work
rfelker
parents: 9467
diff changeset
64 COMPARABLE((s)[0].m.noise,(h)) || \
12eae4cb4e56 new version of the de-telecine filter, largely rewritten. should work
rfelker
parents: 9467
diff changeset
65 COMPARABLE((s)[1].m.noise,(h)) ) )
12eae4cb4e56 new version of the de-telecine filter, largely rewritten. should work
rfelker
parents: 9467
diff changeset
66
12eae4cb4e56 new version of the de-telecine filter, largely rewritten. should work
rfelker
parents: 9467
diff changeset
67 enum {
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
68 TC_DROP,
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
69 TC_PROG,
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
70 TC_IL1,
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
71 TC_IL2
9467
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
72 };
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
73
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
74 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
75 {
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
76 int x, y, even=0, odd=0, noise, temp;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
77 unsigned char *oldp, *newp;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
78 m->noise = m->temp = 0;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
79 for (x = 8; x; x--) {
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
80 oldp = old++;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
81 newp = new++;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
82 noise = temp = 0;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
83 for (y = 4; y; y--) {
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
84 even += abs(newp[0]-oldp[0]);
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
85 odd += abs(newp[ns]-oldp[os]);
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
86 noise += newp[ns]-newp[0];
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
87 temp += oldp[os]-newp[0];
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
88 oldp += os<<1;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
89 newp += ns<<1;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
90 }
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
91 m->noise += abs(noise);
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
92 m->temp += abs(temp);
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
93 }
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
94 m->even = even;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
95 m->odd = odd;
9467
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
96 }
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
97
9554
12eae4cb4e56 new version of the de-telecine filter, largely rewritten. should work
rfelker
parents: 9467
diff changeset
98 static void diff_planes(struct metrics *m, unsigned char *old, unsigned char *new, int w, int h, int os, int ns)
9467
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
99 {
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
100 int x, y, me=0, mo=0, mn=0, mt=0;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
101 struct metrics l;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
102 for (y = 0; y < h-7; y += 8) {
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
103 for (x = 0; x < w-7; x += 8) {
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
104 block_diffs(&l, old+x+y*os, new+x+y*ns, os, ns);
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
105 if (l.even > me) me = l.even;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
106 if (l.odd > mo) mo = l.odd;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
107 if (l.noise > mn) mn = l.noise;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
108 if (l.temp > mt) mt = l.temp;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
109 }
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
110 }
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
111 m->even = me;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
112 m->odd = mo;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
113 m->noise = mn;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
114 m->temp = mt;
9467
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
115 }
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
116
9554
12eae4cb4e56 new version of the de-telecine filter, largely rewritten. should work
rfelker
parents: 9467
diff changeset
117 static void diff_fields(struct metrics *metr, mp_image_t *old, mp_image_t *new)
9467
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
118 {
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
119 struct metrics m, mu, mv;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
120 diff_planes(&m, old->planes[0], new->planes[0],
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
121 new->w, new->h, old->stride[0], new->stride[0]);
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
122 if (new->flags & MP_IMGFLAG_PLANAR) {
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
123 diff_planes(&mu, old->planes[1], new->planes[1],
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
124 new->chroma_width, new->chroma_height,
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
125 old->stride[1], new->stride[1]);
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
126 diff_planes(&mv, old->planes[2], new->planes[2],
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
127 new->chroma_width, new->chroma_height,
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
128 old->stride[2], new->stride[2]);
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
129 if (mu.even > m.even) m.even = mu.even;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
130 if (mu.odd > m.odd) m.odd = mu.odd;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
131 if (mu.noise > m.noise) m.noise = mu.noise;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
132 if (mu.temp > m.temp) m.temp = mu.temp;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
133 if (mv.even > m.even) m.even = mv.even;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
134 if (mv.odd > m.odd) m.odd = mv.odd;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
135 if (mv.noise > m.noise) m.noise = mv.noise;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
136 if (mv.temp > m.temp) m.temp = mv.temp;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
137 }
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
138 *metr = m;
9554
12eae4cb4e56 new version of the de-telecine filter, largely rewritten. should work
rfelker
parents: 9467
diff changeset
139 }
12eae4cb4e56 new version of the de-telecine filter, largely rewritten. should work
rfelker
parents: 9467
diff changeset
140
9636
5a087f79270a compiler warning fix by Dominik Mierzejewski <dominik@rangers.eu.org>
alex
parents: 9593
diff changeset
141 static void status(int f, struct metrics *m)
9554
12eae4cb4e56 new version of the de-telecine filter, largely rewritten. should work
rfelker
parents: 9467
diff changeset
142 {
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
143 mp_msg(MSGT_VFILTER, MSGL_V, "frame %d: e=%d o=%d n=%d t=%d\n",
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
144 f, m->even, m->odd, m->noise, m->temp);
9554
12eae4cb4e56 new version of the de-telecine filter, largely rewritten. should work
rfelker
parents: 9467
diff changeset
145 }
12eae4cb4e56 new version of the de-telecine filter, largely rewritten. should work
rfelker
parents: 9467
diff changeset
146
12eae4cb4e56 new version of the de-telecine filter, largely rewritten. should work
rfelker
parents: 9467
diff changeset
147 static int analyze_fixed_pattern(struct vf_priv_s *p, mp_image_t *new, mp_image_t *old)
12eae4cb4e56 new version of the de-telecine filter, largely rewritten. should work
rfelker
parents: 9467
diff changeset
148 {
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
149 if (p->frame >= 0) p->frame = (p->frame+1)%5;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
150 mp_msg(MSGT_VFILTER, MSGL_V, "frame %d\n", p->frame);
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
151 switch (p->frame) {
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
152 case -1: case 0: case 1: case 2:
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
153 return TC_PROG;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
154 case 3:
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
155 return TC_IL1;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
156 case 4:
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
157 return TC_IL2;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
158 }
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
159 return 0;
9467
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
9554
12eae4cb4e56 new version of the de-telecine filter, largely rewritten. should work
rfelker
parents: 9467
diff changeset
162 static int analyze_aggressive(struct vf_priv_s *p, mp_image_t *new, mp_image_t *old)
9467
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
163 {
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
164 struct metrics m, pm;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 25767
diff changeset
165
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
166 if (p->frame >= 0) p->frame = (p->frame+1)%5;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 25767
diff changeset
167
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
168 diff_fields(&m, old, new);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 25767
diff changeset
169
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
170 status(p->frame, &m);
9554
12eae4cb4e56 new version of the de-telecine filter, largely rewritten. should work
rfelker
parents: 9467
diff changeset
171
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
172 pm = p->pm;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
173 p->pm = m;
9467
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
174
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
175 if (p->frame == 4) {
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
176 /* We need to break at scene changes, but is this a valid test? */
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
177 if ((m.even > p->thres[2]) && (m.odd > p->thres[2]) && (m.temp > p->thres[3])
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
178 && (m.temp > 5*pm.temp) && (m.temp*2 > m.noise)) {
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
179 mp_msg(MSGT_VFILTER, MSGL_V, "scene change breaking telecine!\n");
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
180 p->frame = -1;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
181 return TC_DROP;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
182 }
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
183 /* Thres. is to compensate for quantization errors when noise is low */
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
184 if (m.noise - m.temp > -p->thres[4]) {
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
185 if (COMPARABLE(m.even, pm.odd)) {
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
186 //mp_msg(MSGT_VFILTER, MSGL_V, "confirmed field match!\n");
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
187 return TC_IL2;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
188 } else if ((m.even < p->thres[0]) && (m.odd < p->thres[0]) && VERYCLOSE(m.even, m.odd)
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
189 && VERYCLOSE(m.noise,m.temp) && VERYCLOSE(m.noise,pm.noise)) {
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
190 mp_msg(MSGT_VFILTER, MSGL_V, "interlaced frame appears in duplicate!!!\n");
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
191 p->pm = pm; /* hack :) */
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
192 p->frame = 3;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
193 return TC_IL1;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
194 }
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
195 } else {
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
196 mp_msg(MSGT_VFILTER, MSGL_V, "mismatched telecine fields!\n");
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
197 p->frame = -1;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
198 }
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
199 }
9467
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
200
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
201 if (2*m.even*m.temp < m.odd*m.noise) {
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
202 mp_msg(MSGT_VFILTER, MSGL_V, "caught telecine sync!\n");
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
203 p->frame = 3;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
204 return TC_IL1;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
205 }
9467
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
206
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
207 if (p->frame < 3) {
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
208 if (m.noise > p->thres[3]) {
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
209 if (m.noise > 2*m.temp) {
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
210 mp_msg(MSGT_VFILTER, MSGL_V, "merging fields out of sequence!\n");
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
211 return TC_IL2;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
212 }
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
213 if ((m.noise > 2*pm.noise) && (m.even > p->thres[2]) && (m.odd > p->thres[2])) {
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
214 mp_msg(MSGT_VFILTER, MSGL_V, "dropping horrible interlaced frame!\n");
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
215 return TC_DROP;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
216 }
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
217 }
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
218 }
9554
12eae4cb4e56 new version of the de-telecine filter, largely rewritten. should work
rfelker
parents: 9467
diff changeset
219
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
220 switch (p->frame) {
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
221 case -1:
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
222 if (4*m.noise > 5*m.temp) {
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
223 mp_msg(MSGT_VFILTER, MSGL_V, "merging fields out of sequence!\n");
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
224 return TC_IL2;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
225 }
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
226 case 0:
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
227 case 1:
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
228 case 2:
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
229 return TC_PROG;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
230 case 3:
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
231 if ((m.even > p->thres[1]) && (m.even > m.odd) && (m.temp > m.noise)) {
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
232 mp_msg(MSGT_VFILTER, MSGL_V, "lost telecine tracking!\n");
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
233 p->frame = -1;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
234 return TC_PROG;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
235 }
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
236 return TC_IL1;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
237 case 4:
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
238 return TC_IL2;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
239 }
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
240 return 0;
9554
12eae4cb4e56 new version of the de-telecine filter, largely rewritten. should work
rfelker
parents: 9467
diff changeset
241 }
12eae4cb4e56 new version of the de-telecine filter, largely rewritten. should work
rfelker
parents: 9467
diff changeset
242
12eae4cb4e56 new version of the de-telecine filter, largely rewritten. should work
rfelker
parents: 9467
diff changeset
243 static void copy_image(mp_image_t *dmpi, mp_image_t *mpi, int field)
12eae4cb4e56 new version of the de-telecine filter, largely rewritten. should work
rfelker
parents: 9467
diff changeset
244 {
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
245 switch (field) {
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
246 case 0:
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
247 my_memcpy_pic(dmpi->planes[0], mpi->planes[0], mpi->w, mpi->h/2,
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
248 dmpi->stride[0]*2, mpi->stride[0]*2);
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
249 if (mpi->flags & MP_IMGFLAG_PLANAR) {
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
250 my_memcpy_pic(dmpi->planes[1], mpi->planes[1],
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
251 mpi->chroma_width, mpi->chroma_height/2,
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
252 dmpi->stride[1]*2, mpi->stride[1]*2);
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
253 my_memcpy_pic(dmpi->planes[2], mpi->planes[2],
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
254 mpi->chroma_width, mpi->chroma_height/2,
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
255 dmpi->stride[2]*2, mpi->stride[2]*2);
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
256 }
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
257 break;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
258 case 1:
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
259 my_memcpy_pic(dmpi->planes[0]+dmpi->stride[0],
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
260 mpi->planes[0]+mpi->stride[0], mpi->w, mpi->h/2,
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
261 dmpi->stride[0]*2, mpi->stride[0]*2);
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
262 if (mpi->flags & MP_IMGFLAG_PLANAR) {
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
263 my_memcpy_pic(dmpi->planes[1]+dmpi->stride[1],
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
264 mpi->planes[1]+mpi->stride[1],
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
265 mpi->chroma_width, mpi->chroma_height/2,
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
266 dmpi->stride[1]*2, mpi->stride[1]*2);
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
267 my_memcpy_pic(dmpi->planes[2]+dmpi->stride[2],
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
268 mpi->planes[2]+mpi->stride[2],
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
269 mpi->chroma_width, mpi->chroma_height/2,
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
270 dmpi->stride[2]*2, mpi->stride[2]*2);
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
271 }
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
272 break;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
273 case 2:
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
274 memcpy_pic(dmpi->planes[0], mpi->planes[0], mpi->w, mpi->h,
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
275 dmpi->stride[0], mpi->stride[0]);
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
276 if (mpi->flags & MP_IMGFLAG_PLANAR) {
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
277 memcpy_pic(dmpi->planes[1], mpi->planes[1],
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
278 mpi->chroma_width, mpi->chroma_height,
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
279 dmpi->stride[1], mpi->stride[1]);
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
280 memcpy_pic(dmpi->planes[2], mpi->planes[2],
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
281 mpi->chroma_width, mpi->chroma_height,
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
282 dmpi->stride[2], mpi->stride[2]);
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
283 }
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
284 break;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
285 }
9554
12eae4cb4e56 new version of the de-telecine filter, largely rewritten. should work
rfelker
parents: 9467
diff changeset
286 }
12eae4cb4e56 new version of the de-telecine filter, largely rewritten. should work
rfelker
parents: 9467
diff changeset
287
30642
a972c1a4a012 cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents: 30638
diff changeset
288 static int do_put_image(struct vf_instance *vf, mp_image_t *dmpi)
9554
12eae4cb4e56 new version of the de-telecine filter, largely rewritten. should work
rfelker
parents: 9467
diff changeset
289 {
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
290 struct vf_priv_s *p = vf->priv;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
291 int dropflag;
9554
12eae4cb4e56 new version of the de-telecine filter, largely rewritten. should work
rfelker
parents: 9467
diff changeset
292
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
293 switch (p->drop) {
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
294 default:
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
295 dropflag = 0;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
296 break;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
297 case 1:
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
298 dropflag = (++p->lastdrop >= 5);
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
299 break;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
300 case 2:
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
301 dropflag = (++p->lastdrop >= 5) && (4*p->inframes <= 5*p->outframes);
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
302 break;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
303 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 25767
diff changeset
304
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
305 if (dropflag) {
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
306 mp_msg(MSGT_VFILTER, MSGL_V, "drop! [%d/%d=%g]\n",
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
307 p->outframes, p->inframes, (float)p->outframes/p->inframes);
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
308 p->lastdrop = 0;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
309 return 0;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
310 }
9554
12eae4cb4e56 new version of the de-telecine filter, largely rewritten. should work
rfelker
parents: 9467
diff changeset
311
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
312 p->outframes++;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
313 return vf_next_put_image(vf, dmpi, MP_NOPTS_VALUE);
9467
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
314 }
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
315
30642
a972c1a4a012 cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents: 30638
diff changeset
316 static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts)
9554
12eae4cb4e56 new version of the de-telecine filter, largely rewritten. should work
rfelker
parents: 9467
diff changeset
317 {
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
318 int ret=0;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
319 mp_image_t *dmpi;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
320 struct vf_priv_s *p = vf->priv;
9554
12eae4cb4e56 new version of the de-telecine filter, largely rewritten. should work
rfelker
parents: 9467
diff changeset
321
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
322 p->inframes++;
9554
12eae4cb4e56 new version of the de-telecine filter, largely rewritten. should work
rfelker
parents: 9467
diff changeset
323
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
324 if (p->needread) dmpi = vf_get_image(vf->next, mpi->imgfmt,
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
325 MP_IMGTYPE_STATIC, MP_IMGFLAG_ACCEPT_STRIDE |
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
326 MP_IMGFLAG_PRESERVE | MP_IMGFLAG_READABLE,
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
327 mpi->width, mpi->height);
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
328 /* FIXME: is there a good way to get rid of static type? */
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
329 else dmpi = vf_get_image(vf->next, mpi->imgfmt,
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
330 MP_IMGTYPE_STATIC, MP_IMGFLAG_ACCEPT_STRIDE |
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
331 MP_IMGFLAG_PRESERVE, mpi->width, mpi->height);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 25767
diff changeset
332
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
333 switch (p->analyze(p, mpi, dmpi)) {
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
334 case TC_DROP:
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
335 /* Don't copy anything unless we'll need to read it. */
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
336 if (p->needread) copy_image(dmpi, mpi, 2);
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
337 p->lastdrop = 0;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
338 break;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
339 case TC_PROG:
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
340 /* Copy and display the whole frame. */
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
341 copy_image(dmpi, mpi, 2);
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
342 ret = do_put_image(vf, dmpi);
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
343 break;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
344 case TC_IL1:
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
345 /* Only copy bottom field unless we need to read. */
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
346 if (p->needread) copy_image(dmpi, mpi, 2);
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
347 else copy_image(dmpi, mpi, 1);
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
348 p->lastdrop = 0;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
349 break;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
350 case TC_IL2:
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
351 /* Copy top field and show frame, then copy bottom if needed. */
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
352 copy_image(dmpi, mpi, 0);
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
353 ret = do_put_image(vf, dmpi);
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
354 if (p->needread) copy_image(dmpi, mpi, 1);
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
355 break;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
356 }
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
357 return ret;
9554
12eae4cb4e56 new version of the de-telecine filter, largely rewritten. should work
rfelker
parents: 9467
diff changeset
358 }
12eae4cb4e56 new version of the de-telecine filter, largely rewritten. should work
rfelker
parents: 9467
diff changeset
359
30642
a972c1a4a012 cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents: 30638
diff changeset
360 static int query_format(struct vf_instance *vf, unsigned int fmt)
9467
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
361 {
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
362 /* FIXME - figure out which other formats work */
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
363 switch (fmt) {
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
364 case IMGFMT_YV12:
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
365 case IMGFMT_IYUV:
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
366 case IMGFMT_I420:
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
367 return vf_next_query_format(vf, fmt);
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
368 }
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
369 return 0;
9467
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
370 }
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
371
30642
a972c1a4a012 cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents: 30638
diff changeset
372 static int config(struct vf_instance *vf,
9467
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
373 int width, int height, int d_width, int d_height,
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
374 unsigned int flags, unsigned int outfmt)
9467
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
375 {
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
376 return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt);
9467
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
377 }
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
378
30642
a972c1a4a012 cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents: 30638
diff changeset
379 static void uninit(struct vf_instance *vf)
9467
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
380 {
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
381 free(vf->priv);
9467
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
382 }
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
383
9554
12eae4cb4e56 new version of the de-telecine filter, largely rewritten. should work
rfelker
parents: 9467
diff changeset
384 static struct {
33440
12e6ac943b41 Add const to match actual type of string literal that are assigned.
reimar
parents: 32702
diff changeset
385 const char *name;
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
386 int (*func)(struct vf_priv_s *p, mp_image_t *new, mp_image_t *old);
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
387 int needread;
9554
12eae4cb4e56 new version of the de-telecine filter, largely rewritten. should work
rfelker
parents: 9467
diff changeset
388 } anal_funcs[] = {
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
389 { "fixed", analyze_fixed_pattern, 0 },
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
390 { "aggressive", analyze_aggressive, 1 },
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
391 { NULL, NULL, 0 }
9554
12eae4cb4e56 new version of the de-telecine filter, largely rewritten. should work
rfelker
parents: 9467
diff changeset
392 };
12eae4cb4e56 new version of the de-telecine filter, largely rewritten. should work
rfelker
parents: 9467
diff changeset
393
12eae4cb4e56 new version of the de-telecine filter, largely rewritten. should work
rfelker
parents: 9467
diff changeset
394 #define STARTVARS if (0)
12eae4cb4e56 new version of the de-telecine filter, largely rewritten. should work
rfelker
parents: 9467
diff changeset
395 #define GETVAR(str, name, out, func) \
12eae4cb4e56 new version of the de-telecine filter, largely rewritten. should work
rfelker
parents: 9467
diff changeset
396 else if (!strncmp((str), name "=", sizeof(name))) \
12eae4cb4e56 new version of the de-telecine filter, largely rewritten. should work
rfelker
parents: 9467
diff changeset
397 (out) = (func)((str) + sizeof(name))
12eae4cb4e56 new version of the de-telecine filter, largely rewritten. should work
rfelker
parents: 9467
diff changeset
398
12eae4cb4e56 new version of the de-telecine filter, largely rewritten. should work
rfelker
parents: 9467
diff changeset
399 static void parse_var(struct vf_priv_s *p, char *var)
12eae4cb4e56 new version of the de-telecine filter, largely rewritten. should work
rfelker
parents: 9467
diff changeset
400 {
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
401 STARTVARS;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
402 GETVAR(var, "dr", p->drop, atoi);
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
403 GETVAR(var, "t0", p->thres[0], atoi);
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
404 GETVAR(var, "t1", p->thres[1], atoi);
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
405 GETVAR(var, "t2", p->thres[2], atoi);
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
406 GETVAR(var, "t3", p->thres[3], atoi);
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
407 GETVAR(var, "t4", p->thres[4], atoi);
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
408 GETVAR(var, "fr", p->frame, atoi);
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
409 GETVAR(var, "am", p->mode, atoi);
9554
12eae4cb4e56 new version of the de-telecine filter, largely rewritten. should work
rfelker
parents: 9467
diff changeset
410 }
12eae4cb4e56 new version of the de-telecine filter, largely rewritten. should work
rfelker
parents: 9467
diff changeset
411
12eae4cb4e56 new version of the de-telecine filter, largely rewritten. should work
rfelker
parents: 9467
diff changeset
412 static void parse_args(struct vf_priv_s *p, char *args)
12eae4cb4e56 new version of the de-telecine filter, largely rewritten. should work
rfelker
parents: 9467
diff changeset
413 {
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
414 char *next, *orig;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
415 for (args=orig=strdup(args); args; args=next) {
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
416 next = strchr(args, ':');
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
417 if (next) *next++ = 0;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
418 parse_var(p, args);
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
419 }
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
420 free(orig);
9554
12eae4cb4e56 new version of the de-telecine filter, largely rewritten. should work
rfelker
parents: 9467
diff changeset
421 }
12eae4cb4e56 new version of the de-telecine filter, largely rewritten. should work
rfelker
parents: 9467
diff changeset
422
30638
a7b908875c14 Rename open() vf initialization function to vf_open().
diego
parents: 30633
diff changeset
423 static int vf_open(vf_instance_t *vf, char *args)
9467
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
424 {
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
425 struct vf_priv_s *p;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
426 vf->config = config;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
427 vf->put_image = put_image;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
428 vf->query_format = query_format;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
429 vf->uninit = uninit;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
430 vf->default_reqs = VFCAP_ACCEPT_STRIDE;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
431 vf->priv = p = calloc(1, sizeof(struct vf_priv_s));
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
432 p->frame = -1;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
433 p->thres[0] = 440;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
434 p->thres[1] = 720;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
435 p->thres[2] = 2500;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
436 p->thres[3] = 2500;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
437 p->thres[4] = 800;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
438 p->drop = 0;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
439 p->mode = 1;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
440 if (args) parse_args(p, args);
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
441 p->analyze = anal_funcs[p->mode].func;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
442 p->needread = anal_funcs[p->mode].needread;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
443 return 1;
9467
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
444 }
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
445
25221
00fff9a3b735 Make all vf_info_t structs const
reimar
parents: 24602
diff changeset
446 const vf_info_t vf_info_detc = {
9467
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
447 "de-telecine filter",
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
448 "detc",
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
449 "Rich Felker",
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
450 "",
30638
a7b908875c14 Rename open() vf initialization function to vf_open().
diego
parents: 30633
diff changeset
451 vf_open,
9593
e9a2af584986 Add the new -vf option wich is the same as vop in reverse order.
albeu
parents: 9554
diff changeset
452 NULL
9467
9fae4150ec43 experimental de-telecine filter. not documented or configurable yet,
rfelker
parents:
diff changeset
453 };