8 #include "img_format.h"
12 #include "libvo/fastmemcpy.h"
13 #include "libvo/sub.h"
21 static inline void *my_memcpy_pic(void * dst
, void * src
, int bytesPerLine
, int height
, int dstStride
, int srcStride
)
26 for(i
=0; i
<height
; i
++)
28 memcpy(dst
, src
, bytesPerLine
);
36 static int put_image(struct vf_instance_s
* vf
, mp_image_t
*mpi
, double pts
)
40 int flags
= mpi
->fields
;
41 int state
= vf
->priv
->state
;
43 dmpi
= vf_get_image(vf
->next
, mpi
->imgfmt
,
44 MP_IMGTYPE_STATIC
, MP_IMGFLAG_ACCEPT_STRIDE
|
45 MP_IMGFLAG_PRESERVE
, mpi
->width
, mpi
->height
);
50 !(flags
& MP_IMGFIELD_TOP_FIRST
)) ||
52 flags
& MP_IMGFIELD_TOP_FIRST
)) {
53 mp_msg(MSGT_VFILTER
, MSGL_WARN
,
54 "softpulldown: Unexpected field flags: state=%d top_field_first=%d repeat_first_field=%d\n",
56 (flags
& MP_IMGFIELD_TOP_FIRST
) != 0,
57 (flags
& MP_IMGFIELD_REPEAT_FIRST
) != 0);
62 ret
= vf_next_put_image(vf
, mpi
, MP_NOPTS_VALUE
);
64 if (flags
& MP_IMGFIELD_REPEAT_FIRST
) {
65 my_memcpy_pic(dmpi
->planes
[0],
66 mpi
->planes
[0], mpi
->w
, mpi
->h
/2,
67 dmpi
->stride
[0]*2, mpi
->stride
[0]*2);
68 if (mpi
->flags
& MP_IMGFLAG_PLANAR
) {
69 my_memcpy_pic(dmpi
->planes
[1],
75 my_memcpy_pic(dmpi
->planes
[2],
85 my_memcpy_pic(dmpi
->planes
[0]+dmpi
->stride
[0],
86 mpi
->planes
[0]+mpi
->stride
[0], mpi
->w
, mpi
->h
/2,
87 dmpi
->stride
[0]*2, mpi
->stride
[0]*2);
88 if (mpi
->flags
& MP_IMGFLAG_PLANAR
) {
89 my_memcpy_pic(dmpi
->planes
[1]+dmpi
->stride
[1],
90 mpi
->planes
[1]+mpi
->stride
[1],
91 mpi
->chroma_width
, mpi
->chroma_height
/2,
92 dmpi
->stride
[1]*2, mpi
->stride
[1]*2);
93 my_memcpy_pic(dmpi
->planes
[2]+dmpi
->stride
[2],
94 mpi
->planes
[2]+mpi
->stride
[2],
95 mpi
->chroma_width
, mpi
->chroma_height
/2,
96 dmpi
->stride
[2]*2, mpi
->stride
[2]*2);
98 ret
= vf_next_put_image(vf
, dmpi
, MP_NOPTS_VALUE
);
100 if (flags
& MP_IMGFIELD_REPEAT_FIRST
) {
101 ret
|= vf_next_put_image(vf
, mpi
, MP_NOPTS_VALUE
);
105 my_memcpy_pic(dmpi
->planes
[0],
106 mpi
->planes
[0], mpi
->w
, mpi
->h
/2,
107 dmpi
->stride
[0]*2, mpi
->stride
[0]*2);
108 if (mpi
->flags
& MP_IMGFLAG_PLANAR
) {
109 my_memcpy_pic(dmpi
->planes
[1],
112 mpi
->chroma_height
/2,
115 my_memcpy_pic(dmpi
->planes
[2],
118 mpi
->chroma_height
/2,
125 vf
->priv
->state
= state
;
130 static int config(struct vf_instance_s
* vf
,
131 int width
, int height
, int d_width
, int d_height
,
132 unsigned int flags
, unsigned int outfmt
)
134 return vf_next_config(vf
,width
,height
,d_width
,d_height
,flags
,outfmt
);
137 static void uninit(struct vf_instance_s
* vf
)
139 mp_msg(MSGT_VFILTER
, MSGL_INFO
, "softpulldown: %lld frames in, %lld frames out\n", vf
->priv
->in
, vf
->priv
->out
);
143 static int open(vf_instance_t
*vf
, char* args
)
147 vf
->put_image
= put_image
;
149 vf
->default_reqs
= VFCAP_ACCEPT_STRIDE
;
150 vf
->priv
= p
= calloc(1, sizeof(struct vf_priv_s
));
155 vf_info_t vf_info_softpulldown
= {
156 "mpeg2 soft 3:2 pulldown",
158 "Tobias Diedrich <ranma+mplayer@tdiedrich.de>",