10 #include "img_format.h"
14 #include "libvo/fastmemcpy.h"
15 #include "postproc/rgb2rgb.h"
23 static void toright(unsigned char *dst
[3], unsigned char *src
[3],
24 int dststride
[3], int srcstride
[3],
25 int w
, int h
, struct vf_priv_s
* p
)
29 for (k
= 0; k
< 3; k
++) {
30 unsigned char* fromL
= src
[k
];
31 unsigned char* fromR
= src
[k
];
32 unsigned char* to
= dst
[k
];
33 int src
= srcstride
[k
];
34 int dst
= dststride
[k
];
40 i
= h
/ 4 - p
->skipline
/ 2;
41 ss
= src
* (h
/ 4 + p
->skipline
/ 2);
44 i
= h
/ 2 - p
->skipline
;
45 ss
= src
* (h
/ 2 + p
->skipline
);
51 unsigned char* t
= to
;
52 unsigned char* sL
= fromL
;
53 unsigned char* sR
= fromR
;
56 for (j
= dd
; j
> 0; j
--) {
57 *t
++ = (sL
[0] + sL
[1]) / 2;
60 for (j
= dd
; j
> 0; j
--) {
61 *t
++ = (sR
[0] + sR
[1]) / 2;
65 for (j
= dd
* 2 ; j
> 0; j
--)
67 for (j
= dd
* 2 ; j
> 0; j
--)
71 memcpy(to
+ dst
, to
, dst
);
78 //printf("K %d %d %d %d %d \n", k, w, h, src, dst);
82 static int put_image(struct vf_instance_s
* vf
, mp_image_t
*mpi
, double pts
)
86 // hope we'll get DR buffer:
87 dmpi
=vf_get_image(vf
->next
, IMGFMT_YV12
,
88 MP_IMGTYPE_TEMP
, MP_IMGFLAG_ACCEPT_STRIDE
|
89 (vf
->priv
->scaleh
== 1) ? MP_IMGFLAG_READABLE
: 0,
90 mpi
->w
* vf
->priv
->scalew
,
91 mpi
->h
/ vf
->priv
->scaleh
- vf
->priv
->skipline
);
93 toright(dmpi
->planes
, mpi
->planes
, dmpi
->stride
,
94 mpi
->stride
, mpi
->w
, mpi
->h
, vf
->priv
);
96 return vf_next_put_image(vf
,dmpi
, pts
);
99 static int config(struct vf_instance_s
* vf
,
100 int width
, int height
, int d_width
, int d_height
,
101 unsigned int flags
, unsigned int outfmt
)
103 /* FIXME - also support UYVY output? */
104 return vf_next_config(vf
, width
* vf
->priv
->scalew
,
105 height
/ vf
->priv
->scaleh
- vf
->priv
->skipline
, d_width
, d_height
, flags
, IMGFMT_YV12
);
109 static int query_format(struct vf_instance_s
* vf
, unsigned int fmt
)
111 /* FIXME - really any YUV 4:2:0 input format should work */
116 return vf_next_query_format(vf
, IMGFMT_YV12
);
121 static void uninit(struct vf_instance_s
* vf
)
126 static int open(vf_instance_t
*vf
, char* args
)
129 vf
->query_format
=query_format
;
130 vf
->put_image
=put_image
;
133 vf
->priv
= calloc(1, sizeof (struct vf_priv_s
));
134 vf
->priv
->skipline
= 0;
135 vf
->priv
->scalew
= 1;
136 vf
->priv
->scaleh
= 2;
137 if (args
) sscanf(args
, "%d:%d:%d", &vf
->priv
->skipline
, &vf
->priv
->scalew
, &vf
->priv
->scaleh
);
142 vf_info_t vf_info_down3dright
= {
143 "convert stereo movie from top-bottom to left-right field",