comparison libmpcodecs/vf_flip.c @ 10141:7d6a854a5fe5

cleanup, use vf->dmpi rather than vf->priv->dmpi for consistency
author rfelker
date Tue, 20 May 2003 18:36:55 +0000
parents e9a2af584986
children 05aa13cdf92f
comparison
equal deleted inserted replaced
10140:30cad6ad9dbc 10141:7d6a854a5fe5
6 #include "../mp_msg.h" 6 #include "../mp_msg.h"
7 7
8 #include "mp_image.h" 8 #include "mp_image.h"
9 #include "vf.h" 9 #include "vf.h"
10 10
11 #include "../libvo/fastmemcpy.h"
12
13 struct vf_priv_s {
14 mp_image_t *dmpi;
15 };
16 11
17 //===========================================================================// 12 //===========================================================================//
18 13
19 static int config(struct vf_instance_s* vf, 14 static int config(struct vf_instance_s* vf,
20 int width, int height, int d_width, int d_height, 15 int width, int height, int d_width, int d_height,
24 } 19 }
25 20
26 static void get_image(struct vf_instance_s* vf, mp_image_t *mpi){ 21 static void get_image(struct vf_instance_s* vf, mp_image_t *mpi){
27 if(mpi->flags&MP_IMGFLAG_ACCEPT_STRIDE){ 22 if(mpi->flags&MP_IMGFLAG_ACCEPT_STRIDE){
28 // try full DR ! 23 // try full DR !
29 vf->priv->dmpi=vf_get_image(vf->next,mpi->imgfmt, 24 vf->dmpi=vf_get_image(vf->next,mpi->imgfmt,
30 mpi->type, mpi->flags, mpi->width, mpi->height); 25 mpi->type, mpi->flags, mpi->width, mpi->height);
31 // set up mpi as a upside-down image of dmpi: 26 // set up mpi as a upside-down image of dmpi:
32 mpi->planes[0]=vf->priv->dmpi->planes[0]+ 27 mpi->planes[0]=vf->dmpi->planes[0]+
33 vf->priv->dmpi->stride[0]*(vf->priv->dmpi->height-1); 28 vf->dmpi->stride[0]*(vf->dmpi->height-1);
34 mpi->stride[0]=-vf->priv->dmpi->stride[0]; 29 mpi->stride[0]=-vf->dmpi->stride[0];
35 if(mpi->flags&MP_IMGFLAG_PLANAR){ 30 if(mpi->flags&MP_IMGFLAG_PLANAR){
36 mpi->planes[1]=vf->priv->dmpi->planes[1]+ 31 mpi->planes[1]=vf->dmpi->planes[1]+
37 vf->priv->dmpi->stride[1]*((vf->priv->dmpi->height>>mpi->chroma_y_shift)-1); 32 vf->dmpi->stride[1]*((vf->dmpi->height>>mpi->chroma_y_shift)-1);
38 mpi->stride[1]=-vf->priv->dmpi->stride[1]; 33 mpi->stride[1]=-vf->dmpi->stride[1];
39 mpi->planes[2]=vf->priv->dmpi->planes[2]+ 34 mpi->planes[2]=vf->dmpi->planes[2]+
40 vf->priv->dmpi->stride[2]*((vf->priv->dmpi->height>>mpi->chroma_y_shift)-1); 35 vf->dmpi->stride[2]*((vf->dmpi->height>>mpi->chroma_y_shift)-1);
41 mpi->stride[2]=-vf->priv->dmpi->stride[2]; 36 mpi->stride[2]=-vf->dmpi->stride[2];
42 } 37 }
43 mpi->flags|=MP_IMGFLAG_DIRECT; 38 mpi->flags|=MP_IMGFLAG_DIRECT;
44 mpi->priv=(void*)vf->priv->dmpi; 39 mpi->priv=(void*)vf->dmpi;
45 } 40 }
46 } 41 }
47 42
48 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi){ 43 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi){
49 if(mpi->flags&MP_IMGFLAG_DIRECT){ 44 if(mpi->flags&MP_IMGFLAG_DIRECT){
51 if(!(mpi->flags&MP_IMGFLAG_PLANAR)) 46 if(!(mpi->flags&MP_IMGFLAG_PLANAR))
52 ((mp_image_t*)mpi->priv)->planes[1] = mpi->planes[1]; // passthrough rgb8 palette 47 ((mp_image_t*)mpi->priv)->planes[1] = mpi->planes[1]; // passthrough rgb8 palette
53 return vf_next_put_image(vf,(mp_image_t*)mpi->priv); 48 return vf_next_put_image(vf,(mp_image_t*)mpi->priv);
54 } 49 }
55 50
56 vf->priv->dmpi=vf_get_image(vf->next,mpi->imgfmt, 51 vf->dmpi=vf_get_image(vf->next,mpi->imgfmt,
57 MP_IMGTYPE_EXPORT, MP_IMGFLAG_ACCEPT_STRIDE, 52 MP_IMGTYPE_EXPORT, MP_IMGFLAG_ACCEPT_STRIDE,
58 mpi->width, mpi->height); 53 mpi->width, mpi->height);
59 54
60 // set up mpi as a upside-down image of dmpi: 55 // set up mpi as a upside-down image of dmpi:
61 vf->priv->dmpi->planes[0]=mpi->planes[0]+ 56 vf->dmpi->planes[0]=mpi->planes[0]+
62 mpi->stride[0]*(mpi->height-1); 57 mpi->stride[0]*(mpi->height-1);
63 vf->priv->dmpi->stride[0]=-mpi->stride[0]; 58 vf->dmpi->stride[0]=-mpi->stride[0];
64 if(vf->priv->dmpi->flags&MP_IMGFLAG_PLANAR){ 59 if(vf->dmpi->flags&MP_IMGFLAG_PLANAR){
65 vf->priv->dmpi->planes[1]=mpi->planes[1]+ 60 vf->dmpi->planes[1]=mpi->planes[1]+
66 mpi->stride[1]*((mpi->height>>mpi->chroma_y_shift)-1); 61 mpi->stride[1]*((mpi->height>>mpi->chroma_y_shift)-1);
67 vf->priv->dmpi->stride[1]=-mpi->stride[1]; 62 vf->dmpi->stride[1]=-mpi->stride[1];
68 vf->priv->dmpi->planes[2]=mpi->planes[2]+ 63 vf->dmpi->planes[2]=mpi->planes[2]+
69 mpi->stride[2]*((mpi->height>>mpi->chroma_y_shift)-1); 64 mpi->stride[2]*((mpi->height>>mpi->chroma_y_shift)-1);
70 vf->priv->dmpi->stride[2]=-mpi->stride[2]; 65 vf->dmpi->stride[2]=-mpi->stride[2];
71 } else 66 } else
72 vf->priv->dmpi->planes[1]=mpi->planes[1]; // passthru bgr8 palette!!! 67 vf->dmpi->planes[1]=mpi->planes[1]; // passthru bgr8 palette!!!
73 68
74 return vf_next_put_image(vf,vf->priv->dmpi); 69 return vf_next_put_image(vf,vf->dmpi);
75 } 70 }
76 71
77 //===========================================================================// 72 //===========================================================================//
78 73
79 static int open(vf_instance_t *vf, char* args){ 74 static int open(vf_instance_t *vf, char* args){
80 vf->config=config; 75 vf->config=config;
81 vf->get_image=get_image; 76 vf->get_image=get_image;
82 vf->put_image=put_image; 77 vf->put_image=put_image;
83 vf->default_reqs=VFCAP_ACCEPT_STRIDE; 78 vf->default_reqs=VFCAP_ACCEPT_STRIDE;
84 vf->priv=malloc(sizeof(struct vf_priv_s));
85 return 1; 79 return 1;
86 } 80 }
87 81
88 vf_info_t vf_info_flip = { 82 vf_info_t vf_info_flip = {
89 "flip image upside-down", 83 "flip image upside-down",