annotate libmpcodecs/vf_fil.c @ 25412:058a51cf2f57

Fix the expand text's format by the source.
author ulion
date Mon, 17 Dec 2007 15:29:42 +0000
parents 00fff9a3b735
children 0f1b5b68af32
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
17012
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 11242
diff changeset
5 #include "config.h"
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 11242
diff changeset
6 #include "mp_msg.h"
11242
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 struct vf_priv_s {
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
12 int interleave;
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
13 int height;
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
14 int width;
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
15 int stridefactor;
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
16 };
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
17
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 static int config(struct vf_instance_s* vf,
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
21 int width, int height, int d_width, int d_height,
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
22 unsigned int flags, unsigned int outfmt){
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
23 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
24
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
25 #if 0
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
26 if(mpi->flags&MP_IMGFLAG_PLANAR)
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
27 pixel_stride= mpi->stride[0];
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
28 else
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
29 pixel_stride= 8*mpi->stride[0] / mpi->bpp;
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
30
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
31 #endif
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 if(vf->priv->interleave){
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
34 vf->priv->height= 2*height;
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
35 vf->priv->width= width - (pixel_stride/2);
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
36 vf->priv->stridefactor=1;
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
37 }else{
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
38 vf->priv->height= height/2;
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
39 vf->priv->width= width + pixel_stride;
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
40 vf->priv->stridefactor=4;
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
41 }
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
42 //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
43
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
44 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
45 (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
46 }
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
47
17906
20aca9baf5d8 passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents: 17012
diff changeset
48 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
11242
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
49 if(mpi->flags&MP_IMGFLAG_DIRECT){
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
50 // we've used DR, so we're ready...
17906
20aca9baf5d8 passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents: 17012
diff changeset
51 return vf_next_put_image(vf,(mp_image_t*)mpi->priv, pts);
11242
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
52 }
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
53
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
54 vf->dmpi=vf_get_image(vf->next,mpi->imgfmt,
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
55 MP_IMGTYPE_EXPORT, MP_IMGFLAG_ACCEPT_STRIDE,
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
56 vf->priv->width, vf->priv->height);
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
57
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
58 // set up mpi as a double-stride image of dmpi:
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
59 vf->dmpi->planes[0]=mpi->planes[0];
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
60 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
61 if(vf->dmpi->flags&MP_IMGFLAG_PLANAR){
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
62 vf->dmpi->planes[1]=mpi->planes[1];
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
63 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
64 vf->dmpi->planes[2]=mpi->planes[2];
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
65 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
66 } else
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
67 vf->dmpi->planes[1]=mpi->planes[1]; // passthru bgr8 palette!!!
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
68
17906
20aca9baf5d8 passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents: 17012
diff changeset
69 return vf_next_put_image(vf,vf->dmpi, pts);
11242
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
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 static void uninit(struct vf_instance_s* vf)
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 free(vf->priv);
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
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
79 static int open(vf_instance_t *vf, char* args){
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
80 vf->config=config;
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
81 vf->put_image=put_image;
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
82 vf->uninit=uninit;
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
83 vf->default_reqs=VFCAP_ACCEPT_STRIDE;
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
84 vf->priv=calloc(1, sizeof(struct vf_priv_s));
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
85 vf->priv->interleave= args && (*args == 'i');
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
86 return 1;
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
87 }
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
88
25221
00fff9a3b735 Make all vf_info_t structs const
reimar
parents: 23373
diff changeset
89 const vf_info_t vf_info_fil = {
11242
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
90 "fast (de)interleaver",
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
91 "fil",
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
92 "Michael Niedermayer",
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
93 "",
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
94 open,
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
95 NULL
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
96 };
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
97
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
98 //===========================================================================//