2 * This file is part of MPlayer.
4 * MPlayer is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * MPlayer is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 #include "img_format.h"
30 #include "libvo/fastmemcpy.h"
36 static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts)
40 int w = (IMGFMT_IS_YUVP16(mpi->imgfmt) ? 2 : 1) * mpi->w;
41 int chroma_width = (IMGFMT_IS_YUVP16(mpi->imgfmt) ? 2 : 1) * mpi->chroma_width;
43 vf->priv->frame = (vf->priv->frame+1)%4;
45 dmpi = ff_vf_get_image(vf->next, mpi->imgfmt,
46 MP_IMGTYPE_STATIC, MP_IMGFLAG_ACCEPT_STRIDE |
47 MP_IMGFLAG_PRESERVE, mpi->width, mpi->height);
50 // 0/0 1/1 2/2 2/3 3/0
51 switch (vf->priv->frame) {
53 my_memcpy_pic(dmpi->planes[0]+dmpi->stride[0],
54 mpi->planes[0]+mpi->stride[0], w, mpi->h/2,
55 dmpi->stride[0]*2, mpi->stride[0]*2);
56 if (mpi->flags & MP_IMGFLAG_PLANAR) {
57 my_memcpy_pic(dmpi->planes[1]+dmpi->stride[1],
58 mpi->planes[1]+mpi->stride[1],
59 chroma_width, mpi->chroma_height/2,
60 dmpi->stride[1]*2, mpi->stride[1]*2);
61 my_memcpy_pic(dmpi->planes[2]+dmpi->stride[2],
62 mpi->planes[2]+mpi->stride[2],
63 chroma_width, mpi->chroma_height/2,
64 dmpi->stride[2]*2, mpi->stride[2]*2);
66 ret = ff_vf_next_put_image(vf, dmpi, MP_NOPTS_VALUE);
70 memcpy_pic(dmpi->planes[0], mpi->planes[0], w, mpi->h,
71 dmpi->stride[0], mpi->stride[0]);
72 if (mpi->flags & MP_IMGFLAG_PLANAR) {
73 memcpy_pic(dmpi->planes[1], mpi->planes[1],
74 chroma_width, mpi->chroma_height,
75 dmpi->stride[1], mpi->stride[1]);
76 memcpy_pic(dmpi->planes[2], mpi->planes[2],
77 chroma_width, mpi->chroma_height,
78 dmpi->stride[2], mpi->stride[2]);
80 return ff_vf_next_put_image(vf, dmpi, MP_NOPTS_VALUE) || ret;
82 my_memcpy_pic(dmpi->planes[0]+dmpi->stride[0],
83 mpi->planes[0]+mpi->stride[0], w, mpi->h/2,
84 dmpi->stride[0]*2, mpi->stride[0]*2);
85 if (mpi->flags & MP_IMGFLAG_PLANAR) {
86 my_memcpy_pic(dmpi->planes[1]+dmpi->stride[1],
87 mpi->planes[1]+mpi->stride[1],
88 chroma_width, mpi->chroma_height/2,
89 dmpi->stride[1]*2, mpi->stride[1]*2);
90 my_memcpy_pic(dmpi->planes[2]+dmpi->stride[2],
91 mpi->planes[2]+mpi->stride[2],
92 chroma_width, mpi->chroma_height/2,
93 dmpi->stride[2]*2, mpi->stride[2]*2);
95 ret = ff_vf_next_put_image(vf, dmpi, MP_NOPTS_VALUE);
96 my_memcpy_pic(dmpi->planes[0], mpi->planes[0], w, mpi->h/2,
97 dmpi->stride[0]*2, mpi->stride[0]*2);
98 if (mpi->flags & MP_IMGFLAG_PLANAR) {
99 my_memcpy_pic(dmpi->planes[1], mpi->planes[1],
100 chroma_width, mpi->chroma_height/2,
101 dmpi->stride[1]*2, mpi->stride[1]*2);
102 my_memcpy_pic(dmpi->planes[2], mpi->planes[2],
103 chroma_width, mpi->chroma_height/2,
104 dmpi->stride[2]*2, mpi->stride[2]*2);
112 static int query_format(struct vf_instance *vf, unsigned int fmt)
114 /* FIXME - figure out which other formats work */
119 return ff_vf_next_query_format(vf, fmt);
124 static int config(struct vf_instance *vf,
125 int width, int height, int d_width, int d_height,
126 unsigned int flags, unsigned int outfmt)
128 return ff_vf_next_config(vf,width,height,d_width,d_height,flags,outfmt);
132 static void uninit(struct vf_instance *vf)
137 static int vf_open(vf_instance_t *vf, char *args)
139 //vf->config = config;
140 vf->put_image = put_image;
141 //vf->query_format = query_format;
143 vf->default_reqs = VFCAP_ACCEPT_STRIDE;
144 vf->priv = calloc(1, sizeof(struct vf_priv_s));
146 if (args) sscanf(args, "%d", &vf->priv->frame);
151 const vf_info_t ff_vf_info_telecine = {