comparison libmpcodecs/vf_fil.c @ 11242:34770e3d9654

fast deinterleaver (= il filter with stride/width/height tricks)
author michael
date Wed, 22 Oct 2003 21:21:52 +0000
parents
children 6ff3379a0862
comparison
equal deleted inserted replaced
11241:c8b84bb55089 11242:34770e3d9654
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 interleave;
15 int height;
16 int width;
17 int stridefactor;
18 };
19
20 //===========================================================================//
21
22 static int config(struct vf_instance_s* vf,
23 int width, int height, int d_width, int d_height,
24 unsigned int flags, unsigned int outfmt){
25 int pixel_stride= (width+15)&~15; //FIXME this is ust a guess ... especially for non planar its somewhat bad one
26
27 #if 0
28 if(mpi->flags&MP_IMGFLAG_PLANAR)
29 pixel_stride= mpi->stride[0];
30 else
31 pixel_stride= 8*mpi->stride[0] / mpi->bpp;
32
33 #endif
34
35 if(vf->priv->interleave){
36 vf->priv->height= 2*height;
37 vf->priv->width= width - (pixel_stride/2);
38 vf->priv->stridefactor=1;
39 }else{
40 vf->priv->height= height/2;
41 vf->priv->width= width + pixel_stride;
42 vf->priv->stridefactor=4;
43 }
44 //printf("hX %d %d %d\n", vf->priv->width,vf->priv->height,vf->priv->stridefactor);
45
46 return vf_next_config(vf, vf->priv->width, vf->priv->height,
47 (d_width*vf->priv->stridefactor)>>1, 2*d_height/vf->priv->stridefactor, flags, outfmt);
48 }
49
50 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi){
51 if(mpi->flags&MP_IMGFLAG_DIRECT){
52 // we've used DR, so we're ready...
53 return vf_next_put_image(vf,(mp_image_t*)mpi->priv);
54 }
55
56 vf->dmpi=vf_get_image(vf->next,mpi->imgfmt,
57 MP_IMGTYPE_EXPORT, MP_IMGFLAG_ACCEPT_STRIDE,
58 vf->priv->width, vf->priv->height);
59
60 // set up mpi as a double-stride image of dmpi:
61 vf->dmpi->planes[0]=mpi->planes[0];
62 vf->dmpi->stride[0]=(mpi->stride[0]*vf->priv->stridefactor)>>1;
63 if(vf->dmpi->flags&MP_IMGFLAG_PLANAR){
64 vf->dmpi->planes[1]=mpi->planes[1];
65 vf->dmpi->stride[1]=(mpi->stride[1]*vf->priv->stridefactor)>>1;
66 vf->dmpi->planes[2]=mpi->planes[2];
67 vf->dmpi->stride[2]=(mpi->stride[2]*vf->priv->stridefactor)>>1;
68 } else
69 vf->dmpi->planes[1]=mpi->planes[1]; // passthru bgr8 palette!!!
70
71 return vf_next_put_image(vf,vf->dmpi);
72 }
73
74 //===========================================================================//
75
76 static void uninit(struct vf_instance_s* vf)
77 {
78 free(vf->priv);
79 }
80
81 static int open(vf_instance_t *vf, char* args){
82 vf->config=config;
83 vf->put_image=put_image;
84 vf->uninit=uninit;
85 vf->default_reqs=VFCAP_ACCEPT_STRIDE;
86 vf->priv=calloc(1, sizeof(struct vf_priv_s));
87 vf->priv->interleave= args && (*args == 'i');
88 return 1;
89 }
90
91 vf_info_t vf_info_fil = {
92 "fast (de)interleaver",
93 "fil",
94 "Michael Niedermayer",
95 "",
96 open,
97 NULL
98 };
99
100 //===========================================================================//