Mercurial > mplayer.hg
comparison libmpcodecs/vf_stereo3d.c @ 32538:28f08e7c2a0a
Adjust d_height instead of bad ad-hoc scaling.
Patch by Endre Kollr [taxy443 gmail com]
author | reimar |
---|---|
date | Sun, 14 Nov 2010 15:24:12 +0000 |
parents | 7ec524214684 |
children | 8341f48adbc5 |
comparison
equal
deleted
inserted
replaced
32537:8fa2f43cb760 | 32538:28f08e7c2a0a |
---|---|
64 unsigned int width; | 64 unsigned int width; |
65 unsigned int height; | 65 unsigned int height; |
66 unsigned int off_left; | 66 unsigned int off_left; |
67 unsigned int off_right; | 67 unsigned int off_right; |
68 unsigned int stride; | 68 unsigned int stride; |
69 unsigned int hres; | |
70 } component; | 69 } component; |
71 | 70 |
72 //==global variables==// | 71 //==global variables==// |
73 static const int ana_coeff[10][3][6] = { | 72 static const int ana_coeff[10][3][6] = { |
74 {{19595, 38470, 7471, 0, 0, 0}, //ANAGLYPH_RC_GRAY | 73 {{19595, 38470, 7471, 0, 0, 0}, //ANAGLYPH_RC_GRAY |
135 //default input values | 134 //default input values |
136 vf->priv->width = width; | 135 vf->priv->width = width; |
137 vf->priv->height = height; | 136 vf->priv->height = height; |
138 vf->priv->in.width = width; | 137 vf->priv->in.width = width; |
139 vf->priv->in.height = height; | 138 vf->priv->in.height = height; |
140 vf->priv->in.hres = 1; | |
141 vf->priv->in.off_left = 0; | 139 vf->priv->in.off_left = 0; |
142 vf->priv->in.off_right = 0; | 140 vf->priv->in.off_right = 0; |
143 vf->priv->in.stride = vf->priv->width * 3; | 141 vf->priv->in.stride = vf->priv->width * 3; |
144 | 142 |
145 //check input format | 143 //check input format |
152 case SIDE_BY_SIDE_RL: | 150 case SIDE_BY_SIDE_RL: |
153 vf->priv->width = width / 2; | 151 vf->priv->width = width / 2; |
154 vf->priv->in.off_left = vf->priv->width * 3; | 152 vf->priv->in.off_left = vf->priv->width * 3; |
155 vf->priv->in.stride = vf->priv->width * 6; | 153 vf->priv->in.stride = vf->priv->width * 6; |
156 break; | 154 break; |
155 case ABOVE_BELOW_2_LR: | |
156 d_height *= 2; | |
157 case ABOVE_BELOW_LR: | 157 case ABOVE_BELOW_LR: |
158 vf->priv->height = height / 2; | 158 vf->priv->height = height / 2; |
159 vf->priv->in.off_right = vf->priv->width * vf->priv->height * 3; | 159 vf->priv->in.off_right = vf->priv->width * vf->priv->height * 3; |
160 break; | 160 break; |
161 case ABOVE_BELOW_2_RL: | |
162 d_height *= 2; | |
161 case ABOVE_BELOW_RL: | 163 case ABOVE_BELOW_RL: |
162 vf->priv->height = height / 2; | 164 vf->priv->height = height / 2; |
163 vf->priv->in.off_left = vf->priv->width * vf->priv->height * 3; | 165 vf->priv->in.off_left = vf->priv->width * vf->priv->height * 3; |
164 break; | |
165 case ABOVE_BELOW_2_LR: | |
166 vf->priv->in.hres = 2; | |
167 vf->priv->in.off_right = vf->priv->width * vf->priv->height / 2 * 3; | |
168 break; | |
169 case ABOVE_BELOW_2_RL: | |
170 vf->priv->in.hres = 2; | |
171 vf->priv->in.off_left = vf->priv->width * vf->priv->height / 2 * 3; | |
172 break; | 166 break; |
173 default: | 167 default: |
174 mp_msg(MSGT_VFILTER, MSGL_WARN, | 168 mp_msg(MSGT_VFILTER, MSGL_WARN, |
175 "[stereo3d] stereo format of input is not supported\n"); | 169 "[stereo3d] stereo format of input is not supported\n"); |
176 return 0; | 170 return 0; |
177 break; | 171 break; |
178 } | 172 } |
179 //default output values | 173 //default output values |
180 vf->priv->out.width = vf->priv->width; | 174 vf->priv->out.width = vf->priv->width; |
181 vf->priv->out.height = vf->priv->height; | 175 vf->priv->out.height = vf->priv->height; |
182 vf->priv->out.hres = 1; | |
183 vf->priv->out.off_left = 0; | 176 vf->priv->out.off_left = 0; |
184 vf->priv->out.off_right = 0; | 177 vf->priv->out.off_right = 0; |
185 vf->priv->out.stride = vf->priv->width * 3; | 178 vf->priv->out.stride = vf->priv->width * 3; |
186 | 179 |
187 //check output format | 180 //check output format |
207 case SIDE_BY_SIDE_RL: | 200 case SIDE_BY_SIDE_RL: |
208 vf->priv->out.width = vf->priv->width * 2; | 201 vf->priv->out.width = vf->priv->width * 2; |
209 vf->priv->out.off_left = vf->priv->width * 3; | 202 vf->priv->out.off_left = vf->priv->width * 3; |
210 vf->priv->out.stride = vf->priv->width * 6; | 203 vf->priv->out.stride = vf->priv->width * 6; |
211 break; | 204 break; |
205 case ABOVE_BELOW_2_LR: | |
206 d_height /= 2; | |
212 case ABOVE_BELOW_LR: | 207 case ABOVE_BELOW_LR: |
213 vf->priv->out.height = vf->priv->height * 2; | 208 vf->priv->out.height = vf->priv->height * 2; |
214 vf->priv->out.off_right = vf->priv->width * vf->priv->height * 3; | 209 vf->priv->out.off_right = vf->priv->width * vf->priv->height * 3; |
215 break; | 210 break; |
211 case ABOVE_BELOW_2_RL: | |
212 d_height /= 2; | |
216 case ABOVE_BELOW_RL: | 213 case ABOVE_BELOW_RL: |
217 vf->priv->out.height = vf->priv->height * 2; | 214 vf->priv->out.height = vf->priv->height * 2; |
218 vf->priv->out.off_left = vf->priv->width * vf->priv->height * 3; | 215 vf->priv->out.off_left = vf->priv->width * vf->priv->height * 3; |
219 break; | |
220 case ABOVE_BELOW_2_LR: | |
221 vf->priv->out.hres = 2; | |
222 vf->priv->out.off_right = vf->priv->width * vf->priv->height / 2 * 3; | |
223 break; | |
224 case ABOVE_BELOW_2_RL: | |
225 vf->priv->out.hres = 2; | |
226 vf->priv->out.off_left = vf->priv->width * vf->priv->height / 2 * 3; | |
227 break; | 216 break; |
228 case MONO_R: | 217 case MONO_R: |
229 //same as MONO_L only needs switching of input offsets | 218 //same as MONO_L only needs switching of input offsets |
230 vf->priv->in.off_left = vf->priv->in.off_right; | 219 vf->priv->in.off_left = vf->priv->in.off_right; |
231 //nobreak; | 220 //nobreak; |
261 case SIDE_BY_SIDE_RL: | 250 case SIDE_BY_SIDE_RL: |
262 case ABOVE_BELOW_LR: | 251 case ABOVE_BELOW_LR: |
263 case ABOVE_BELOW_RL: | 252 case ABOVE_BELOW_RL: |
264 case ABOVE_BELOW_2_LR: | 253 case ABOVE_BELOW_2_LR: |
265 case ABOVE_BELOW_2_RL: | 254 case ABOVE_BELOW_2_RL: |
266 for (int i = 0; i < vf->priv->in.hres; i++) { | 255 memcpy_pic(dmpi->planes[0] + vf->priv->out.off_left, |
267 memcpy_pic(dmpi->planes[0] + vf->priv->out.off_left + | 256 mpi->planes[0] + vf->priv->in.off_left, |
268 (i * vf->priv->out.stride), mpi->planes[0] + | 257 3 * vf->priv->width, |
269 vf->priv->in.off_left, 3 * vf->priv->width, | 258 vf->priv->height, |
270 vf->priv->height / (vf->priv->in.hres * | 259 vf->priv->out.stride, |
271 vf->priv->out.hres), vf->priv->out.stride * | 260 vf->priv->in.stride); |
272 vf->priv->in.hres, vf->priv->in.stride * | 261 memcpy_pic(dmpi->planes[0] + vf->priv->out.off_right, |
273 vf->priv->out.hres); | 262 mpi->planes[0] + vf->priv->in.off_right, |
274 memcpy_pic(dmpi->planes[0] + vf->priv->out.off_right + | 263 3 * vf->priv->width, |
275 (i * vf->priv->out.stride), mpi->planes[0] + | 264 vf->priv->height, |
276 vf->priv->in.off_right, 3 * vf->priv->width, | 265 vf->priv->out.stride, |
277 vf->priv->height / (vf->priv->in.hres * | 266 vf->priv->in.stride); |
278 vf->priv->out.hres), vf->priv->out.stride * | |
279 vf->priv->in.hres, vf->priv->in.stride * | |
280 vf->priv->out.hres); | |
281 } | |
282 break; | 267 break; |
283 case MONO_L: | 268 case MONO_L: |
284 case MONO_R: | 269 case MONO_R: |
285 for (int i = 0; i < vf->priv->in.hres; i++) { | 270 memcpy_pic(dmpi->planes[0], |
286 memcpy_pic(dmpi->planes[0] + (i * vf->priv->out.stride), | 271 mpi->planes[0] + vf->priv->in.off_left, |
287 mpi->planes[0] + vf->priv->in.off_left, 3 * | 272 3 * vf->priv->width, |
288 vf->priv->width, vf->priv->height / | 273 vf->priv->height, |
289 vf->priv->in.hres, vf->priv->out.stride * | 274 vf->priv->out.stride, |
290 vf->priv->in.hres, vf->priv->in.stride); | 275 vf->priv->in.stride); |
291 } | |
292 break; | 276 break; |
293 case ANAGLYPH_RC_GRAY: | 277 case ANAGLYPH_RC_GRAY: |
294 case ANAGLYPH_RC_HALF: | 278 case ANAGLYPH_RC_HALF: |
295 case ANAGLYPH_RC_COLOR: | 279 case ANAGLYPH_RC_COLOR: |
296 case ANAGLYPH_RC_DUBOIS: | 280 case ANAGLYPH_RC_DUBOIS: |
309 for(int i = 0; i < 3; i++) | 293 for(int i = 0; i < 3; i++) |
310 ana_matrix[i] = vf->priv->ana_matrix[i]; | 294 ana_matrix[i] = vf->priv->ana_matrix[i]; |
311 | 295 |
312 for (y = 0; y < vf->priv->out.height; y++) { | 296 for (y = 0; y < vf->priv->out.height; y++) { |
313 o = vf->priv->out.stride * y; | 297 o = vf->priv->out.stride * y; |
314 il = vf->priv->in.off_left + (y / vf->priv->in.hres) * | 298 il = vf->priv->in.off_left + y * |
315 vf->priv->in.stride; | 299 vf->priv->in.stride; |
316 ir = vf->priv->in.off_right + (y / vf->priv->in.hres) * | 300 ir = vf->priv->in.off_right + y * |
317 vf->priv->in.stride; | 301 vf->priv->in.stride; |
318 for (x = 0; x < out_width; x++) { | 302 for (x = 0; x < out_width; x++) { |
319 dest[o ] = ana_convert( | 303 dest[o ] = ana_convert( |
320 ana_matrix[0], source + il, source + ir); //red out | 304 ana_matrix[0], source + il, source + ir); //red out |
321 dest[o + 1] = ana_convert( | 305 dest[o + 1] = ana_convert( |