Mercurial > mplayer.hg
annotate libmpcodecs/vf_stereo3d.c @ 37095:6cce7a87e800
Cosmetic: Adjust indent.
author | ib |
---|---|
date | Wed, 07 May 2014 14:16:02 +0000 |
parents | 4cdc07440a68 |
children |
rev | line source |
---|---|
32441 | 1 /* |
2 * Copyright (C) 2010 Gordon Schmidt <gordon.schmidt <at> s2000.tu-chemnitz.de> | |
3 * | |
4 * This file is part of MPlayer. | |
5 * | |
6 * MPlayer is free software; you can redistribute it and/or modify | |
7 * it under the terms of the GNU General Public License as published by | |
8 * the Free Software Foundation; either version 2 of the License, or | |
9 * (at your option) any later version. | |
10 * | |
11 * MPlayer is distributed in the hope that it will be useful, | |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 * GNU General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU General Public License along | |
17 * with MPlayer; if not, write to the Free Software Foundation, Inc., | |
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
19 */ | |
20 | |
21 //==includes==// | |
22 #include <stdio.h> | |
23 #include <stdlib.h> | |
24 #include <string.h> | |
25 | |
26 #include "config.h" | |
27 #include "mp_msg.h" | |
28 #include "help_mp.h" | |
29 | |
30 #include "img_format.h" | |
31 #include "mp_image.h" | |
32445
7ec524214684
Use proper include instead of extern declarations in the .c file.
reimar
parents:
32441
diff
changeset
|
32 #include "vd.h" |
32441 | 33 #include "vf.h" |
34 #include "m_struct.h" | |
35 | |
36 #include "libavutil/common.h" | |
37 #include "libvo/fastmemcpy.h" | |
38 | |
39 //==types==// | |
40 typedef enum stereo_code { | |
41 ANAGLYPH_RC_GRAY, //anaglyph red/cyan gray | |
42 ANAGLYPH_RC_HALF, //anaglyph red/cyan half colored | |
43 ANAGLYPH_RC_COLOR, //anaglyph red/cyan colored | |
44 ANAGLYPH_RC_DUBOIS, //anaglyph red/cyan dubois | |
45 ANAGLYPH_GM_GRAY, //anaglyph green/magenta gray | |
46 ANAGLYPH_GM_HALF, //anaglyph green/magenta half colored | |
47 ANAGLYPH_GM_COLOR, //anaglyph green/magenta colored | |
35812 | 48 ANAGLYPH_GM_DUBOIS, //anaglyph green/magenta dubois |
32441 | 49 ANAGLYPH_YB_GRAY, //anaglyph yellow/blue gray |
50 ANAGLYPH_YB_HALF, //anaglyph yellow/blue half colored | |
51 ANAGLYPH_YB_COLOR, //anaglyph yellow/blue colored | |
34986 | 52 ANAGLYPH_YB_DUBOIS, //anaglyph yellow/blue dubois |
32441 | 53 MONO_L, //mono output for debugging (left eye only) |
54 MONO_R, //mono output for debugging (right eye only) | |
55 SIDE_BY_SIDE_LR, //side by side parallel (left eye left, right eye right) | |
56 SIDE_BY_SIDE_RL, //side by side crosseye (right eye left, left eye right) | |
33789 | 57 SIDE_BY_SIDE_2_LR, //side by side parallel with half width resolution |
58 SIDE_BY_SIDE_2_RL, //side by side crosseye with half width resolution | |
32441 | 59 ABOVE_BELOW_LR, //above-below (left eye above, right eye below) |
60 ABOVE_BELOW_RL, //above-below (right eye above, left eye below) | |
61 ABOVE_BELOW_2_LR, //above-below with half height resolution | |
62 ABOVE_BELOW_2_RL, //above-below with half height resolution | |
33560
16cf555989a9
Add support for converting to interleaved 3D in vf_stereo3d.
reimar
parents:
32541
diff
changeset
|
63 INTERLEAVE_ROWS_LR, //row-interleave (left eye has top row) |
16cf555989a9
Add support for converting to interleaved 3D in vf_stereo3d.
reimar
parents:
32541
diff
changeset
|
64 INTERLEAVE_ROWS_RL, //row-interleave (right eye has top row) |
32441 | 65 STEREO_CODE_COUNT //no value set - TODO: needs autodetection |
66 } stereo_code; | |
67 | |
68 typedef struct component { | |
69 stereo_code fmt; | |
70 unsigned int width; | |
71 unsigned int height; | |
72 unsigned int off_left; | |
73 unsigned int off_right; | |
32539 | 74 unsigned int row_left; |
75 unsigned int row_right; | |
32441 | 76 } component; |
77 | |
78 //==global variables==// | |
34984
c24d1a0c7665
Make compiler give the ana_coeff array automatically the right size.
reimar
parents:
33789
diff
changeset
|
79 static const int ana_coeff[][3][6] = { |
34985 | 80 [ANAGLYPH_RC_GRAY] = |
81 {{19595, 38470, 7471, 0, 0, 0}, | |
32441 | 82 { 0, 0, 0, 19595, 38470, 7471}, |
83 { 0, 0, 0, 19595, 38470, 7471}}, | |
34985 | 84 [ANAGLYPH_RC_HALF] = |
85 {{19595, 38470, 7471, 0, 0, 0}, | |
32441 | 86 { 0, 0, 0, 0, 65536, 0}, |
87 { 0, 0, 0, 0, 0, 65536}}, | |
34985 | 88 [ANAGLYPH_RC_COLOR] = |
89 {{65536, 0, 0, 0, 0, 0}, | |
32441 | 90 { 0, 0, 0, 0, 65536, 0}, |
91 { 0, 0, 0, 0, 0, 65536}}, | |
34985 | 92 [ANAGLYPH_RC_DUBOIS] = |
93 {{29891, 32800, 11559, -2849, -5763, -102}, | |
32441 | 94 {-2627, -2479, -1033, 24804, 48080, -1209}, |
95 { -997, -1350, -358, -4729, -7403, 80373}}, | |
34985 | 96 [ANAGLYPH_GM_GRAY] = |
97 {{ 0, 0, 0, 19595, 38470, 7471}, | |
32441 | 98 {19595, 38470, 7471, 0, 0, 0}, |
99 { 0, 0, 0, 19595, 38470, 7471}}, | |
34985 | 100 [ANAGLYPH_GM_HALF] = |
101 {{ 0, 0, 0, 65536, 0, 0}, | |
32441 | 102 {19595, 38470, 7471, 0, 0, 0}, |
103 { 0, 0, 0, 0, 0, 65536}}, | |
34985 | 104 [ANAGLYPH_GM_COLOR] = |
105 {{ 0, 0, 0, 65536, 0, 0}, | |
32441 | 106 { 0, 65536, 0, 0, 0, 0}, |
107 { 0, 0, 0, 0, 0, 65536}}, | |
35812 | 108 [ANAGLYPH_GM_DUBOIS] = |
109 {{-4063,-10354, -2556, 34669, 46203, 1573}, | |
110 {18612, 43778, 9372, -1049, -983, -4260}, | |
111 { -983, -1769, 1376, 590, 4915, 61407}}, | |
34985 | 112 [ANAGLYPH_YB_GRAY] = |
113 {{ 0, 0, 0, 19595, 38470, 7471}, | |
32441 | 114 { 0, 0, 0, 19595, 38470, 7471}, |
115 {19595, 38470, 7471, 0, 0, 0}}, | |
34985 | 116 [ANAGLYPH_YB_HALF] = |
117 {{ 0, 0, 0, 65536, 0, 0}, | |
32441 | 118 { 0, 0, 0, 0, 65536, 0}, |
119 {19595, 38470, 7471, 0, 0, 0}}, | |
34985 | 120 [ANAGLYPH_YB_COLOR] = |
121 {{ 0, 0, 0, 65536, 0, 0}, | |
32441 | 122 { 0, 0, 0, 0, 65536, 0}, |
34986 | 123 { 0, 0, 65536, 0, 0, 0}}, |
124 [ANAGLYPH_YB_DUBOIS] = | |
125 {{65535,-12650,18451, -987, -7590, -1049}, | |
126 {-1604, 56032, 4196, 370, 3826, -1049}, | |
127 {-2345,-10676, 1358, 5801, 11416, 56217}}, | |
32441 | 128 }; |
129 | |
130 struct vf_priv_s { | |
131 component in; | |
132 component out; | |
133 int ana_matrix[3][6]; | |
134 unsigned int width; | |
135 unsigned int height; | |
33560
16cf555989a9
Add support for converting to interleaved 3D in vf_stereo3d.
reimar
parents:
32541
diff
changeset
|
136 unsigned int row_step; |
32441 | 137 } const vf_priv_default = { |
138 {SIDE_BY_SIDE_LR}, | |
139 {ANAGLYPH_RC_DUBOIS} | |
140 }; | |
141 | |
142 //==functions==// | |
143 static inline uint8_t ana_convert(int coeff[6], uint8_t left[3], uint8_t right[3]) | |
144 { | |
145 int sum; | |
146 | |
147 sum = coeff[0] * left[0] + coeff[3] * right[0]; //red in | |
148 sum += coeff[1] * left[1] + coeff[4] * right[1]; //green in | |
149 sum += coeff[2] * left[2] + coeff[5] * right[2]; //blue in | |
150 return av_clip_uint8(sum >> 16); | |
151 } | |
152 | |
153 static int config(struct vf_instance *vf, int width, int height, int d_width, | |
154 int d_height, unsigned int flags, unsigned int outfmt) | |
155 { | |
156 if ((width & 1) || (height & 1)) { | |
157 mp_msg(MSGT_VFILTER, MSGL_WARN, "[stereo3d] invalid height or width\n"); | |
158 return 0; | |
159 } | |
160 //default input values | |
161 vf->priv->width = width; | |
162 vf->priv->height = height; | |
33560
16cf555989a9
Add support for converting to interleaved 3D in vf_stereo3d.
reimar
parents:
32541
diff
changeset
|
163 vf->priv->row_step = 1; |
32441 | 164 vf->priv->in.width = width; |
165 vf->priv->in.height = height; | |
166 vf->priv->in.off_left = 0; | |
167 vf->priv->in.off_right = 0; | |
32539 | 168 vf->priv->in.row_left = 0; |
169 vf->priv->in.row_right = 0; | |
32441 | 170 |
171 //check input format | |
172 switch (vf->priv->in.fmt) { | |
33789 | 173 case SIDE_BY_SIDE_2_LR: |
174 d_width *= 2; | |
32441 | 175 case SIDE_BY_SIDE_LR: |
176 vf->priv->width = width / 2; | |
177 vf->priv->in.off_right = vf->priv->width * 3; | |
178 break; | |
33789 | 179 case SIDE_BY_SIDE_2_RL: |
180 d_width *= 2; | |
32441 | 181 case SIDE_BY_SIDE_RL: |
182 vf->priv->width = width / 2; | |
183 vf->priv->in.off_left = vf->priv->width * 3; | |
184 break; | |
32538 | 185 case ABOVE_BELOW_2_LR: |
186 d_height *= 2; | |
32441 | 187 case ABOVE_BELOW_LR: |
188 vf->priv->height = height / 2; | |
32539 | 189 vf->priv->in.row_right = vf->priv->height; |
32441 | 190 break; |
32538 | 191 case ABOVE_BELOW_2_RL: |
192 d_height *= 2; | |
32441 | 193 case ABOVE_BELOW_RL: |
194 vf->priv->height = height / 2; | |
32539 | 195 vf->priv->in.row_left = vf->priv->height; |
32441 | 196 break; |
197 default: | |
198 mp_msg(MSGT_VFILTER, MSGL_WARN, | |
199 "[stereo3d] stereo format of input is not supported\n"); | |
200 return 0; | |
201 break; | |
202 } | |
203 //default output values | |
204 vf->priv->out.width = vf->priv->width; | |
205 vf->priv->out.height = vf->priv->height; | |
206 vf->priv->out.off_left = 0; | |
207 vf->priv->out.off_right = 0; | |
32539 | 208 vf->priv->out.row_left = 0; |
209 vf->priv->out.row_right = 0; | |
32441 | 210 |
211 //check output format | |
212 switch (vf->priv->out.fmt) { | |
213 case ANAGLYPH_RC_GRAY: | |
214 case ANAGLYPH_RC_HALF: | |
215 case ANAGLYPH_RC_COLOR: | |
216 case ANAGLYPH_RC_DUBOIS: | |
217 case ANAGLYPH_GM_GRAY: | |
218 case ANAGLYPH_GM_HALF: | |
219 case ANAGLYPH_GM_COLOR: | |
35812 | 220 case ANAGLYPH_GM_DUBOIS: |
32441 | 221 case ANAGLYPH_YB_GRAY: |
222 case ANAGLYPH_YB_HALF: | |
223 case ANAGLYPH_YB_COLOR: | |
34986 | 224 case ANAGLYPH_YB_DUBOIS: |
32441 | 225 memcpy(vf->priv->ana_matrix, ana_coeff[vf->priv->out.fmt], |
226 sizeof(vf->priv->ana_matrix)); | |
227 break; | |
33789 | 228 case SIDE_BY_SIDE_2_LR: |
229 d_width /= 2; | |
32441 | 230 case SIDE_BY_SIDE_LR: |
231 vf->priv->out.width = vf->priv->width * 2; | |
232 vf->priv->out.off_right = vf->priv->width * 3; | |
233 break; | |
33789 | 234 case SIDE_BY_SIDE_2_RL: |
235 d_width /= 2; | |
32441 | 236 case SIDE_BY_SIDE_RL: |
237 vf->priv->out.width = vf->priv->width * 2; | |
238 vf->priv->out.off_left = vf->priv->width * 3; | |
239 break; | |
32538 | 240 case ABOVE_BELOW_2_LR: |
241 d_height /= 2; | |
32441 | 242 case ABOVE_BELOW_LR: |
243 vf->priv->out.height = vf->priv->height * 2; | |
32539 | 244 vf->priv->out.row_right = vf->priv->height; |
32441 | 245 break; |
32538 | 246 case ABOVE_BELOW_2_RL: |
247 d_height /= 2; | |
32441 | 248 case ABOVE_BELOW_RL: |
249 vf->priv->out.height = vf->priv->height * 2; | |
32539 | 250 vf->priv->out.row_left = vf->priv->height; |
32441 | 251 break; |
33560
16cf555989a9
Add support for converting to interleaved 3D in vf_stereo3d.
reimar
parents:
32541
diff
changeset
|
252 case INTERLEAVE_ROWS_LR: |
16cf555989a9
Add support for converting to interleaved 3D in vf_stereo3d.
reimar
parents:
32541
diff
changeset
|
253 vf->priv->row_step = 2; |
16cf555989a9
Add support for converting to interleaved 3D in vf_stereo3d.
reimar
parents:
32541
diff
changeset
|
254 vf->priv->height = vf->priv->height / 2; |
16cf555989a9
Add support for converting to interleaved 3D in vf_stereo3d.
reimar
parents:
32541
diff
changeset
|
255 vf->priv->out.off_right = vf->priv->width * 3; |
16cf555989a9
Add support for converting to interleaved 3D in vf_stereo3d.
reimar
parents:
32541
diff
changeset
|
256 vf->priv->in.off_right += vf->priv->in.width * 3; |
16cf555989a9
Add support for converting to interleaved 3D in vf_stereo3d.
reimar
parents:
32541
diff
changeset
|
257 break; |
16cf555989a9
Add support for converting to interleaved 3D in vf_stereo3d.
reimar
parents:
32541
diff
changeset
|
258 case INTERLEAVE_ROWS_RL: |
16cf555989a9
Add support for converting to interleaved 3D in vf_stereo3d.
reimar
parents:
32541
diff
changeset
|
259 vf->priv->row_step = 2; |
16cf555989a9
Add support for converting to interleaved 3D in vf_stereo3d.
reimar
parents:
32541
diff
changeset
|
260 vf->priv->height = vf->priv->height / 2; |
16cf555989a9
Add support for converting to interleaved 3D in vf_stereo3d.
reimar
parents:
32541
diff
changeset
|
261 vf->priv->out.off_left = vf->priv->width * 3; |
16cf555989a9
Add support for converting to interleaved 3D in vf_stereo3d.
reimar
parents:
32541
diff
changeset
|
262 vf->priv->in.off_left += vf->priv->in.width * 3; |
16cf555989a9
Add support for converting to interleaved 3D in vf_stereo3d.
reimar
parents:
32541
diff
changeset
|
263 break; |
32441 | 264 case MONO_R: |
265 //same as MONO_L only needs switching of input offsets | |
266 vf->priv->in.off_left = vf->priv->in.off_right; | |
32539 | 267 vf->priv->in.row_left = vf->priv->in.row_right; |
32441 | 268 //nobreak; |
269 case MONO_L: | |
270 //use default settings | |
271 break; | |
272 default: | |
273 mp_msg(MSGT_VFILTER, MSGL_WARN, | |
274 "[stereo3d] stereo format of output is not supported\n"); | |
275 return 0; | |
276 break; | |
277 } | |
278 if (!opt_screen_size_x && !opt_screen_size_y) { | |
279 d_width = d_width * vf->priv->out.width / width; | |
280 d_height = d_height * vf->priv->out.height / height; | |
281 } | |
282 return vf_next_config(vf, vf->priv->out.width, vf->priv->out.height, | |
283 d_width, d_height, flags, outfmt); | |
284 } | |
285 | |
286 static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts) | |
287 { | |
288 mp_image_t *dmpi; | |
289 if (vf->priv->in.fmt == vf->priv->out.fmt) { //nothing to do | |
290 dmpi = mpi; | |
291 } else { | |
32539 | 292 int out_off_left, out_off_right; |
293 int in_off_left = vf->priv->in.row_left * mpi->stride[0] + | |
294 vf->priv->in.off_left; | |
295 int in_off_right = vf->priv->in.row_right * mpi->stride[0] + | |
296 vf->priv->in.off_right; | |
297 | |
32541
45b3a91e8fb7
Indicate that stereo3d can now handle strides properly.
reimar
parents:
32540
diff
changeset
|
298 dmpi = vf_get_image(vf->next, IMGFMT_RGB24, MP_IMGTYPE_TEMP, |
45b3a91e8fb7
Indicate that stereo3d can now handle strides properly.
reimar
parents:
32540
diff
changeset
|
299 MP_IMGFLAG_ACCEPT_STRIDE, |
32441 | 300 vf->priv->out.width, vf->priv->out.height); |
32539 | 301 out_off_left = vf->priv->out.row_left * dmpi->stride[0] + |
302 vf->priv->out.off_left; | |
303 out_off_right = vf->priv->out.row_right * dmpi->stride[0] + | |
304 vf->priv->out.off_right; | |
305 | |
32441 | 306 switch (vf->priv->out.fmt) { |
307 case SIDE_BY_SIDE_LR: | |
308 case SIDE_BY_SIDE_RL: | |
33789 | 309 case SIDE_BY_SIDE_2_LR: |
310 case SIDE_BY_SIDE_2_RL: | |
32441 | 311 case ABOVE_BELOW_LR: |
312 case ABOVE_BELOW_RL: | |
313 case ABOVE_BELOW_2_LR: | |
314 case ABOVE_BELOW_2_RL: | |
33560
16cf555989a9
Add support for converting to interleaved 3D in vf_stereo3d.
reimar
parents:
32541
diff
changeset
|
315 case INTERLEAVE_ROWS_LR: |
16cf555989a9
Add support for converting to interleaved 3D in vf_stereo3d.
reimar
parents:
32541
diff
changeset
|
316 case INTERLEAVE_ROWS_RL: |
33602
042b10b477fa
Change memcpy_pic to force it to never write to image parts between
reimar
parents:
33599
diff
changeset
|
317 memcpy_pic2(dmpi->planes[0] + out_off_left, |
32539 | 318 mpi->planes[0] + in_off_left, |
32538 | 319 3 * vf->priv->width, |
320 vf->priv->height, | |
33560
16cf555989a9
Add support for converting to interleaved 3D in vf_stereo3d.
reimar
parents:
32541
diff
changeset
|
321 dmpi->stride[0] * vf->priv->row_step, |
33602
042b10b477fa
Change memcpy_pic to force it to never write to image parts between
reimar
parents:
33599
diff
changeset
|
322 mpi->stride[0] * vf->priv->row_step, |
042b10b477fa
Change memcpy_pic to force it to never write to image parts between
reimar
parents:
33599
diff
changeset
|
323 vf->priv->row_step != 1); |
042b10b477fa
Change memcpy_pic to force it to never write to image parts between
reimar
parents:
33599
diff
changeset
|
324 memcpy_pic2(dmpi->planes[0] + out_off_right, |
32539 | 325 mpi->planes[0] + in_off_right, |
32538 | 326 3 * vf->priv->width, |
327 vf->priv->height, | |
33560
16cf555989a9
Add support for converting to interleaved 3D in vf_stereo3d.
reimar
parents:
32541
diff
changeset
|
328 dmpi->stride[0] * vf->priv->row_step, |
33602
042b10b477fa
Change memcpy_pic to force it to never write to image parts between
reimar
parents:
33599
diff
changeset
|
329 mpi->stride[0] * vf->priv->row_step, |
042b10b477fa
Change memcpy_pic to force it to never write to image parts between
reimar
parents:
33599
diff
changeset
|
330 vf->priv->row_step != 1); |
32441 | 331 break; |
332 case MONO_L: | |
333 case MONO_R: | |
32538 | 334 memcpy_pic(dmpi->planes[0], |
32539 | 335 mpi->planes[0] + in_off_left, |
32538 | 336 3 * vf->priv->width, |
337 vf->priv->height, | |
32539 | 338 dmpi->stride[0], |
339 mpi->stride[0]); | |
32441 | 340 break; |
341 case ANAGLYPH_RC_GRAY: | |
342 case ANAGLYPH_RC_HALF: | |
343 case ANAGLYPH_RC_COLOR: | |
344 case ANAGLYPH_RC_DUBOIS: | |
345 case ANAGLYPH_GM_GRAY: | |
346 case ANAGLYPH_GM_HALF: | |
347 case ANAGLYPH_GM_COLOR: | |
35812 | 348 case ANAGLYPH_GM_DUBOIS: |
32441 | 349 case ANAGLYPH_YB_GRAY: |
350 case ANAGLYPH_YB_HALF: | |
35812 | 351 case ANAGLYPH_YB_COLOR: |
352 case ANAGLYPH_YB_DUBOIS: { | |
33599
6d690eac34eb
Avoid C99 syntax not supported by some old compilers.
reimar
parents:
33560
diff
changeset
|
353 int i,x,y,il,ir,o; |
32441 | 354 unsigned char *source = mpi->planes[0]; |
355 unsigned char *dest = dmpi->planes[0]; | |
356 unsigned int out_width = vf->priv->out.width; | |
357 int *ana_matrix[3]; | |
358 | |
33599
6d690eac34eb
Avoid C99 syntax not supported by some old compilers.
reimar
parents:
33560
diff
changeset
|
359 for(i = 0; i < 3; i++) |
32441 | 360 ana_matrix[i] = vf->priv->ana_matrix[i]; |
361 | |
362 for (y = 0; y < vf->priv->out.height; y++) { | |
32539 | 363 o = dmpi->stride[0] * y; |
364 il = in_off_left + y * mpi->stride[0]; | |
365 ir = in_off_right + y * mpi->stride[0]; | |
32441 | 366 for (x = 0; x < out_width; x++) { |
367 dest[o ] = ana_convert( | |
368 ana_matrix[0], source + il, source + ir); //red out | |
369 dest[o + 1] = ana_convert( | |
370 ana_matrix[1], source + il, source + ir); //green out | |
371 dest[o + 2] = ana_convert( | |
372 ana_matrix[2], source + il, source + ir); //blue out | |
373 il += 3; | |
374 ir += 3; | |
375 o += 3; | |
376 } | |
377 } | |
378 break; | |
379 } | |
380 default: | |
381 mp_msg(MSGT_VFILTER, MSGL_WARN, | |
382 "[stereo3d] stereo format of output is not supported\n"); | |
383 return 0; | |
384 break; | |
385 } | |
386 } | |
387 return vf_next_put_image(vf, dmpi, pts); | |
388 } | |
389 | |
390 static int query_format(struct vf_instance *vf, unsigned int fmt) | |
391 { | |
392 switch (fmt) | |
393 case IMGFMT_RGB24: | |
394 return vf_next_query_format(vf, fmt); | |
395 return 0; | |
396 } | |
397 | |
398 static void uninit(vf_instance_t *vf) | |
399 { | |
400 free(vf->priv); | |
401 } | |
402 | |
403 static int vf_open(vf_instance_t *vf, char *args) | |
404 { | |
405 vf->config = config; | |
406 vf->uninit = uninit; | |
407 vf->put_image = put_image; | |
408 vf->query_format = query_format; | |
409 | |
410 return 1; | |
411 } | |
412 | |
413 ///Presets usage | |
414 static const struct format_preset { | |
415 char* name; | |
416 stereo_code scode; | |
417 } vf_format_presets_defs[] = { | |
418 {"arcg", ANAGLYPH_RC_GRAY}, | |
419 {"anaglyph_red_cyan_gray", ANAGLYPH_RC_GRAY}, | |
420 {"arch", ANAGLYPH_RC_HALF}, | |
421 {"anaglyph_red_cyan_half_color", ANAGLYPH_RC_HALF}, | |
422 {"arcc", ANAGLYPH_RC_COLOR}, | |
423 {"anaglyph_red_cyan_color", ANAGLYPH_RC_COLOR}, | |
424 {"arcd", ANAGLYPH_RC_DUBOIS}, | |
36185 | 425 {"anaglyph_red_cyan_dubois", ANAGLYPH_RC_DUBOIS}, |
32441 | 426 {"agmg", ANAGLYPH_GM_GRAY}, |
427 {"anaglyph_green_magenta_gray", ANAGLYPH_GM_GRAY}, | |
428 {"agmh", ANAGLYPH_GM_HALF}, | |
429 {"anaglyph_green_magenta_half_color",ANAGLYPH_GM_HALF}, | |
430 {"agmc", ANAGLYPH_GM_COLOR}, | |
431 {"anaglyph_green_magenta_color", ANAGLYPH_GM_COLOR}, | |
35812 | 432 {"agmd", ANAGLYPH_GM_DUBOIS}, |
433 {"anaglyph_green_magenta_dubois", ANAGLYPH_GM_DUBOIS}, | |
32441 | 434 {"aybg", ANAGLYPH_YB_GRAY}, |
435 {"anaglyph_yellow_blue_gray", ANAGLYPH_YB_GRAY}, | |
436 {"aybh", ANAGLYPH_YB_HALF}, | |
437 {"anaglyph_yellow_blue_half_color", ANAGLYPH_YB_HALF}, | |
438 {"aybc", ANAGLYPH_YB_COLOR}, | |
439 {"anaglyph_yellow_blue_color", ANAGLYPH_YB_COLOR}, | |
34986 | 440 {"aybd", ANAGLYPH_YB_DUBOIS}, |
441 {"anaglyph_yellow_blue_dubois", ANAGLYPH_YB_DUBOIS}, | |
32441 | 442 {"ml", MONO_L}, |
443 {"mono_left", MONO_L}, | |
444 {"mr", MONO_R}, | |
445 {"mono_right", MONO_R}, | |
446 {"sbsl", SIDE_BY_SIDE_LR}, | |
447 {"side_by_side_left_first", SIDE_BY_SIDE_LR}, | |
448 {"sbsr", SIDE_BY_SIDE_RL}, | |
449 {"side_by_side_right_first", SIDE_BY_SIDE_RL}, | |
33789 | 450 {"sbs2l", SIDE_BY_SIDE_2_LR}, |
451 {"side_by_side_half_width_left_first", SIDE_BY_SIDE_2_LR}, | |
452 {"sbs2r", SIDE_BY_SIDE_2_RL}, | |
453 {"side_by_side_half_width_right_first",SIDE_BY_SIDE_2_RL}, | |
32441 | 454 {"abl", ABOVE_BELOW_LR}, |
455 {"above_below_left_first", ABOVE_BELOW_LR}, | |
456 {"abr", ABOVE_BELOW_RL}, | |
457 {"above_below_right_first", ABOVE_BELOW_RL}, | |
458 {"ab2l", ABOVE_BELOW_2_LR}, | |
459 {"above_below_half_height_left_first", ABOVE_BELOW_2_LR}, | |
460 {"ab2r", ABOVE_BELOW_2_RL}, | |
461 {"above_below_half_height_right_first",ABOVE_BELOW_2_RL}, | |
33560
16cf555989a9
Add support for converting to interleaved 3D in vf_stereo3d.
reimar
parents:
32541
diff
changeset
|
462 {"irl", INTERLEAVE_ROWS_LR}, |
16cf555989a9
Add support for converting to interleaved 3D in vf_stereo3d.
reimar
parents:
32541
diff
changeset
|
463 {"interleave_rows_left_first", INTERLEAVE_ROWS_LR}, |
16cf555989a9
Add support for converting to interleaved 3D in vf_stereo3d.
reimar
parents:
32541
diff
changeset
|
464 {"irr", INTERLEAVE_ROWS_RL}, |
16cf555989a9
Add support for converting to interleaved 3D in vf_stereo3d.
reimar
parents:
32541
diff
changeset
|
465 {"interleave_rows_right_first", INTERLEAVE_ROWS_RL}, |
32441 | 466 { NULL, 0} |
467 }; | |
468 | |
469 #define ST_OFF(f) M_ST_OFF(struct format_preset,f) | |
470 static const m_option_t vf_format_preset_fields_in[] = { | |
471 {"in", ST_OFF(scode), CONF_TYPE_INT, 0,0,0, NULL}, | |
472 { NULL, NULL, 0, 0, 0, 0, NULL } | |
473 }; | |
474 static const m_option_t vf_format_preset_fields_out[] = { | |
475 {"out", ST_OFF(scode), CONF_TYPE_INT, 0,0,0, NULL}, | |
476 { NULL, NULL, 0, 0, 0, 0, NULL } | |
477 }; | |
478 | |
479 static const m_struct_t vf_format_preset_in = { | |
480 "stereo_format_preset_in", | |
481 sizeof(struct format_preset), | |
482 NULL, | |
483 vf_format_preset_fields_in | |
484 }; | |
485 static const m_struct_t vf_format_preset_out = { | |
486 "stereo_format_preset_out", | |
487 sizeof(struct format_preset), | |
488 NULL, | |
489 vf_format_preset_fields_out | |
490 }; | |
491 | |
492 static const m_struct_t vf_opts; | |
493 static const m_obj_presets_t format_preset_in = { | |
494 (struct m_struct_st*)&vf_format_preset_in, | |
495 (struct m_struct_st*)&vf_opts, | |
496 (struct format_preset*)vf_format_presets_defs, | |
497 ST_OFF(name) | |
498 }; | |
499 static const m_obj_presets_t format_preset_out = { | |
500 (struct m_struct_st*)&vf_format_preset_out, | |
501 (struct m_struct_st*)&vf_opts, | |
502 (struct format_preset*)vf_format_presets_defs, | |
503 ST_OFF(name) | |
504 }; | |
505 | |
506 /// Now the options | |
507 #undef ST_OFF | |
508 #define ST_OFF(f) M_ST_OFF(struct vf_priv_s,f) | |
509 static const m_option_t vf_opts_fields[] = { | |
510 {"stereo_in", 0, CONF_TYPE_OBJ_PRESETS, 0, 0, 0, | |
511 (m_obj_presets_t*)&format_preset_in}, | |
512 {"stereo_out", 0, CONF_TYPE_OBJ_PRESETS, 0, 0, 0, | |
513 (m_obj_presets_t*)&format_preset_out}, | |
514 {"in", ST_OFF(in.fmt), CONF_TYPE_INT, 0,0,0, NULL}, | |
515 {"out", ST_OFF(out.fmt), CONF_TYPE_INT, 0,0,0, NULL}, | |
516 { NULL, NULL, 0, 0, 0, 0, NULL } | |
517 }; | |
518 | |
519 static const m_struct_t vf_opts = { | |
520 "stereo3d", | |
521 sizeof(struct vf_priv_s), | |
522 &vf_priv_default, | |
523 vf_opts_fields | |
524 }; | |
525 | |
526 | |
527 //==info struct==// | |
528 const vf_info_t vf_info_stereo3d = { | |
529 "stereoscopic 3d view", | |
530 "stereo3d", | |
531 "Gordon Schmidt", | |
532 "view stereoscopic videos", | |
533 vf_open, | |
534 &vf_opts | |
535 }; |