9468
|
1 #include <stdio.h>
|
|
2 #include <stdlib.h>
|
|
3 #include <string.h>
|
|
4
|
|
5 #include "../config.h"
|
|
6 #include "../mp_msg.h"
|
|
7
|
|
8 #include "img_format.h"
|
|
9 #include "mp_image.h"
|
|
10 #include "vf.h"
|
|
11
|
|
12 #include "../libvo/fastmemcpy.h"
|
|
13
|
|
14 struct vf_priv_s {
|
|
15 int frame;
|
|
16 };
|
|
17
|
|
18 static inline void *my_memcpy_pic(void * dst, void * src, int bytesPerLine, int height, int dstStride, int srcStride)
|
|
19 {
|
|
20 int i;
|
|
21 void *retval=dst;
|
|
22
|
|
23 for(i=0; i<height; i++)
|
|
24 {
|
|
25 memcpy(dst, src, bytesPerLine);
|
|
26 src+= srcStride;
|
|
27 dst+= dstStride;
|
|
28 }
|
|
29
|
|
30 return retval;
|
|
31 }
|
|
32
|
|
33 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi)
|
|
34 {
|
|
35 mp_image_t *dmpi;
|
|
36 int ret;
|
|
37
|
|
38 vf->priv->frame = (vf->priv->frame+1)%4;
|
|
39
|
|
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);
|
|
43
|
|
44 ret = 0;
|
|
45 // 0/0 1/1 2/2 2/3 3/0
|
|
46 switch (vf->priv->frame) {
|
|
47 case 0:
|
|
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);
|
|
60 }
|
|
61 ret = vf_next_put_image(vf, dmpi);
|
|
62 case 1:
|
|
63 case 2:
|
|
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]);
|
|
73 }
|
|
74 return vf_next_put_image(vf, dmpi) || ret;
|
|
75 case 3:
|
|
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);
|
|
88 }
|
|
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);
|
|
99 }
|
|
100 return ret;
|
|
101 }
|
|
102 return 0;
|
|
103 }
|
|
104
|
|
105 static int query_format(struct vf_instance_s* vf, unsigned int fmt)
|
|
106 {
|
|
107 /* FIXME - figure out which other formats work */
|
|
108 switch (fmt) {
|
|
109 case IMGFMT_YV12:
|
|
110 case IMGFMT_IYUV:
|
|
111 case IMGFMT_I420:
|
|
112 return vf_next_query_format(vf, fmt);
|
|
113 }
|
|
114 return 0;
|
|
115 }
|
|
116
|
|
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)
|
|
120 {
|
|
121 return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt);
|
|
122 }
|
|
123
|
|
124 static void uninit(struct vf_instance_s* vf)
|
|
125 {
|
|
126 free(vf->priv);
|
|
127 }
|
|
128
|
|
129 static int open(vf_instance_t *vf, char* args)
|
|
130 {
|
|
131 //vf->config = config;
|
|
132 vf->put_image = put_image;
|
|
133 //vf->query_format = query_format;
|
|
134 vf->uninit = uninit;
|
|
135 vf->default_reqs = VFCAP_ACCEPT_STRIDE;
|
|
136 vf->priv = calloc(1, sizeof(struct vf_priv_s));
|
|
137 vf->priv->frame = 1;
|
|
138 if (args) sscanf(args, "%d", &vf->priv->frame);
|
|
139 vf->priv->frame--;
|
|
140 return 1;
|
|
141 }
|
|
142
|
|
143 vf_info_t vf_info_telecine = {
|
|
144 "telecine filter",
|
|
145 "telecine",
|
|
146 "Rich Felker",
|
|
147 "",
|
9593
|
148 open,
|
|
149 NULL
|
9468
|
150 };
|
|
151
|
|
152
|