Initialize local variable, avoids a possible crash due to using an
[mplayer/glamo.git] / libmpcodecs / vf_fil.c
blob110c5d7b47bc947b8c72f0f5de53ff74680f9540
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
5 #include "config.h"
6 #include "mp_msg.h"
8 #include "mp_image.h"
9 #include "vf.h"
11 struct vf_priv_s {
12 int interleave;
13 int height;
14 int width;
15 int stridefactor;
18 //===========================================================================//
20 static int config(struct vf_instance_s* vf,
21 int width, int height, int d_width, int d_height,
22 unsigned int flags, unsigned int outfmt){
23 int pixel_stride= (width+15)&~15; //FIXME this is ust a guess ... especially for non planar its somewhat bad one
25 #if 0
26 if(mpi->flags&MP_IMGFLAG_PLANAR)
27 pixel_stride= mpi->stride[0];
28 else
29 pixel_stride= 8*mpi->stride[0] / mpi->bpp;
31 #endif
33 if(vf->priv->interleave){
34 vf->priv->height= 2*height;
35 vf->priv->width= width - (pixel_stride/2);
36 vf->priv->stridefactor=1;
37 }else{
38 vf->priv->height= height/2;
39 vf->priv->width= width + pixel_stride;
40 vf->priv->stridefactor=4;
42 //printf("hX %d %d %d\n", vf->priv->width,vf->priv->height,vf->priv->stridefactor);
44 return vf_next_config(vf, vf->priv->width, vf->priv->height,
45 (d_width*vf->priv->stridefactor)>>1, 2*d_height/vf->priv->stridefactor, flags, outfmt);
48 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
49 if(mpi->flags&MP_IMGFLAG_DIRECT){
50 // we've used DR, so we're ready...
51 return vf_next_put_image(vf,(mp_image_t*)mpi->priv, pts);
54 vf->dmpi=vf_get_image(vf->next,mpi->imgfmt,
55 MP_IMGTYPE_EXPORT, MP_IMGFLAG_ACCEPT_STRIDE,
56 vf->priv->width, vf->priv->height);
58 // set up mpi as a double-stride image of dmpi:
59 vf->dmpi->planes[0]=mpi->planes[0];
60 vf->dmpi->stride[0]=(mpi->stride[0]*vf->priv->stridefactor)>>1;
61 if(vf->dmpi->flags&MP_IMGFLAG_PLANAR){
62 vf->dmpi->planes[1]=mpi->planes[1];
63 vf->dmpi->stride[1]=(mpi->stride[1]*vf->priv->stridefactor)>>1;
64 vf->dmpi->planes[2]=mpi->planes[2];
65 vf->dmpi->stride[2]=(mpi->stride[2]*vf->priv->stridefactor)>>1;
66 } else
67 vf->dmpi->planes[1]=mpi->planes[1]; // passthru bgr8 palette!!!
69 return vf_next_put_image(vf,vf->dmpi, pts);
72 //===========================================================================//
74 static void uninit(struct vf_instance_s* vf)
76 free(vf->priv);
79 static int open(vf_instance_t *vf, char* args){
80 vf->config=config;
81 vf->put_image=put_image;
82 vf->uninit=uninit;
83 vf->default_reqs=VFCAP_ACCEPT_STRIDE;
84 vf->priv=calloc(1, sizeof(struct vf_priv_s));
85 vf->priv->interleave= args && (*args == 'i');
86 return 1;
89 const vf_info_t vf_info_fil = {
90 "fast (de)interleaver",
91 "fil",
92 "Michael Niedermayer",
93 "",
94 open,
95 NULL
98 //===========================================================================//