Mercurial > mplayer.hg
annotate libmpcodecs/vf_down3dright.c @ 15593:a7abe85e8b41
avoid lrintf redeclaration
author | henry |
---|---|
date | Mon, 30 May 2005 08:18:03 +0000 |
parents | 44fbb21a4eba |
children | 6cada718a809 |
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, |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
88 MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE, |
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 |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
95 return vf_next_put_image(vf,dmpi); |
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 |
7a43a52b9f60
down3dright filter by kabi (converts between 2 common stereoscopic systems)
michael
parents:
diff
changeset
|
141 vf_info_t vf_info_down3dright = { |
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 |