12 #include "img_format.h"
16 //#include "libvo/fastmemcpy.h"
18 #ifdef USE_LIBAVCODEC_SO
19 #include <ffmpeg/avcodec.h>
21 #include "libavcodec/avcodec.h"
24 extern int avcodec_inited
;
32 /* Support for avcodec's built-in deinterlacer.
36 //===========================================================================//
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).
43 /* The deinterlacer supports planer 4:2:0, 4:2:2, and 4:4:4 YUV */
45 imgfmt_to_pixfmt (int imgfmt
)
49 /* I hope I got all the supported formats */
55 return PIX_FMT_YUV420P
;
69 return PIX_FMT_YUV422P
;
73 /* Are there any _planar_ YUV 4:4:4 formats? */
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
)
86 struct vf_priv_s
*priv
= vf
->priv
;
88 priv
->pix_fmt
= imgfmt_to_pixfmt(outfmt
);
89 if(priv
->pix_fmt
== -1)
92 /* The deinterlacer will fail if this is false */
93 if ((width
& 3) != 0 || (height
& 3) != 0)
96 /* If we get here, the deinterlacer is guaranteed not to fail */
99 priv
->height
= height
;
101 return vf_next_config(vf
,
108 put_image (struct vf_instance_s
* vf
, mp_image_t
*mpi
)
110 struct vf_priv_s
*priv
= vf
->priv
;
113 AVPicture lavc_picture
;
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];
122 dmpi
= vf_get_image(vf
->next
, mpi
->imgfmt
,
123 MP_IMGTYPE_TEMP
, MP_IMGFLAG_ACCEPT_STRIDE
,
124 priv
->width
, priv
->height
);
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];
133 if (avpicture_deinterlace(&pic
, &lavc_picture
,
134 priv
->pix_fmt
, priv
->width
, priv
->height
) < 0)
136 /* This should not happen -- see config() */
140 return vf_next_put_image(vf
, dmpi
);
145 query_format (struct vf_instance_s
* vf
, unsigned int fmt
)
147 if(imgfmt_to_pixfmt(fmt
) == -1)
150 return vf_next_query_format(vf
,fmt
);
155 open (vf_instance_t
*vf
, char* args
)
157 /* We don't have any args */
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
));
166 /* This may not technically be necessary just for a deinterlace,
167 * but it seems like a good idea.
172 avcodec_register_all();
180 vf_info_t vf_info_lavcdeint
= {
181 "libavcodec's deinterlacing filter",
184 "libavcodec's internal deinterlacer, in case you don't like "
185 "the builtin ones (invoked with -pp or -npp)",
191 //===========================================================================//
193 #endif /* USE_LIBAVCODEC */