Mercurial > mplayer.hg
annotate libmpcodecs/vf_geq.c @ 32540:0143883f2e8b
Remove unused struct element.
author | reimar |
---|---|
date | Sun, 14 Nov 2010 15:34:27 +0000 |
parents | 8fa2f43cb760 |
children | b86ea534cfc7 |
rev | line source |
---|---|
20266 | 1 /* |
26727 | 2 * Copyright (C) 2006 Michael Niedermayer <michaelni@gmx.at> |
3 * | |
4 * This file is part of MPlayer. | |
5 * | |
6 * MPlayer is free software; you can redistribute it and/or modify | |
7 * it under the terms of the GNU General Public License as published by | |
8 * the Free Software Foundation; either version 2 of the License, or | |
9 * (at your option) any later version. | |
10 * | |
11 * MPlayer is distributed in the hope that it will be useful, | |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 * GNU General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU General Public License along | |
17 * with MPlayer; if not, write to the Free Software Foundation, Inc., | |
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
19 */ | |
20266 | 20 |
21 #include <stdio.h> | |
22 #include <stdlib.h> | |
23 #include <string.h> | |
24 #include <math.h> | |
25 #include <inttypes.h> | |
26 | |
27 #include "config.h" | |
28 | |
29 #include "mp_msg.h" | |
30 #include "cpudetect.h" | |
31 | |
24738 | 32 #include "img_format.h" |
33 #include "mp_image.h" | |
34 #include "vf.h" | |
35 | |
20266 | 36 #include "libavcodec/avcodec.h" |
31256 | 37 #include "libavutil/eval.h" |
20266 | 38 |
39 struct vf_priv_s { | |
30987
e1483ae3d93c
Fix build due to FFmpeg r22833 change (typedef rename).
iive
parents:
30642
diff
changeset
|
40 AVExpr * e[3]; |
20456 | 41 int framenum; |
42 mp_image_t *mpi; | |
20266 | 43 }; |
44 | |
30642
a972c1a4a012
cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents:
30638
diff
changeset
|
45 static int config(struct vf_instance *vf, |
20266 | 46 int width, int height, int d_width, int d_height, |
20456 | 47 unsigned int flags, unsigned int outfmt){ |
48 return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt); | |
20266 | 49 } |
50 | |
30642
a972c1a4a012
cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents:
30638
diff
changeset
|
51 static inline double getpix(struct vf_instance *vf, double x, double y, int plane){ |
20270 | 52 int xi, yi; |
53 mp_image_t *mpi= vf->priv->mpi; | |
54 int stride= mpi->stride[plane]; | |
55 uint8_t *src= mpi->planes[plane]; | |
56 xi=x= FFMIN(FFMAX(x, 0), (mpi->w >> (plane ? mpi->chroma_x_shift : 0))-1); | |
57 yi=y= FFMIN(FFMAX(y, 0), (mpi->h >> (plane ? mpi->chroma_y_shift : 0))-1); | |
58 | |
59 x-=xi; | |
60 y-=yi; | |
61 | |
62 return | |
63 (1-y)*((1-x)*src[xi + yi * stride] + x*src[xi + 1 + yi * stride]) | |
64 + y *((1-x)*src[xi + (yi+1) * stride] + x*src[xi + 1 + (yi+1) * stride]); | |
65 } | |
66 | |
67 //FIXME cubic interpolate | |
20266 | 68 //FIXME keep the last few frames |
31543
59a6592b57b7
Fix function prototypes to match the required type.
reimar
parents:
31256
diff
changeset
|
69 static double lum(void *vf, double x, double y){ |
20270 | 70 return getpix(vf, x, y, 0); |
20266 | 71 } |
72 | |
31543
59a6592b57b7
Fix function prototypes to match the required type.
reimar
parents:
31256
diff
changeset
|
73 static double cb(void *vf, double x, double y){ |
20270 | 74 return getpix(vf, x, y, 1); |
20266 | 75 } |
76 | |
31543
59a6592b57b7
Fix function prototypes to match the required type.
reimar
parents:
31256
diff
changeset
|
77 static double cr(void *vf, double x, double y){ |
20270 | 78 return getpix(vf, x, y, 2); |
20266 | 79 } |
80 | |
30642
a972c1a4a012
cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents:
30638
diff
changeset
|
81 static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts){ |
20456 | 82 mp_image_t *dmpi; |
83 int x,y, plane; | |
20455 | 84 |
20456 | 85 if(!(mpi->flags&MP_IMGFLAG_DIRECT)){ |
86 // no DR, so get a new image! hope we'll get DR buffer: | |
87 vf->dmpi=vf_get_image(vf->next,mpi->imgfmt, MP_IMGTYPE_TEMP, | |
88 MP_IMGFLAG_ACCEPT_STRIDE|MP_IMGFLAG_PREFER_ALIGNED_STRIDE, | |
89 mpi->w,mpi->h); | |
90 } | |
20455 | 91 |
20456 | 92 dmpi= vf->dmpi; |
93 vf->priv->mpi= mpi; | |
20455 | 94 |
20456 | 95 vf_clone_mpi_attributes(dmpi, mpi); |
20455 | 96 |
20456 | 97 for(plane=0; plane<3; plane++){ |
98 int w= mpi->w >> (plane ? mpi->chroma_x_shift : 0); | |
99 int h= mpi->h >> (plane ? mpi->chroma_y_shift : 0); | |
100 uint8_t *dst = dmpi->planes[plane]; | |
101 int dst_stride= dmpi->stride[plane]; | |
102 double const_values[]={ | |
103 M_PI, | |
104 M_E, | |
105 0, | |
106 0, | |
107 w, | |
108 h, | |
109 vf->priv->framenum, | |
110 w/(double)mpi->w, | |
111 h/(double)mpi->h, | |
112 0 | |
113 }; | |
114 if (!vf->priv->e[plane]) continue; | |
115 for(y=0; y<h; y++){ | |
116 const_values[3]=y; | |
117 for(x=0; x<w; x++){ | |
118 const_values[2]=x; | |
31256 | 119 dst[x + y * dst_stride] = av_eval_expr(vf->priv->e[plane], |
30989 | 120 const_values, vf); |
20455 | 121 } |
122 } | |
20456 | 123 } |
20455 | 124 |
20456 | 125 vf->priv->framenum++; |
20455 | 126 |
20456 | 127 return vf_next_put_image(vf,dmpi, pts); |
20455 | 128 } |
129 | |
30642
a972c1a4a012
cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents:
30638
diff
changeset
|
130 static void uninit(struct vf_instance *vf){ |
20456 | 131 av_free(vf->priv); |
132 vf->priv=NULL; | |
20455 | 133 } |
134 | |
135 //===========================================================================// | |
30638
a7b908875c14
Rename open() vf initialization function to vf_open().
diego
parents:
27694
diff
changeset
|
136 static int vf_open(vf_instance_t *vf, char *args){ |
20455 | 137 char eq[3][2000] = { { 0 }, { 0 }, { 0 } }; |
31233 | 138 int plane, res; |
20455 | 139 |
140 vf->config=config; | |
141 vf->put_image=put_image; | |
142 // vf->get_image=get_image; | |
143 vf->uninit=uninit; | |
144 vf->priv=av_malloc(sizeof(struct vf_priv_s)); | |
145 memset(vf->priv, 0, sizeof(struct vf_priv_s)); | |
146 | |
20466 | 147 if (args) sscanf(args, "%1999[^:]:%1999[^:]:%1999[^:]", eq[0], eq[1], eq[2]); |
20455 | 148 |
149 if (!eq[1][0]) strncpy(eq[1], eq[0], sizeof(eq[0])-1); | |
150 if (!eq[2][0]) strncpy(eq[2], eq[1], sizeof(eq[0])-1); | |
151 | |
152 for(plane=0; plane<3; plane++){ | |
20266 | 153 static const char *const_names[]={ |
154 "PI", | |
155 "E", | |
156 "X", | |
157 "Y", | |
158 "W", | |
159 "H", | |
160 "N", | |
161 "SW", | |
162 "SH", | |
163 NULL | |
164 }; | |
165 static const char *func2_names[]={ | |
166 "lum", | |
167 "cb", | |
168 "cr", | |
169 "p", | |
170 NULL | |
171 }; | |
20455 | 172 double (*func2[])(void *, double, double)={ |
173 lum, | |
174 cb, | |
175 cr, | |
176 plane==0 ? lum : (plane==1 ? cb : cr), | |
177 NULL | |
178 }; | |
31256 | 179 res = av_parse_expr(&vf->priv->e[plane], eq[plane], const_names, NULL, NULL, func2_names, func2, 0, NULL); |
20266 | 180 |
31233 | 181 if (res < 0) { |
31130
d1f5069bef25
Fix compilation broken by FFmpeg-r23201 that changed the api of error logging.
iive
parents:
30991
diff
changeset
|
182 mp_msg(MSGT_VFILTER, MSGL_ERR, "geq: error loading equation `%s'\n", eq[plane]); |
d1f5069bef25
Fix compilation broken by FFmpeg-r23201 that changed the api of error logging.
iive
parents:
30991
diff
changeset
|
183 return 0; |
20266 | 184 } |
20455 | 185 } |
20266 | 186 |
187 return 1; | |
188 } | |
189 | |
25221 | 190 const vf_info_t vf_info_geq = { |
20266 | 191 "generic equation filter", |
192 "geq", | |
193 "Michael Niedermayer", | |
194 "", | |
30638
a7b908875c14
Rename open() vf initialization function to vf_open().
diego
parents:
27694
diff
changeset
|
195 vf_open, |
20266 | 196 NULL |
197 }; |