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