Mercurial > mplayer.hg
annotate libmpcodecs/vf_lavcdeint.c @ 33259:04dc3e55cd90
Increase the maximum value of the DVB timeout to 240 seconds.
Some devices may need more time for the initial tune (e.g. firmware loading).
Let the user specify higher timeout value if there is need to.
The default remains 30 seconds.
author | iive |
---|---|
date | Sun, 01 May 2011 18:07:59 +0000 |
parents | f957f330aa6d |
children | 30f5e5cd3676 |
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 |
6859 | 19 #include <stdio.h> |
20 #include <stdlib.h> | |
21 #include <string.h> | |
22 #include <inttypes.h> | |
23 | |
17012 | 24 #include "config.h" |
25 #include "mp_msg.h" | |
26 #include "help_mp.h" | |
6859 | 27 |
28 #include "img_format.h" | |
29 #include "mp_image.h" | |
30 #include "vf.h" | |
31959
f957f330aa6d
Introduce init_avcodec function to avoid duplicated FFmpeg initializations.
diego
parents:
30642
diff
changeset
|
31 #include "vd_ffmpeg.h" |
6859 | 32 #include "libavcodec/avcodec.h" |
33 | |
34 | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26069
diff
changeset
|
35 struct vf_priv_s |
6859 | 36 { |
37 int width, height; | |
38 int pix_fmt; | |
39 }; | |
40 | |
41 /* Support for avcodec's built-in deinterlacer. | |
42 * Based on vf_lavc.c | |
43 */ | |
44 | |
45 //===========================================================================// | |
46 | |
47 | |
48 /* Convert mplayer's IMGFMT_* to avcodec's PIX_FMT_* for the supported | |
49 * IMGFMT's, and return -1 if the deinterlacer doesn't support | |
50 * that format (-1 because 0 is a valid PIX_FMT). | |
51 */ | |
52 /* The deinterlacer supports planer 4:2:0, 4:2:2, and 4:4:4 YUV */ | |
53 static int | |
54 imgfmt_to_pixfmt (int imgfmt) | |
55 { | |
56 switch(imgfmt) | |
57 { | |
58 /* I hope I got all the supported formats */ | |
59 | |
60 /* 4:2:0 */ | |
61 case IMGFMT_YV12: | |
62 case IMGFMT_I420: | |
63 case IMGFMT_IYUV: | |
64 return PIX_FMT_YUV420P; | |
65 break; | |
66 | |
6860 | 67 #if 0 |
6859 | 68 /* 4:2:2 */ |
69 case IMGFMT_UYVY: | |
70 case IMGFMT_UYNV: | |
71 case IMGFMT_Y422: | |
72 case IMGFMT_YUY2: | |
73 case IMGFMT_YUNV: | |
74 case IMGFMT_YVYU: | |
75 case IMGFMT_Y42T: | |
76 case IMGFMT_V422: | |
77 case IMGFMT_V655: | |
78 return PIX_FMT_YUV422P; | |
79 break; | |
6860 | 80 #endif |
6859 | 81 |
82 /* Are there any _planar_ YUV 4:4:4 formats? */ | |
83 | |
84 default: | |
85 return -1; | |
86 } | |
87 } | |
88 | |
89 | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26069
diff
changeset
|
90 static int |
30642
a972c1a4a012
cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents:
30638
diff
changeset
|
91 config (struct vf_instance *vf, |
6859 | 92 int width, int height, int d_width, int d_height, |
93 unsigned int flags, unsigned int outfmt) | |
94 { | |
95 struct vf_priv_s *priv = vf->priv; | |
96 | |
97 priv->pix_fmt = imgfmt_to_pixfmt(outfmt); | |
98 if(priv->pix_fmt == -1) | |
99 return 0; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26069
diff
changeset
|
100 |
6859 | 101 /* The deinterlacer will fail if this is false */ |
8787
e280692c0878
Found another 10l :-), but the filter is still broken :-(
filon
parents:
8427
diff
changeset
|
102 if ((width & 3) != 0 || (height & 3) != 0) |
6859 | 103 return 0; |
104 | |
105 /* If we get here, the deinterlacer is guaranteed not to fail */ | |
106 | |
107 priv->width = width; | |
108 priv->height = height; | |
109 | |
110 return vf_next_config(vf, | |
111 width, height, | |
112 d_width, d_height, | |
113 flags, outfmt); | |
114 } | |
115 | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26069
diff
changeset
|
116 static int |
30642
a972c1a4a012
cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents:
30638
diff
changeset
|
117 put_image (struct vf_instance *vf, mp_image_t *mpi, double pts) |
6859 | 118 { |
119 struct vf_priv_s *priv = vf->priv; | |
120 mp_image_t* dmpi; | |
6860 | 121 AVPicture pic; |
6859 | 122 AVPicture lavc_picture; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26069
diff
changeset
|
123 |
6859 | 124 lavc_picture.data[0] = mpi->planes[0]; |
125 lavc_picture.data[1] = mpi->planes[1]; | |
126 lavc_picture.data[2] = mpi->planes[2]; | |
127 lavc_picture.linesize[0] = mpi->stride[0]; | |
128 lavc_picture.linesize[1] = mpi->stride[1]; | |
129 lavc_picture.linesize[2] = mpi->stride[2]; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26069
diff
changeset
|
130 |
6860 | 131 dmpi = vf_get_image(vf->next, mpi->imgfmt, |
132 MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE, | |
133 priv->width, priv->height); | |
6859 | 134 |
6860 | 135 pic.data[0] = dmpi->planes[0]; |
136 pic.data[1] = dmpi->planes[1]; | |
137 pic.data[2] = dmpi->planes[2]; | |
138 pic.linesize[0] = dmpi->stride[0]; | |
139 pic.linesize[1] = dmpi->stride[1]; | |
140 pic.linesize[2] = dmpi->stride[2]; | |
6859 | 141 |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26069
diff
changeset
|
142 if (avpicture_deinterlace(&pic, &lavc_picture, |
6859 | 143 priv->pix_fmt, priv->width, priv->height) < 0) |
144 { | |
145 /* This should not happen -- see config() */ | |
7368 | 146 return 0; |
6859 | 147 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26069
diff
changeset
|
148 |
17906
20aca9baf5d8
passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents:
17523
diff
changeset
|
149 return vf_next_put_image(vf, dmpi, pts); |
6859 | 150 } |
151 | |
152 | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26069
diff
changeset
|
153 static int |
30642
a972c1a4a012
cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents:
30638
diff
changeset
|
154 query_format (struct vf_instance *vf, unsigned int fmt) |
6859 | 155 { |
156 if(imgfmt_to_pixfmt(fmt) == -1) | |
157 return 0; | |
158 | |
159 return vf_next_query_format(vf,fmt); | |
160 } | |
161 | |
162 | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26069
diff
changeset
|
163 static int |
30638
a7b908875c14
Rename open() vf initialization function to vf_open().
diego
parents:
30421
diff
changeset
|
164 vf_open(vf_instance_t *vf, char *args) |
6859 | 165 { |
166 /* We don't have any args */ | |
167 (void) args; | |
168 | |
169 vf->config = config; | |
170 vf->put_image = put_image; | |
171 vf->query_format = query_format; | |
172 vf->priv = malloc(sizeof(struct vf_priv_s)); | |
173 memset(vf->priv,0,sizeof(struct vf_priv_s)); | |
174 | |
175 /* This may not technically be necessary just for a deinterlace, | |
176 * but it seems like a good idea. | |
177 */ | |
31959
f957f330aa6d
Introduce init_avcodec function to avoid duplicated FFmpeg initializations.
diego
parents:
30642
diff
changeset
|
178 init_avcodec(); |
6859 | 179 |
180 return 1; | |
181 } | |
182 | |
183 | |
25221 | 184 const vf_info_t vf_info_lavcdeint = { |
6859 | 185 "libavcodec's deinterlacing filter", |
186 "lavcdeint", | |
187 "Joe Rabinoff", | |
188 "libavcodec's internal deinterlacer, in case you don't like " | |
189 "the builtin ones (invoked with -pp or -npp)", | |
30638
a7b908875c14
Rename open() vf initialization function to vf_open().
diego
parents:
30421
diff
changeset
|
190 vf_open, |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
8787
diff
changeset
|
191 NULL |
6859 | 192 }; |
193 | |
194 | |
195 //===========================================================================// |