Mercurial > mplayer.hg
annotate libmpcodecs/vf_lavcdeint.c @ 25944:8a1c062707ff
Do not uselessly erase background, OpenGL will take care of drawing everything.
author | reimar |
---|---|
date | Sun, 10 Feb 2008 19:47:54 +0000 |
parents | 00fff9a3b735 |
children | afa125da85cf |
rev | line source |
---|---|
6859 | 1 #include <stdio.h> |
2 #include <stdlib.h> | |
3 #include <string.h> | |
4 #include <inttypes.h> | |
5 | |
17012 | 6 #include "config.h" |
7 #include "mp_msg.h" | |
8 #include "help_mp.h" | |
6859 | 9 |
10 #include "img_format.h" | |
11 #include "mp_image.h" | |
12 #include "vf.h" | |
13 | |
14 #ifdef USE_LIBAVCODEC_SO | |
7004 | 15 #include <ffmpeg/avcodec.h> |
6859 | 16 #else |
17 #include "libavcodec/avcodec.h" | |
18 #endif | |
19 | |
20 extern int avcodec_inited; | |
21 | |
22 struct vf_priv_s | |
23 { | |
24 int width, height; | |
25 int pix_fmt; | |
26 }; | |
27 | |
28 /* Support for avcodec's built-in deinterlacer. | |
29 * Based on vf_lavc.c | |
30 */ | |
31 | |
32 //===========================================================================// | |
33 | |
34 | |
35 /* Convert mplayer's IMGFMT_* to avcodec's PIX_FMT_* for the supported | |
36 * IMGFMT's, and return -1 if the deinterlacer doesn't support | |
37 * that format (-1 because 0 is a valid PIX_FMT). | |
38 */ | |
39 /* The deinterlacer supports planer 4:2:0, 4:2:2, and 4:4:4 YUV */ | |
40 static int | |
41 imgfmt_to_pixfmt (int imgfmt) | |
42 { | |
43 switch(imgfmt) | |
44 { | |
45 /* I hope I got all the supported formats */ | |
46 | |
47 /* 4:2:0 */ | |
48 case IMGFMT_YV12: | |
49 case IMGFMT_I420: | |
50 case IMGFMT_IYUV: | |
51 return PIX_FMT_YUV420P; | |
52 break; | |
53 | |
6860 | 54 #if 0 |
6859 | 55 /* 4:2:2 */ |
56 case IMGFMT_UYVY: | |
57 case IMGFMT_UYNV: | |
58 case IMGFMT_Y422: | |
59 case IMGFMT_YUY2: | |
60 case IMGFMT_YUNV: | |
61 case IMGFMT_YVYU: | |
62 case IMGFMT_Y42T: | |
63 case IMGFMT_V422: | |
64 case IMGFMT_V655: | |
65 return PIX_FMT_YUV422P; | |
66 break; | |
6860 | 67 #endif |
6859 | 68 |
69 /* Are there any _planar_ YUV 4:4:4 formats? */ | |
70 | |
71 default: | |
72 return -1; | |
73 } | |
74 } | |
75 | |
76 | |
77 static int | |
78 config (struct vf_instance_s* vf, | |
79 int width, int height, int d_width, int d_height, | |
80 unsigned int flags, unsigned int outfmt) | |
81 { | |
82 struct vf_priv_s *priv = vf->priv; | |
83 | |
84 priv->pix_fmt = imgfmt_to_pixfmt(outfmt); | |
85 if(priv->pix_fmt == -1) | |
86 return 0; | |
87 | |
88 /* The deinterlacer will fail if this is false */ | |
8787
e280692c0878
Found another 10l :-), but the filter is still broken :-(
filon
parents:
8427
diff
changeset
|
89 if ((width & 3) != 0 || (height & 3) != 0) |
6859 | 90 return 0; |
91 | |
92 /* If we get here, the deinterlacer is guaranteed not to fail */ | |
93 | |
94 priv->width = width; | |
95 priv->height = height; | |
96 | |
97 return vf_next_config(vf, | |
98 width, height, | |
99 d_width, d_height, | |
100 flags, outfmt); | |
101 } | |
102 | |
7368 | 103 static int |
17906
20aca9baf5d8
passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents:
17523
diff
changeset
|
104 put_image (struct vf_instance_s* vf, mp_image_t *mpi, double pts) |
6859 | 105 { |
106 struct vf_priv_s *priv = vf->priv; | |
107 mp_image_t* dmpi; | |
6860 | 108 AVPicture pic; |
6859 | 109 AVPicture lavc_picture; |
110 | |
111 lavc_picture.data[0] = mpi->planes[0]; | |
112 lavc_picture.data[1] = mpi->planes[1]; | |
113 lavc_picture.data[2] = mpi->planes[2]; | |
114 lavc_picture.linesize[0] = mpi->stride[0]; | |
115 lavc_picture.linesize[1] = mpi->stride[1]; | |
116 lavc_picture.linesize[2] = mpi->stride[2]; | |
117 | |
6860 | 118 dmpi = vf_get_image(vf->next, mpi->imgfmt, |
119 MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE, | |
120 priv->width, priv->height); | |
6859 | 121 |
6860 | 122 pic.data[0] = dmpi->planes[0]; |
123 pic.data[1] = dmpi->planes[1]; | |
124 pic.data[2] = dmpi->planes[2]; | |
125 pic.linesize[0] = dmpi->stride[0]; | |
126 pic.linesize[1] = dmpi->stride[1]; | |
127 pic.linesize[2] = dmpi->stride[2]; | |
6859 | 128 |
6860 | 129 if (avpicture_deinterlace(&pic, &lavc_picture, |
6859 | 130 priv->pix_fmt, priv->width, priv->height) < 0) |
131 { | |
132 /* This should not happen -- see config() */ | |
7368 | 133 return 0; |
6859 | 134 } |
135 | |
17906
20aca9baf5d8
passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents:
17523
diff
changeset
|
136 return vf_next_put_image(vf, dmpi, pts); |
6859 | 137 } |
138 | |
139 | |
140 static int | |
141 query_format (struct vf_instance_s* vf, unsigned int fmt) | |
142 { | |
143 if(imgfmt_to_pixfmt(fmt) == -1) | |
144 return 0; | |
145 | |
146 return vf_next_query_format(vf,fmt); | |
147 } | |
148 | |
149 | |
150 static int | |
151 open (vf_instance_t *vf, char* args) | |
152 { | |
153 /* We don't have any args */ | |
154 (void) args; | |
155 | |
156 vf->config = config; | |
157 vf->put_image = put_image; | |
158 vf->query_format = query_format; | |
159 vf->priv = malloc(sizeof(struct vf_priv_s)); | |
160 memset(vf->priv,0,sizeof(struct vf_priv_s)); | |
161 | |
162 /* This may not technically be necessary just for a deinterlace, | |
163 * but it seems like a good idea. | |
164 */ | |
165 if(!avcodec_inited) | |
166 { | |
167 avcodec_init(); | |
168 avcodec_register_all(); | |
169 avcodec_inited=1; | |
170 } | |
171 | |
172 return 1; | |
173 } | |
174 | |
175 | |
25221 | 176 const vf_info_t vf_info_lavcdeint = { |
6859 | 177 "libavcodec's deinterlacing filter", |
178 "lavcdeint", | |
179 "Joe Rabinoff", | |
180 "libavcodec's internal deinterlacer, in case you don't like " | |
181 "the builtin ones (invoked with -pp or -npp)", | |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
8787
diff
changeset
|
182 open, |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
8787
diff
changeset
|
183 NULL |
6859 | 184 }; |
185 | |
186 | |
187 //===========================================================================// |