Mercurial > mplayer.hg
annotate libmpcodecs/vf_down3dright.c @ 16784:7a6e909c223e
minor typo
author | diego |
---|---|
date | Mon, 17 Oct 2005 08:50:04 +0000 |
parents | 6cada718a809 |
children | 6ff3379a0862 |
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 |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
6 #include "../config.h" |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
7 #include "../mp_msg.h" |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
8 #include "../cpudetect.h" |
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 |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
14 #include "../libvo/fastmemcpy.h" |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
15 #include "../postproc/rgb2rgb.h" |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
16 |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
17 struct vf_priv_s { |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
18 int skipline; |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
19 int scalew; |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
20 int scaleh; |
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 |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
23 static void toright(unsigned char *dst[3], unsigned char *src[3], |
14793 | 24 int dststride[3], int srcstride[3], |
9404
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
25 int w, int h, struct vf_priv_s* p) |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
26 { |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
27 int k; |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
28 |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
29 for (k = 0; k < 3; k++) { |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
30 unsigned char* fromL = src[k]; |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
31 unsigned char* fromR = src[k]; |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
32 unsigned char* to = dst[k]; |
14793 | 33 int src = srcstride[k]; |
34 int dst = dststride[k]; | |
35 int ss; | |
9404
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
36 unsigned int dd; |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
37 int i; |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
38 |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
39 if (k > 0) { |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
40 i = h / 4 - p->skipline / 2; |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
41 ss = src * (h / 4 + p->skipline / 2); |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
42 dd = w / 4; |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
43 } else { |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
44 i = h / 2 - p->skipline; |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
45 ss = src * (h / 2 + p->skipline); |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
46 dd = w / 2; |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
47 } |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
48 fromR += ss; |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
49 for ( ; i > 0; i--) { |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
50 int j; |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
51 unsigned char* t = to; |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
52 unsigned char* sL = fromL; |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
53 unsigned char* sR = fromR; |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
54 |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
55 if (p->scalew == 1) { |
10051
55831d1b371b
fixed a 10l (undefined behavior) and made the other parameters configurable
rfelker
parents:
9593
diff
changeset
|
56 for (j = dd; j > 0; j--) { |
55831d1b371b
fixed a 10l (undefined behavior) and made the other parameters configurable
rfelker
parents:
9593
diff
changeset
|
57 *t++ = (sL[0] + sL[1]) / 2; |
55831d1b371b
fixed a 10l (undefined behavior) and made the other parameters configurable
rfelker
parents:
9593
diff
changeset
|
58 sL+=2; |
55831d1b371b
fixed a 10l (undefined behavior) and made the other parameters configurable
rfelker
parents:
9593
diff
changeset
|
59 } |
55831d1b371b
fixed a 10l (undefined behavior) and made the other parameters configurable
rfelker
parents:
9593
diff
changeset
|
60 for (j = dd ; j > 0; j--) { |
55831d1b371b
fixed a 10l (undefined behavior) and made the other parameters configurable
rfelker
parents:
9593
diff
changeset
|
61 *t++ = (sR[0] + sR[1]) / 2; |
55831d1b371b
fixed a 10l (undefined behavior) and made the other parameters configurable
rfelker
parents:
9593
diff
changeset
|
62 sR+=2; |
55831d1b371b
fixed a 10l (undefined behavior) and made the other parameters configurable
rfelker
parents:
9593
diff
changeset
|
63 } |
9404
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
64 } else { |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
65 for (j = dd * 2 ; j > 0; j--) |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
66 *t++ = *sL++; |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
67 for (j = dd * 2 ; j > 0; j--) |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
68 *t++ = *sR++; |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
69 } |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
70 if (p->scaleh == 1) { |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
71 memcpy(to + dst, to, dst); |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
72 to += dst; |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
73 } |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
74 to += dst; |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
75 fromL += src; |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
76 fromR += src; |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
77 } |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
78 //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
|
79 } |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
80 } |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
81 |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
82 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi) |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
83 { |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
84 mp_image_t *dmpi; |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
85 |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
86 // hope we'll get DR buffer: |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
87 dmpi=vf_get_image(vf->next, IMGFMT_YV12, |
16138
6cada718a809
If scaleh == 1 our destination image must be readable
reimar
parents:
14793
diff
changeset
|
88 MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE | |
6cada718a809
If scaleh == 1 our destination image must be readable
reimar
parents:
14793
diff
changeset
|
89 (vf->priv->scaleh == 1) ? MP_IMGFLAG_READABLE : 0, |
9404
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
90 mpi->w * vf->priv->scalew, |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
91 mpi->h / vf->priv->scaleh - vf->priv->skipline); |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
92 |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
93 toright(dmpi->planes, mpi->planes, dmpi->stride, |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
94 mpi->stride, mpi->w, mpi->h, vf->priv); |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
95 |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
96 return vf_next_put_image(vf,dmpi); |
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 |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
99 static int config(struct vf_instance_s* vf, |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
100 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
|
101 unsigned int flags, unsigned int outfmt) |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
102 { |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
103 /* FIXME - also support UYVY output? */ |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
104 return vf_next_config(vf, width * vf->priv->scalew, |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
105 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
|
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 |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
109 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
|
110 { |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
111 /* 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
|
112 switch (fmt) { |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
113 case IMGFMT_YV12: |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
114 case IMGFMT_IYUV: |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
115 case IMGFMT_I420: |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
116 return vf_next_query_format(vf, IMGFMT_YV12); |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
117 } |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
118 return 0; |
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 |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
121 static void uninit(struct vf_instance_s* vf) |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
122 { |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
123 free(vf->priv); |
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 |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
126 static int open(vf_instance_t *vf, char* args) |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
127 { |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
128 vf->config=config; |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
129 vf->query_format=query_format; |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
130 vf->put_image=put_image; |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
131 vf->uninit=uninit; |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
132 |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
133 vf->priv = calloc(1, sizeof (struct vf_priv_s)); |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
134 vf->priv->skipline = 0; |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
135 vf->priv->scalew = 1; |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
136 vf->priv->scaleh = 2; |
10051
55831d1b371b
fixed a 10l (undefined behavior) and made the other parameters configurable
rfelker
parents:
9593
diff
changeset
|
137 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
|
138 |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
139 return 1; |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
140 } |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
141 |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
142 vf_info_t vf_info_down3dright = { |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
143 "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
|
144 "down3dright", |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
145 "Zdenek Kabelac", |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
146 "", |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9404
diff
changeset
|
147 open, |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9404
diff
changeset
|
148 NULL |
9404
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
149 }; |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
150 |