comparison libmpcodecs/vf_field.c @ 9072:d7237ee9db7f

new video filter to extract a single field using stride arithmetic, i.e. without using cpu time
author rfelker
date Thu, 23 Jan 2003 16:33:57 +0000
parents
children 7df93217d82c
comparison
equal deleted inserted replaced
9071:25baacd1c650 9072:d7237ee9db7f
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 int field;
15 mp_image_t *dmpi;
16 };
17
18 //===========================================================================//
19
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 return vf_next_config(vf,width,height/2,d_width,d_height,flags,outfmt);
24 }
25
26 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi){
27 if(mpi->flags&MP_IMGFLAG_DIRECT){
28 // we've used DR, so we're ready...
29 return vf_next_put_image(vf,(mp_image_t*)mpi->priv);
30 }
31
32 vf->priv->dmpi=vf_get_image(vf->next,mpi->imgfmt,
33 MP_IMGTYPE_EXPORT, MP_IMGFLAG_ACCEPT_STRIDE,
34 mpi->width, mpi->height/2);
35
36 // set up mpi as a double-stride image of dmpi:
37 vf->priv->dmpi->planes[0]=mpi->planes[0]+mpi->stride[0]*vf->priv->field;
38 vf->priv->dmpi->stride[0]=2*mpi->stride[0];
39 if(vf->priv->dmpi->flags&MP_IMGFLAG_PLANAR){
40 vf->priv->dmpi->planes[1]=mpi->planes[1]+
41 mpi->stride[1]*vf->priv->field;
42 vf->priv->dmpi->stride[1]=2*mpi->stride[1];
43 vf->priv->dmpi->planes[2]=mpi->planes[2]+
44 mpi->stride[2]*vf->priv->field;
45 vf->priv->dmpi->stride[2]=2*mpi->stride[2];
46 } else
47 vf->priv->dmpi->planes[1]=mpi->planes[1]; // passthru bgr8 palette!!!
48
49 return vf_next_put_image(vf,vf->priv->dmpi);
50 }
51
52 //===========================================================================//
53
54 // FIXME - do we need to free dmpi on uninit?
55
56 static int open(vf_instance_t *vf, char* args){
57 vf->config=config;
58 vf->put_image=put_image;
59 vf->default_reqs=VFCAP_ACCEPT_STRIDE;
60 vf->priv=calloc(1, sizeof(struct vf_priv_s));
61 if (args) sscanf(args, "%d", &vf->priv->field);
62 vf->priv->field &= 1;
63 return 1;
64 }
65
66 vf_info_t vf_info_field = {
67 "extract single field",
68 "field",
69 "Rich Felker",
70 "",
71 open
72 };
73
74 //===========================================================================//