Mercurial > mplayer.hg
comparison libmpcodecs/vf_flip.c @ 5557:2d0b4090497f
new filter: flip
author | arpi |
---|---|
date | Thu, 11 Apr 2002 03:17:14 +0000 |
parents | |
children | 0b301fec999a |
comparison
equal
deleted
inserted
replaced
5556:4016b44a1230 | 5557:2d0b4090497f |
---|---|
1 #include <stdio.h> | |
2 #include <stdlib.h> | |
3 #include <string.h> | |
4 | |
5 #include "../config.h" | |
6 #include "../mp_msg.h" | |
7 | |
8 #include "../mp_image.h" | |
9 #include "vf.h" | |
10 | |
11 #include "../libvo/fastmemcpy.h" | |
12 | |
13 struct vf_priv_s { | |
14 mp_image_t *dmpi; | |
15 }; | |
16 | |
17 //===========================================================================// | |
18 | |
19 static void get_image(struct vf_instance_s* vf, mp_image_t *mpi){ | |
20 if(mpi->flags&MP_IMGFLAG_ACCEPT_STRIDE){ | |
21 // try full DR ! | |
22 vf->priv->dmpi=vf_get_image(vf->next,mpi->imgfmt, | |
23 mpi->type, mpi->flags, mpi->width, mpi->height); | |
24 // set up mpi as a upside-down image of dmpi: | |
25 mpi->planes[0]=vf->priv->dmpi->planes[0]+ | |
26 vf->priv->dmpi->stride[0]*(vf->priv->dmpi->height-1); | |
27 mpi->stride[0]=-vf->priv->dmpi->stride[0]; | |
28 if(mpi->flags&MP_IMGFLAG_PLANAR){ | |
29 mpi->planes[1]=vf->priv->dmpi->planes[1]+ | |
30 vf->priv->dmpi->stride[1]*((vf->priv->dmpi->height>>1)-1); | |
31 mpi->stride[1]=-vf->priv->dmpi->stride[1]; | |
32 mpi->planes[2]=vf->priv->dmpi->planes[2]+ | |
33 vf->priv->dmpi->stride[2]*((vf->priv->dmpi->height>>1)-1); | |
34 mpi->stride[2]=-vf->priv->dmpi->stride[2]; | |
35 } | |
36 mpi->flags|=MP_IMGFLAG_DIRECT; | |
37 } | |
38 } | |
39 | |
40 static void put_image(struct vf_instance_s* vf, mp_image_t *mpi){ | |
41 if(mpi->flags&MP_IMGFLAG_DIRECT){ | |
42 vf_next_put_image(vf,vf->priv->dmpi); | |
43 return; // we've used DR, so we're ready... | |
44 } | |
45 | |
46 // hope we'll get DR buffer: | |
47 vf->priv->dmpi=vf_get_image(vf->next,mpi->imgfmt, | |
48 MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE, | |
49 mpi->width, mpi->height); | |
50 | |
51 // set up mpi as a upside-down image of dmpi: | |
52 vf->priv->dmpi->planes[0]=mpi->planes[0]+ | |
53 mpi->stride[0]*(mpi->height-1); | |
54 vf->priv->dmpi->stride[0]=-mpi->stride[0]; | |
55 if(vf->priv->dmpi->flags&MP_IMGFLAG_PLANAR){ | |
56 vf->priv->dmpi->planes[1]=mpi->planes[1]+ | |
57 mpi->stride[1]*((mpi->height>>1)-1); | |
58 vf->priv->dmpi->stride[1]=-mpi->stride[1]; | |
59 vf->priv->dmpi->planes[2]=mpi->planes[2]+ | |
60 mpi->stride[2]*((mpi->height>>1)-1); | |
61 vf->priv->dmpi->stride[2]=-mpi->stride[2]; | |
62 } | |
63 | |
64 vf_next_put_image(vf,vf->priv->dmpi); | |
65 } | |
66 | |
67 //===========================================================================// | |
68 | |
69 static int open(vf_instance_t *vf, char* args){ | |
70 vf->get_image=get_image; | |
71 vf->put_image=put_image; | |
72 vf->priv=malloc(sizeof(struct vf_priv_s)); | |
73 return 1; | |
74 } | |
75 | |
76 vf_info_t vf_info_flip = { | |
77 "flip image upside-down", | |
78 "flip", | |
79 "A'rpi", | |
80 "", | |
81 open | |
82 }; | |
83 | |
84 //===========================================================================// |