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"
38 static int put_image(struct vf_instance
* vf
, mp_image_t
*mpi
, double pts
)
42 int flags
= mpi
->fields
;
43 int state
= vf
->priv
->state
;
45 dmpi
= vf_get_image(vf
->next
, mpi
->imgfmt
,
46 MP_IMGTYPE_STATIC
, MP_IMGFLAG_ACCEPT_STRIDE
|
47 MP_IMGFLAG_PRESERVE
, mpi
->width
, mpi
->height
);
52 !(flags
& MP_IMGFIELD_TOP_FIRST
)) ||
54 flags
& MP_IMGFIELD_TOP_FIRST
)) {
55 mp_msg(MSGT_VFILTER
, MSGL_WARN
,
56 "softpulldown: Unexpected field flags: state=%d top_field_first=%d repeat_first_field=%d\n",
58 (flags
& MP_IMGFIELD_TOP_FIRST
) != 0,
59 (flags
& MP_IMGFIELD_REPEAT_FIRST
) != 0);
64 ret
= vf_next_put_image(vf
, mpi
, MP_NOPTS_VALUE
);
66 if (flags
& MP_IMGFIELD_REPEAT_FIRST
) {
67 my_memcpy_pic(dmpi
->planes
[0],
68 mpi
->planes
[0], mpi
->w
, mpi
->h
/2,
69 dmpi
->stride
[0]*2, mpi
->stride
[0]*2);
70 if (mpi
->flags
& MP_IMGFLAG_PLANAR
) {
71 my_memcpy_pic(dmpi
->planes
[1],
77 my_memcpy_pic(dmpi
->planes
[2],
87 my_memcpy_pic(dmpi
->planes
[0]+dmpi
->stride
[0],
88 mpi
->planes
[0]+mpi
->stride
[0], mpi
->w
, mpi
->h
/2,
89 dmpi
->stride
[0]*2, mpi
->stride
[0]*2);
90 if (mpi
->flags
& MP_IMGFLAG_PLANAR
) {
91 my_memcpy_pic(dmpi
->planes
[1]+dmpi
->stride
[1],
92 mpi
->planes
[1]+mpi
->stride
[1],
93 mpi
->chroma_width
, mpi
->chroma_height
/2,
94 dmpi
->stride
[1]*2, mpi
->stride
[1]*2);
95 my_memcpy_pic(dmpi
->planes
[2]+dmpi
->stride
[2],
96 mpi
->planes
[2]+mpi
->stride
[2],
97 mpi
->chroma_width
, mpi
->chroma_height
/2,
98 dmpi
->stride
[2]*2, mpi
->stride
[2]*2);
100 ret
= vf_next_put_image(vf
, dmpi
, MP_NOPTS_VALUE
);
102 if (flags
& MP_IMGFIELD_REPEAT_FIRST
) {
103 ret
|= vf_next_put_image(vf
, mpi
, MP_NOPTS_VALUE
);
107 my_memcpy_pic(dmpi
->planes
[0],
108 mpi
->planes
[0], mpi
->w
, mpi
->h
/2,
109 dmpi
->stride
[0]*2, mpi
->stride
[0]*2);
110 if (mpi
->flags
& MP_IMGFLAG_PLANAR
) {
111 my_memcpy_pic(dmpi
->planes
[1],
114 mpi
->chroma_height
/2,
117 my_memcpy_pic(dmpi
->planes
[2],
120 mpi
->chroma_height
/2,
127 vf
->priv
->state
= state
;
132 static int config(struct vf_instance
* vf
,
133 int width
, int height
, int d_width
, int d_height
,
134 unsigned int flags
, unsigned int outfmt
)
136 return vf_next_config(vf
,width
,height
,d_width
,d_height
,flags
,outfmt
);
139 static void uninit(struct vf_instance
* vf
)
141 mp_msg(MSGT_VFILTER
, MSGL_INFO
, "softpulldown: %lld frames in, %lld frames out\n", vf
->priv
->in
, vf
->priv
->out
);
145 static int vf_open(vf_instance_t
*vf
, char *args
)
149 vf
->put_image
= put_image
;
151 vf
->default_reqs
= VFCAP_ACCEPT_STRIDE
;
152 vf
->priv
= p
= calloc(1, sizeof(struct vf_priv_s
));
157 const vf_info_t vf_info_softpulldown
= {
158 "mpeg2 soft 3:2 pulldown",
160 "Tobias Diedrich <ranma+mplayer@tdiedrich.de>",