annotate libmpcodecs/vf_fil.c @ 15007:c03962274c4b

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