manpage: Fix outdated -vo gl usage example.
[mplayer/glamo.git] / libmpcodecs / vf_down3dright.c
blob1119618e78f1871086b887531dd3c3b41c44e333
1 /*
2 * This file is part of MPlayer.
4 * MPlayer is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * MPlayer is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 #include <stdio.h>
20 #include <stdlib.h>
21 #include <string.h>
22 #include <inttypes.h>
24 #include "config.h"
25 #include "mp_msg.h"
26 #include "cpudetect.h"
28 #include "img_format.h"
29 #include "mp_image.h"
30 #include "vf.h"
32 #include "libvo/fastmemcpy.h"
34 struct vf_priv_s {
35 int skipline;
36 int scalew;
37 int scaleh;
40 static void toright(unsigned char *dst[3], unsigned char *src[3],
41 int dststride[3], int srcstride[3],
42 int w, int h, struct vf_priv_s* p)
44 int k;
46 for (k = 0; k < 3; k++) {
47 unsigned char* fromL = src[k];
48 unsigned char* fromR = src[k];
49 unsigned char* to = dst[k];
50 int src = srcstride[k];
51 int dst = dststride[k];
52 int ss;
53 unsigned int dd;
54 int i;
56 if (k > 0) {
57 i = h / 4 - p->skipline / 2;
58 ss = src * (h / 4 + p->skipline / 2);
59 dd = w / 4;
60 } else {
61 i = h / 2 - p->skipline;
62 ss = src * (h / 2 + p->skipline);
63 dd = w / 2;
65 fromR += ss;
66 for ( ; i > 0; i--) {
67 int j;
68 unsigned char* t = to;
69 unsigned char* sL = fromL;
70 unsigned char* sR = fromR;
72 if (p->scalew == 1) {
73 for (j = dd; j > 0; j--) {
74 *t++ = (sL[0] + sL[1]) / 2;
75 sL+=2;
77 for (j = dd ; j > 0; j--) {
78 *t++ = (sR[0] + sR[1]) / 2;
79 sR+=2;
81 } else {
82 for (j = dd * 2 ; j > 0; j--)
83 *t++ = *sL++;
84 for (j = dd * 2 ; j > 0; j--)
85 *t++ = *sR++;
87 if (p->scaleh == 1) {
88 fast_memcpy(to + dst, to, dst);
89 to += dst;
91 to += dst;
92 fromL += src;
93 fromR += src;
95 //printf("K %d %d %d %d %d \n", k, w, h, src, dst);
99 static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts)
101 mp_image_t *dmpi;
103 // hope we'll get DR buffer:
104 dmpi=vf_get_image(vf->next, IMGFMT_YV12,
105 MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE |
106 (vf->priv->scaleh == 1) ? MP_IMGFLAG_READABLE : 0,
107 mpi->w * vf->priv->scalew,
108 mpi->h / vf->priv->scaleh - vf->priv->skipline);
110 toright(dmpi->planes, mpi->planes, dmpi->stride,
111 mpi->stride, mpi->w, mpi->h, vf->priv);
113 return vf_next_put_image(vf,dmpi, pts);
116 static int config(struct vf_instance *vf,
117 int width, int height, int d_width, int d_height,
118 unsigned int flags, unsigned int outfmt)
120 /* FIXME - also support UYVY output? */
121 return vf_next_config(vf, width * vf->priv->scalew,
122 height / vf->priv->scaleh - vf->priv->skipline, d_width, d_height, flags, IMGFMT_YV12);
126 static int query_format(struct vf_instance *vf, unsigned int fmt)
128 /* FIXME - really any YUV 4:2:0 input format should work */
129 switch (fmt) {
130 case IMGFMT_YV12:
131 case IMGFMT_IYUV:
132 case IMGFMT_I420:
133 return vf_next_query_format(vf, IMGFMT_YV12);
135 return 0;
138 static void uninit(struct vf_instance *vf)
140 free(vf->priv);
143 static int vf_open(vf_instance_t *vf, char *args)
145 vf->config=config;
146 vf->query_format=query_format;
147 vf->put_image=put_image;
148 vf->uninit=uninit;
150 vf->priv = calloc(1, sizeof (struct vf_priv_s));
151 vf->priv->skipline = 0;
152 vf->priv->scalew = 1;
153 vf->priv->scaleh = 2;
154 if (args) sscanf(args, "%d:%d:%d", &vf->priv->skipline, &vf->priv->scalew, &vf->priv->scaleh);
156 return 1;
159 const vf_info_t vf_info_down3dright = {
160 "convert stereo movie from top-bottom to left-right field",
161 "down3dright",
162 "Zdenek Kabelac",
164 vf_open,
165 NULL