Mercurial > mplayer.hg
comparison libmpcodecs/vf_softpulldown.c @ 10510:73b3e4336cd4
Add mpeg2_flags to mp_image_t, copy flags in vd_libmpeg2.c,
and add vf_softpulldown.c.
author | ranma |
---|---|
date | Sun, 03 Aug 2003 12:09:58 +0000 |
parents | |
children | 711159267b2d |
comparison
equal
deleted
inserted
replaced
10509:d9d24093db2e | 10510:73b3e4336cd4 |
---|---|
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 #include "../libvo/sub.h" | |
14 | |
15 struct vf_priv_s { | |
16 int state; | |
17 long long in; | |
18 long long out; | |
19 }; | |
20 | |
21 static inline void *my_memcpy_pic(void * dst, void * src, int bytesPerLine, int height, int dstStride, int srcStride) | |
22 { | |
23 int i; | |
24 void *retval=dst; | |
25 | |
26 for(i=0; i<height; i++) | |
27 { | |
28 memcpy(dst, src, bytesPerLine); | |
29 src+= srcStride; | |
30 dst+= dstStride; | |
31 } | |
32 | |
33 return retval; | |
34 } | |
35 | |
36 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi) | |
37 { | |
38 mp_image_t *dmpi; | |
39 int ret = 0; | |
40 int flags = mpi->mpeg2_flags; | |
41 int state = vf->priv->state; | |
42 | |
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); | |
46 | |
47 vf->priv->in++; | |
48 | |
49 if ((state == 0 && | |
50 !(flags & MP_IMGMPEG2FLAG_TOP_FIELD_FIRST)) || | |
51 (state == 1 && | |
52 flags & MP_IMGMPEG2FLAG_TOP_FIELD_FIRST)) | |
53 mp_msg(MSGT_VFILTER, MSGL_WARN, | |
54 "softpulldown: Unexpected mpeg2 flags: state=%d top_field_first=%d repeat_first_field=%d\n", | |
55 state, | |
56 (flags & MP_IMGMPEG2FLAG_TOP_FIELD_FIRST) == 1, | |
57 (flags & MP_IMGMPEG2FLAG_REPEAT_FIRST_FIELD) == 1); | |
58 | |
59 if (state == 0) { | |
60 ret = vf_next_put_image(vf, mpi); | |
61 vf->priv->out++; | |
62 if (flags & MP_IMGMPEG2FLAG_REPEAT_FIRST_FIELD) { | |
63 my_memcpy_pic(dmpi->planes[0], | |
64 mpi->planes[0], mpi->w, mpi->h/2, | |
65 dmpi->stride[0]*2, mpi->stride[0]*2); | |
66 if (mpi->flags & MP_IMGFLAG_PLANAR) { | |
67 my_memcpy_pic(dmpi->planes[1], | |
68 mpi->planes[1], | |
69 mpi->chroma_width, | |
70 mpi->chroma_height/2, | |
71 dmpi->stride[1]*2, | |
72 mpi->stride[1]*2); | |
73 my_memcpy_pic(dmpi->planes[2], | |
74 mpi->planes[2], | |
75 mpi->chroma_width, | |
76 mpi->chroma_height/2, | |
77 dmpi->stride[2]*2, | |
78 mpi->stride[2]*2); | |
79 } | |
80 state=1; | |
81 } | |
82 } else { | |
83 my_memcpy_pic(dmpi->planes[0]+dmpi->stride[0], | |
84 mpi->planes[0]+mpi->stride[0], mpi->w, mpi->h/2, | |
85 dmpi->stride[0]*2, mpi->stride[0]*2); | |
86 if (mpi->flags & MP_IMGFLAG_PLANAR) { | |
87 my_memcpy_pic(dmpi->planes[1]+dmpi->stride[1], | |
88 mpi->planes[1]+mpi->stride[1], | |
89 mpi->chroma_width, mpi->chroma_height/2, | |
90 dmpi->stride[1]*2, mpi->stride[1]*2); | |
91 my_memcpy_pic(dmpi->planes[2]+dmpi->stride[2], | |
92 mpi->planes[2]+mpi->stride[2], | |
93 mpi->chroma_width, mpi->chroma_height/2, | |
94 dmpi->stride[2]*2, mpi->stride[2]*2); | |
95 } | |
96 ret = vf_next_put_image(vf, dmpi); | |
97 vf->priv->out++; | |
98 if (flags & MP_IMGMPEG2FLAG_REPEAT_FIRST_FIELD) { | |
99 ret |= vf_next_put_image(vf, mpi); | |
100 vf->priv->out++; | |
101 state=0; | |
102 } else { | |
103 my_memcpy_pic(dmpi->planes[0], | |
104 mpi->planes[0], mpi->w, mpi->h/2, | |
105 dmpi->stride[0]*2, mpi->stride[0]*2); | |
106 if (mpi->flags & MP_IMGFLAG_PLANAR) { | |
107 my_memcpy_pic(dmpi->planes[1], | |
108 mpi->planes[1], | |
109 mpi->chroma_width, | |
110 mpi->chroma_height/2, | |
111 dmpi->stride[1]*2, | |
112 mpi->stride[1]*2); | |
113 my_memcpy_pic(dmpi->planes[2], | |
114 mpi->planes[2], | |
115 mpi->chroma_width, | |
116 mpi->chroma_height/2, | |
117 dmpi->stride[2]*2, | |
118 mpi->stride[2]*2); | |
119 } | |
120 } | |
121 } | |
122 | |
123 vf->priv->state = state; | |
124 | |
125 return ret; | |
126 } | |
127 | |
128 static int config(struct vf_instance_s* vf, | |
129 int width, int height, int d_width, int d_height, | |
130 unsigned int flags, unsigned int outfmt) | |
131 { | |
132 return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt); | |
133 } | |
134 | |
135 static void uninit(struct vf_instance_s* vf) | |
136 { | |
137 mp_msg(MSGT_VFILTER, MSGL_INFO, "softpulldown: %lld frames in, %lld frames out\n", vf->priv->in, vf->priv->out); | |
138 free(vf->priv); | |
139 } | |
140 | |
141 static int open(vf_instance_t *vf, char* args) | |
142 { | |
143 struct vf_priv_s *p; | |
144 vf->config = config; | |
145 vf->put_image = put_image; | |
146 vf->uninit = uninit; | |
147 vf->default_reqs = VFCAP_ACCEPT_STRIDE; | |
148 vf->priv = p = calloc(1, sizeof(struct vf_priv_s)); | |
149 vf->priv->state = 0; | |
150 return 1; | |
151 } | |
152 | |
153 vf_info_t vf_info_softpulldown = { | |
154 "mpeg2 soft 3:2 pulldown", | |
155 "softpulldown", | |
156 "Tobias Diedrich", | |
157 "", | |
158 open, | |
159 NULL | |
160 }; |