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