Mercurial > mplayer.hg
annotate libmpcodecs/vf_down3dright.c @ 28131:e2c13ec41971
Document vo_macosx's shared_buffer option.
author | gpoirier |
---|---|
date | Fri, 19 Dec 2008 21:18:31 +0000 |
parents | 00fff9a3b735 |
children | bbb6ebec87a0 |
rev | line source |
---|---|
9404
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
1 #include <stdio.h> |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
2 #include <stdlib.h> |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
3 #include <string.h> |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
4 #include <inttypes.h> |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
5 |
17012 | 6 #include "config.h" |
7 #include "mp_msg.h" | |
8 #include "cpudetect.h" | |
9404
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
9 |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
10 #include "img_format.h" |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
11 #include "mp_image.h" |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
12 #include "vf.h" |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
13 |
17012 | 14 #include "libvo/fastmemcpy.h" |
9404
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
15 |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
16 struct vf_priv_s { |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
17 int skipline; |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
18 int scalew; |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
19 int scaleh; |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
20 }; |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
21 |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
22 static void toright(unsigned char *dst[3], unsigned char *src[3], |
14793 | 23 int dststride[3], int srcstride[3], |
9404
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
24 int w, int h, struct vf_priv_s* p) |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
25 { |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
26 int k; |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
27 |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
28 for (k = 0; k < 3; k++) { |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
29 unsigned char* fromL = src[k]; |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
30 unsigned char* fromR = src[k]; |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
31 unsigned char* to = dst[k]; |
14793 | 32 int src = srcstride[k]; |
33 int dst = dststride[k]; | |
34 int ss; | |
9404
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
35 unsigned int dd; |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
36 int i; |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
37 |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
38 if (k > 0) { |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
39 i = h / 4 - p->skipline / 2; |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
40 ss = src * (h / 4 + p->skipline / 2); |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
41 dd = w / 4; |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
42 } else { |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
43 i = h / 2 - p->skipline; |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
44 ss = src * (h / 2 + p->skipline); |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
45 dd = w / 2; |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
46 } |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
47 fromR += ss; |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
48 for ( ; i > 0; i--) { |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
49 int j; |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
50 unsigned char* t = to; |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
51 unsigned char* sL = fromL; |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
52 unsigned char* sR = fromR; |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
53 |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
54 if (p->scalew == 1) { |
10051
55831d1b371b
fixed a 10l (undefined behavior) and made the other parameters configurable
rfelker
parents:
9593
diff
changeset
|
55 for (j = dd; j > 0; j--) { |
55831d1b371b
fixed a 10l (undefined behavior) and made the other parameters configurable
rfelker
parents:
9593
diff
changeset
|
56 *t++ = (sL[0] + sL[1]) / 2; |
55831d1b371b
fixed a 10l (undefined behavior) and made the other parameters configurable
rfelker
parents:
9593
diff
changeset
|
57 sL+=2; |
55831d1b371b
fixed a 10l (undefined behavior) and made the other parameters configurable
rfelker
parents:
9593
diff
changeset
|
58 } |
55831d1b371b
fixed a 10l (undefined behavior) and made the other parameters configurable
rfelker
parents:
9593
diff
changeset
|
59 for (j = dd ; j > 0; j--) { |
55831d1b371b
fixed a 10l (undefined behavior) and made the other parameters configurable
rfelker
parents:
9593
diff
changeset
|
60 *t++ = (sR[0] + sR[1]) / 2; |
55831d1b371b
fixed a 10l (undefined behavior) and made the other parameters configurable
rfelker
parents:
9593
diff
changeset
|
61 sR+=2; |
55831d1b371b
fixed a 10l (undefined behavior) and made the other parameters configurable
rfelker
parents:
9593
diff
changeset
|
62 } |
9404
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
63 } else { |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
64 for (j = dd * 2 ; j > 0; j--) |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
65 *t++ = *sL++; |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
66 for (j = dd * 2 ; j > 0; j--) |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
67 *t++ = *sR++; |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
68 } |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
69 if (p->scaleh == 1) { |
23457
a124f3abc1ec
Replace implicit use of fast_memcpy via macro by explicit use to allow
reimar
parents:
18746
diff
changeset
|
70 fast_memcpy(to + dst, to, dst); |
9404
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
71 to += dst; |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
72 } |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
73 to += dst; |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
74 fromL += src; |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
75 fromR += src; |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
76 } |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
77 //printf("K %d %d %d %d %d \n", k, w, h, src, dst); |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
78 } |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
79 } |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
80 |
17906
20aca9baf5d8
passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents:
17012
diff
changeset
|
81 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts) |
9404
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
82 { |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
83 mp_image_t *dmpi; |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
84 |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
85 // hope we'll get DR buffer: |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
86 dmpi=vf_get_image(vf->next, IMGFMT_YV12, |
16138
6cada718a809
If scaleh == 1 our destination image must be readable
reimar
parents:
14793
diff
changeset
|
87 MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE | |
6cada718a809
If scaleh == 1 our destination image must be readable
reimar
parents:
14793
diff
changeset
|
88 (vf->priv->scaleh == 1) ? MP_IMGFLAG_READABLE : 0, |
9404
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
89 mpi->w * vf->priv->scalew, |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
90 mpi->h / vf->priv->scaleh - vf->priv->skipline); |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
91 |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
92 toright(dmpi->planes, mpi->planes, dmpi->stride, |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
93 mpi->stride, mpi->w, mpi->h, vf->priv); |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
94 |
17906
20aca9baf5d8
passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents:
17012
diff
changeset
|
95 return vf_next_put_image(vf,dmpi, pts); |
9404
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
96 } |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
97 |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
98 static int config(struct vf_instance_s* vf, |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
99 int width, int height, int d_width, int d_height, |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
100 unsigned int flags, unsigned int outfmt) |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
101 { |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
102 /* FIXME - also support UYVY output? */ |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
103 return vf_next_config(vf, width * vf->priv->scalew, |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
104 height / vf->priv->scaleh - vf->priv->skipline, d_width, d_height, flags, IMGFMT_YV12); |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
105 } |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
106 |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
107 |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
108 static int query_format(struct vf_instance_s* vf, unsigned int fmt) |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
109 { |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
110 /* FIXME - really any YUV 4:2:0 input format should work */ |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
111 switch (fmt) { |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
112 case IMGFMT_YV12: |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
113 case IMGFMT_IYUV: |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
114 case IMGFMT_I420: |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
115 return vf_next_query_format(vf, IMGFMT_YV12); |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
116 } |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
117 return 0; |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
118 } |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
119 |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
120 static void uninit(struct vf_instance_s* vf) |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
121 { |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
122 free(vf->priv); |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
123 } |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
124 |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
125 static int open(vf_instance_t *vf, char* args) |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
126 { |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
127 vf->config=config; |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
128 vf->query_format=query_format; |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
129 vf->put_image=put_image; |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
130 vf->uninit=uninit; |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
131 |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
132 vf->priv = calloc(1, sizeof (struct vf_priv_s)); |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
133 vf->priv->skipline = 0; |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
134 vf->priv->scalew = 1; |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
135 vf->priv->scaleh = 2; |
10051
55831d1b371b
fixed a 10l (undefined behavior) and made the other parameters configurable
rfelker
parents:
9593
diff
changeset
|
136 if (args) sscanf(args, "%d:%d:%d", &vf->priv->skipline, &vf->priv->scalew, &vf->priv->scaleh); |
9404
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
137 |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
138 return 1; |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
139 } |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
140 |
25221 | 141 const vf_info_t vf_info_down3dright = { |
9404
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
142 "convert stereo movie from top-bottom to left-right field", |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
143 "down3dright", |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
144 "Zdenek Kabelac", |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
145 "", |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9404
diff
changeset
|
146 open, |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9404
diff
changeset
|
147 NULL |
9404
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
148 }; |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
149 |