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