vf_fil.c
Go to the documentation of this file.
1 /*
2  * This file is part of MPlayer.
3  *
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.
8  *
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.
13  *
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.
17  */
18 
19 #include <stdio.h>
20 #include <stdlib.h>
21 #include <string.h>
22 
23 #include "config.h"
24 #include "mp_msg.h"
25 
26 #include "mp_image.h"
27 #include "vf.h"
28 
29 struct vf_priv_s {
31  int height;
32  int width;
34 };
35 
36 //===========================================================================//
37 
38 static int config(struct vf_instance *vf,
39  int width, int height, int d_width, int d_height,
40  unsigned int flags, unsigned int outfmt){
41  int pixel_stride= (width+15)&~15; //FIXME this is ust a guess ... especially for non planar its somewhat bad one
42 
43 #if 0
44  if(mpi->flags&MP_IMGFLAG_PLANAR)
45  pixel_stride= mpi->stride[0];
46  else
47  pixel_stride= 8*mpi->stride[0] / mpi->bpp;
48 
49 #endif
50 
51  if(vf->priv->interleave){
52  vf->priv->height= 2*height;
53  vf->priv->width= width - (pixel_stride/2);
54  vf->priv->stridefactor=1;
55  }else{
56  vf->priv->height= height/2;
57  vf->priv->width= width + pixel_stride;
58  vf->priv->stridefactor=4;
59  }
60 //printf("hX %d %d %d\n", vf->priv->width,vf->priv->height,vf->priv->stridefactor);
61 
62  return ff_vf_next_config(vf, vf->priv->width, vf->priv->height,
63  (d_width*vf->priv->stridefactor)>>1, 2*d_height/vf->priv->stridefactor, flags, outfmt);
64 }
65 
66 static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts){
67  if(mpi->flags&MP_IMGFLAG_DIRECT){
68  // we've used DR, so we're ready...
69  return ff_vf_next_put_image(vf,(mp_image_t*)mpi->priv, pts);
70  }
71 
72  vf->dmpi=ff_vf_get_image(vf->next,mpi->imgfmt,
74  vf->priv->width, vf->priv->height);
75 
76  // set up mpi as a double-stride image of dmpi:
77  vf->dmpi->planes[0]=mpi->planes[0];
78  vf->dmpi->stride[0]=(mpi->stride[0]*vf->priv->stridefactor)>>1;
79  if(vf->dmpi->flags&MP_IMGFLAG_PLANAR){
80  vf->dmpi->planes[1]=mpi->planes[1];
81  vf->dmpi->stride[1]=(mpi->stride[1]*vf->priv->stridefactor)>>1;
82  vf->dmpi->planes[2]=mpi->planes[2];
83  vf->dmpi->stride[2]=(mpi->stride[2]*vf->priv->stridefactor)>>1;
84  } else
85  vf->dmpi->planes[1]=mpi->planes[1]; // passthru bgr8 palette!!!
86 
87  return ff_vf_next_put_image(vf,vf->dmpi, pts);
88 }
89 
90 //===========================================================================//
91 
92 static void uninit(struct vf_instance *vf)
93 {
94  free(vf->priv);
95 }
96 
97 static int vf_open(vf_instance_t *vf, char *args){
98  vf->config=config;
99  vf->put_image=put_image;
100  vf->uninit=uninit;
102  vf->priv=calloc(1, sizeof(struct vf_priv_s));
103  vf->priv->interleave= args && (*args == 'i');
104  return 1;
105 }
106 
108  "fast (de)interleaver",
109  "fil",
110  "Michael Niedermayer",
111  "",
112  vf_open,
113  NULL
114 };
115 
116 //===========================================================================//
unsigned int imgfmt
Definition: mp_image.h:130
static int config(struct vf_instance *vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt)
Definition: vf_fil.c:38
mp_image_t * ff_vf_get_image(vf_instance_t *vf, unsigned int outfmt, int mp_imgtype, int mp_imgflag, int w, int h)
Definition: vf_mp.c:380
#define MP_IMGTYPE_EXPORT
Definition: mp_image.h:100
void(* uninit)(struct vf_instance *vf)
Definition: vf.h:74
int ff_vf_next_config(struct vf_instance *vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt)
Definition: vf_mp.c:584
int(* put_image)(struct vf_instance *vf, mp_image_t *mpi, double pts)
Definition: vf.h:68
Definition: vf.h:31
unsigned char * planes[MP_MAX_PLANES]
Definition: mp_image.h:133
int stride[MP_MAX_PLANES]
Definition: mp_image.h:134
static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts)
Definition: vf_fil.c:66
static void uninit(struct vf_instance *vf)
Definition: vf_fil.c:92
int width
Definition: vf_fil.c:32
int stridefactor
Definition: vf_fil.c:33
int interleave
Definition: vf_fil.c:30
unsigned int default_reqs
Definition: vf.h:79
struct vf_instance * next
Definition: vf.h:84
NULL
Definition: eval.c:55
int(* config)(struct vf_instance *vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt)
Definition: vf.h:59
void * priv
Definition: mp_image.h:148
static int vf_open(vf_instance_t *vf, char *args)
Definition: vf_fil.c:97
static int flags
Definition: cpu.c:23
const vf_info_t ff_vf_info_fil
Definition: vf_fil.c:107
#define MP_IMGFLAG_PLANAR
Definition: mp_image.h:76
int ff_vf_next_put_image(struct vf_instance *vf, mp_image_t *mpi, double pts)
Definition: vf_mp.c:539
#define MP_IMGFLAG_ACCEPT_STRIDE
Definition: mp_image.h:63
struct vf_priv_s * priv
Definition: vf.h:86
#define MP_IMGFLAG_DIRECT
Definition: mp_image.h:91
#define VFCAP_ACCEPT_STRIDE
Definition: vfcap.h:44
Definition: vf.h:56
unsigned int flags
Definition: mp_image.h:126
int height
Definition: vf_fil.c:31
mp_image_t * dmpi
Definition: vf.h:85
MUSIC TECHNOLOGY GROUP UNIVERSITAT POMPEU FABRA Free Non Commercial Binary License Agreement UNIVERSITAT POMPEU OR INDICATING ACCEPTANCE BY SELECTING THE ACCEPT BUTTON ON ANY DOWNLOAD OR INSTALL YOU ACCEPT THE TERMS OF THE LICENSE SUMMARY TABLE Software MELODIA Melody Extraction vamp plug in Licensor Music Technology Group Universitat Pompeu Plaça de la Spain Permitted purposes Non commercial internal research and validation and educational purposes only All commercial uses in a production either internal or are prohibited by this license and require an additional commercial exploitation license TERMS AND CONDITIONS SOFTWARE Software means the software programs identified herein in binary any other machine readable any updates or error corrections provided by and any user programming guides and other documentation provided to you by UPF under this Agreement LICENSE Subject to the terms and conditions of this UPF grants you a royalty free