8 #include "img_format.h"
12 #include "../libvo/fastmemcpy.h"
18 static inline void *my_memcpy_pic(void * dst
, void * src
, int bytesPerLine
, int height
, int dstStride
, int srcStride
)
23 for(i
=0; i
<height
; i
++)
25 memcpy(dst
, src
, bytesPerLine
);
33 static int put_image(struct vf_instance_s
* vf
, mp_image_t
*mpi
)
38 vf
->priv
->frame
= (vf
->priv
->frame
+1)%4;
40 dmpi
= vf_get_image(vf
->next
, mpi
->imgfmt
,
41 MP_IMGTYPE_STATIC
, MP_IMGFLAG_ACCEPT_STRIDE
|
42 MP_IMGFLAG_PRESERVE
, mpi
->width
, mpi
->height
);
45 // 0/0 1/1 2/2 2/3 3/0
46 switch (vf
->priv
->frame
) {
48 my_memcpy_pic(dmpi
->planes
[0]+dmpi
->stride
[0],
49 mpi
->planes
[0]+mpi
->stride
[0], mpi
->w
, mpi
->h
/2,
50 dmpi
->stride
[0]*2, mpi
->stride
[0]*2);
51 if (mpi
->flags
& MP_IMGFLAG_PLANAR
) {
52 my_memcpy_pic(dmpi
->planes
[1]+dmpi
->stride
[1],
53 mpi
->planes
[1]+mpi
->stride
[1],
54 mpi
->chroma_width
, mpi
->chroma_height
/2,
55 dmpi
->stride
[1]*2, mpi
->stride
[1]*2);
56 my_memcpy_pic(dmpi
->planes
[2]+dmpi
->stride
[2],
57 mpi
->planes
[2]+mpi
->stride
[2],
58 mpi
->chroma_width
, mpi
->chroma_height
/2,
59 dmpi
->stride
[2]*2, mpi
->stride
[2]*2);
61 ret
= vf_next_put_image(vf
, dmpi
);
64 memcpy_pic(dmpi
->planes
[0], mpi
->planes
[0], mpi
->w
, mpi
->h
,
65 dmpi
->stride
[0], mpi
->stride
[0]);
66 if (mpi
->flags
& MP_IMGFLAG_PLANAR
) {
67 memcpy_pic(dmpi
->planes
[1], mpi
->planes
[1],
68 mpi
->chroma_width
, mpi
->chroma_height
,
69 dmpi
->stride
[1], mpi
->stride
[1]);
70 memcpy_pic(dmpi
->planes
[2], mpi
->planes
[2],
71 mpi
->chroma_width
, mpi
->chroma_height
,
72 dmpi
->stride
[2], mpi
->stride
[2]);
74 return vf_next_put_image(vf
, dmpi
) || ret
;
76 my_memcpy_pic(dmpi
->planes
[0]+dmpi
->stride
[0],
77 mpi
->planes
[0]+mpi
->stride
[0], mpi
->w
, mpi
->h
/2,
78 dmpi
->stride
[0]*2, mpi
->stride
[0]*2);
79 if (mpi
->flags
& MP_IMGFLAG_PLANAR
) {
80 my_memcpy_pic(dmpi
->planes
[1]+dmpi
->stride
[1],
81 mpi
->planes
[1]+mpi
->stride
[1],
82 mpi
->chroma_width
, mpi
->chroma_height
/2,
83 dmpi
->stride
[1]*2, mpi
->stride
[1]*2);
84 my_memcpy_pic(dmpi
->planes
[2]+dmpi
->stride
[2],
85 mpi
->planes
[2]+mpi
->stride
[2],
86 mpi
->chroma_width
, mpi
->chroma_height
/2,
87 dmpi
->stride
[2]*2, mpi
->stride
[2]*2);
89 ret
= vf_next_put_image(vf
, dmpi
);
90 my_memcpy_pic(dmpi
->planes
[0], mpi
->planes
[0], mpi
->w
, mpi
->h
/2,
91 dmpi
->stride
[0]*2, mpi
->stride
[0]*2);
92 if (mpi
->flags
& MP_IMGFLAG_PLANAR
) {
93 my_memcpy_pic(dmpi
->planes
[1], mpi
->planes
[1],
94 mpi
->chroma_width
, mpi
->chroma_height
/2,
95 dmpi
->stride
[1]*2, mpi
->stride
[1]*2);
96 my_memcpy_pic(dmpi
->planes
[2], mpi
->planes
[2],
97 mpi
->chroma_width
, mpi
->chroma_height
/2,
98 dmpi
->stride
[2]*2, mpi
->stride
[2]*2);
105 static int query_format(struct vf_instance_s
* vf
, unsigned int fmt
)
107 /* FIXME - figure out which other formats work */
112 return vf_next_query_format(vf
, fmt
);
117 static int config(struct vf_instance_s
* vf
,
118 int width
, int height
, int d_width
, int d_height
,
119 unsigned int flags
, unsigned int outfmt
)
121 return vf_next_config(vf
,width
,height
,d_width
,d_height
,flags
,outfmt
);
124 static void uninit(struct vf_instance_s
* vf
)
129 static int open(vf_instance_t
*vf
, char* args
)
131 //vf->config = config;
132 vf
->put_image
= put_image
;
133 //vf->query_format = query_format;
135 vf
->default_reqs
= VFCAP_ACCEPT_STRIDE
;
136 vf
->priv
= calloc(1, sizeof(struct vf_priv_s
));
138 if (args
) sscanf(args
, "%d", &vf
->priv
->frame
);
143 vf_info_t vf_info_telecine
= {