annotate libmpcodecs/vf_fil.c @ 35501:7bb176fac55c

Use boolean symbolic constants in Win32 GUI. Use them wherever suitable and useful to make code easier to read.
author ib
date Tue, 04 Dec 2012 20:06:43 +0000
parents 7af3e6f901fd
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
30421
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
1 /*
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
2 * This file is part of MPlayer.
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
3 *
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
4 * MPlayer is free software; you can redistribute it and/or modify
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
5 * it under the terms of the GNU General Public License as published by
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
6 * the Free Software Foundation; either version 2 of the License, or
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
7 * (at your option) any later version.
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
8 *
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
9 * MPlayer is distributed in the hope that it will be useful,
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
12 * GNU General Public License for more details.
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
13 *
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
14 * You should have received a copy of the GNU General Public License along
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
17 */
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
18
11242
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
19 #include <stdio.h>
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
20 #include <stdlib.h>
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
21 #include <string.h>
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
22
17012
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 11242
diff changeset
23 #include "config.h"
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 11242
diff changeset
24 #include "mp_msg.h"
11242
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
25
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
26 #include "mp_image.h"
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
27 #include "vf.h"
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
28
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
29 struct vf_priv_s {
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
30 int interleave;
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
31 int height;
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
32 int width;
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
33 int stridefactor;
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
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
36 //===========================================================================//
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
37
30642
a972c1a4a012 cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents: 30638
diff changeset
38 static int config(struct vf_instance *vf,
11242
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
39 int width, int height, int d_width, int d_height,
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
40 unsigned int flags, unsigned int outfmt){
11242
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
41 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
42
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
43 #if 0
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
44 if(mpi->flags&MP_IMGFLAG_PLANAR)
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
45 pixel_stride= mpi->stride[0];
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
46 else
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
47 pixel_stride= 8*mpi->stride[0] / mpi->bpp;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 25221
diff changeset
48
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 25221
diff changeset
49 #endif
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 25221
diff changeset
50
11242
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
51 if(vf->priv->interleave){
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
52 vf->priv->height= 2*height;
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
53 vf->priv->width= width - (pixel_stride/2);
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
54 vf->priv->stridefactor=1;
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
55 }else{
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
56 vf->priv->height= height/2;
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
57 vf->priv->width= width + pixel_stride;
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
58 vf->priv->stridefactor=4;
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 //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
61
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
62 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
63 (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
64 }
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
65
30642
a972c1a4a012 cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents: 30638
diff changeset
66 static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts){
11242
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
67 if(mpi->flags&MP_IMGFLAG_DIRECT){
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
68 // we've used DR, so we're ready...
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
69 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
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 vf->dmpi=vf_get_image(vf->next,mpi->imgfmt,
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
73 MP_IMGTYPE_EXPORT, MP_IMGFLAG_ACCEPT_STRIDE,
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
74 vf->priv->width, vf->priv->height);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 25221
diff changeset
75
11242
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
76 // set up mpi as a double-stride image of dmpi:
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
77 vf->dmpi->planes[0]=mpi->planes[0];
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
78 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
79 if(vf->dmpi->flags&MP_IMGFLAG_PLANAR){
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
80 vf->dmpi->planes[1]=mpi->planes[1];
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
81 vf->dmpi->stride[1]=(mpi->stride[1]*vf->priv->stridefactor)>>1;
11242
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
82 vf->dmpi->planes[2]=mpi->planes[2];
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
83 vf->dmpi->stride[2]=(mpi->stride[2]*vf->priv->stridefactor)>>1;
11242
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
84 } else
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
85 vf->dmpi->planes[1]=mpi->planes[1]; // passthru bgr8 palette!!!
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 25221
diff changeset
86
17906
20aca9baf5d8 passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents: 17012
diff changeset
87 return vf_next_put_image(vf,vf->dmpi, pts);
11242
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
88 }
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
30642
a972c1a4a012 cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents: 30638
diff changeset
92 static void uninit(struct vf_instance *vf)
11242
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
93 {
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
94 free(vf->priv);
11242
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
30638
a7b908875c14 Rename open() vf initialization function to vf_open().
diego
parents: 30421
diff changeset
97 static int vf_open(vf_instance_t *vf, char *args){
11242
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
98 vf->config=config;
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
99 vf->put_image=put_image;
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
100 vf->uninit=uninit;
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
101 vf->default_reqs=VFCAP_ACCEPT_STRIDE;
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
102 vf->priv=calloc(1, sizeof(struct vf_priv_s));
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
103 vf->priv->interleave= args && (*args == 'i');
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
104 return 1;
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
105 }
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
106
25221
00fff9a3b735 Make all vf_info_t structs const
reimar
parents: 23373
diff changeset
107 const vf_info_t vf_info_fil = {
11242
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
108 "fast (de)interleaver",
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
109 "fil",
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
110 "Michael Niedermayer",
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
111 "",
30638
a7b908875c14 Rename open() vf initialization function to vf_open().
diego
parents: 30421
diff changeset
112 vf_open,
11242
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
113 NULL
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
114 };
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
115
34770e3d9654 fast deinterleaver (= il filter with stride/width/height tricks)
michael
parents:
diff changeset
116 //===========================================================================//