annotate libmpcodecs/vf_smartblur.c @ 27246:0ade28bdc565

Remove const vector casts from Altivec. Fixes compatibility with C99.
author astrange
date Sun, 13 Jul 2008 22:27:19 +0000
parents 82601a38e2a7
children bacaca1ac820
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8106
7aa3dba949f1 smartblur
michael
parents:
diff changeset
1 /*
26727
82601a38e2a7 Use standard license headers.
diego
parents: 26069
diff changeset
2 * Copyright (C) 2002 Michael Niedermayer <michaelni@gmx.at>
82601a38e2a7 Use standard license headers.
diego
parents: 26069
diff changeset
3 *
82601a38e2a7 Use standard license headers.
diego
parents: 26069
diff changeset
4 * This file is part of MPlayer.
82601a38e2a7 Use standard license headers.
diego
parents: 26069
diff changeset
5 *
82601a38e2a7 Use standard license headers.
diego
parents: 26069
diff changeset
6 * MPlayer is free software; you can redistribute it and/or modify
82601a38e2a7 Use standard license headers.
diego
parents: 26069
diff changeset
7 * it under the terms of the GNU General Public License as published by
82601a38e2a7 Use standard license headers.
diego
parents: 26069
diff changeset
8 * the Free Software Foundation; either version 2 of the License, or
82601a38e2a7 Use standard license headers.
diego
parents: 26069
diff changeset
9 * (at your option) any later version.
82601a38e2a7 Use standard license headers.
diego
parents: 26069
diff changeset
10 *
82601a38e2a7 Use standard license headers.
diego
parents: 26069
diff changeset
11 * MPlayer is distributed in the hope that it will be useful,
82601a38e2a7 Use standard license headers.
diego
parents: 26069
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
82601a38e2a7 Use standard license headers.
diego
parents: 26069
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
82601a38e2a7 Use standard license headers.
diego
parents: 26069
diff changeset
14 * GNU General Public License for more details.
82601a38e2a7 Use standard license headers.
diego
parents: 26069
diff changeset
15 *
82601a38e2a7 Use standard license headers.
diego
parents: 26069
diff changeset
16 * You should have received a copy of the GNU General Public License along
82601a38e2a7 Use standard license headers.
diego
parents: 26069
diff changeset
17 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
82601a38e2a7 Use standard license headers.
diego
parents: 26069
diff changeset
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
82601a38e2a7 Use standard license headers.
diego
parents: 26069
diff changeset
19 */
8106
7aa3dba949f1 smartblur
michael
parents:
diff changeset
20
7aa3dba949f1 smartblur
michael
parents:
diff changeset
21 #include <stdio.h>
7aa3dba949f1 smartblur
michael
parents:
diff changeset
22 #include <stdlib.h>
7aa3dba949f1 smartblur
michael
parents:
diff changeset
23 #include <string.h>
7aa3dba949f1 smartblur
michael
parents:
diff changeset
24 #include <inttypes.h>
7aa3dba949f1 smartblur
michael
parents:
diff changeset
25 #include <assert.h>
7aa3dba949f1 smartblur
michael
parents:
diff changeset
26
17012
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 16154
diff changeset
27 #include "config.h"
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 16154
diff changeset
28 #include "mp_msg.h"
8106
7aa3dba949f1 smartblur
michael
parents:
diff changeset
29
7aa3dba949f1 smartblur
michael
parents:
diff changeset
30 #ifdef HAVE_MALLOC_H
7aa3dba949f1 smartblur
michael
parents:
diff changeset
31 #include <malloc.h>
7aa3dba949f1 smartblur
michael
parents:
diff changeset
32 #endif
7aa3dba949f1 smartblur
michael
parents:
diff changeset
33
26069
1318e956c092 FFmpeg now uses different (unified) #include paths.
diego
parents: 25221
diff changeset
34 #include "libavutil/avutil.h"
8106
7aa3dba949f1 smartblur
michael
parents:
diff changeset
35 #include "img_format.h"
7aa3dba949f1 smartblur
michael
parents:
diff changeset
36 #include "mp_image.h"
7aa3dba949f1 smartblur
michael
parents:
diff changeset
37 #include "vf.h"
18861
8579acff875e Move postproc ---> libswscale
lucabe
parents: 17906
diff changeset
38 #include "libswscale/swscale.h"
10233
35f52ad860a0 vf_scale.h & related cleanup & some small warning fix by dominik
michael
parents: 9975
diff changeset
39 #include "vf_scale.h"
8106
7aa3dba949f1 smartblur
michael
parents:
diff changeset
40
7aa3dba949f1 smartblur
michael
parents:
diff changeset
41 //===========================================================================//
7aa3dba949f1 smartblur
michael
parents:
diff changeset
42
7aa3dba949f1 smartblur
michael
parents:
diff changeset
43 typedef struct FilterParam{
7aa3dba949f1 smartblur
michael
parents:
diff changeset
44 float radius;
7aa3dba949f1 smartblur
michael
parents:
diff changeset
45 float strength;
7aa3dba949f1 smartblur
michael
parents:
diff changeset
46 int threshold;
7aa3dba949f1 smartblur
michael
parents:
diff changeset
47 float quality;
9494
543ab3909b78 sws_ prefix, more seperation between internal & external swscaler API
michael
parents: 8263
diff changeset
48 struct SwsContext *filterContext;
8106
7aa3dba949f1 smartblur
michael
parents:
diff changeset
49 }FilterParam;
7aa3dba949f1 smartblur
michael
parents:
diff changeset
50
7aa3dba949f1 smartblur
michael
parents:
diff changeset
51 struct vf_priv_s {
7aa3dba949f1 smartblur
michael
parents:
diff changeset
52 FilterParam luma;
7aa3dba949f1 smartblur
michael
parents:
diff changeset
53 FilterParam chroma;
7aa3dba949f1 smartblur
michael
parents:
diff changeset
54 };
7aa3dba949f1 smartblur
michael
parents:
diff changeset
55
7aa3dba949f1 smartblur
michael
parents:
diff changeset
56
7aa3dba949f1 smartblur
michael
parents:
diff changeset
57 /***************************************************************************/
7aa3dba949f1 smartblur
michael
parents:
diff changeset
58
7aa3dba949f1 smartblur
michael
parents:
diff changeset
59 //FIXME stupid code duplication
7aa3dba949f1 smartblur
michael
parents:
diff changeset
60 static void getSubSampleFactors(int *h, int *v, int format){
7aa3dba949f1 smartblur
michael
parents:
diff changeset
61 switch(format){
7aa3dba949f1 smartblur
michael
parents:
diff changeset
62 case IMGFMT_YV12:
7aa3dba949f1 smartblur
michael
parents:
diff changeset
63 case IMGFMT_I420:
7aa3dba949f1 smartblur
michael
parents:
diff changeset
64 *h=1;
7aa3dba949f1 smartblur
michael
parents:
diff changeset
65 *v=1;
7aa3dba949f1 smartblur
michael
parents:
diff changeset
66 break;
7aa3dba949f1 smartblur
michael
parents:
diff changeset
67 case IMGFMT_YVU9:
7aa3dba949f1 smartblur
michael
parents:
diff changeset
68 *h=2;
7aa3dba949f1 smartblur
michael
parents:
diff changeset
69 *v=2;
7aa3dba949f1 smartblur
michael
parents:
diff changeset
70 break;
7aa3dba949f1 smartblur
michael
parents:
diff changeset
71 case IMGFMT_444P:
7aa3dba949f1 smartblur
michael
parents:
diff changeset
72 *h=0;
7aa3dba949f1 smartblur
michael
parents:
diff changeset
73 *v=0;
7aa3dba949f1 smartblur
michael
parents:
diff changeset
74 break;
7aa3dba949f1 smartblur
michael
parents:
diff changeset
75 case IMGFMT_422P:
7aa3dba949f1 smartblur
michael
parents:
diff changeset
76 *h=1;
7aa3dba949f1 smartblur
michael
parents:
diff changeset
77 *v=0;
7aa3dba949f1 smartblur
michael
parents:
diff changeset
78 break;
7aa3dba949f1 smartblur
michael
parents:
diff changeset
79 case IMGFMT_411P:
7aa3dba949f1 smartblur
michael
parents:
diff changeset
80 *h=2;
7aa3dba949f1 smartblur
michael
parents:
diff changeset
81 *v=0;
7aa3dba949f1 smartblur
michael
parents:
diff changeset
82 break;
7aa3dba949f1 smartblur
michael
parents:
diff changeset
83 }
7aa3dba949f1 smartblur
michael
parents:
diff changeset
84 }
7aa3dba949f1 smartblur
michael
parents:
diff changeset
85
7aa3dba949f1 smartblur
michael
parents:
diff changeset
86 static int allocStuff(FilterParam *f, int width, int height){
7aa3dba949f1 smartblur
michael
parents:
diff changeset
87 SwsVector *vec;
7aa3dba949f1 smartblur
michael
parents:
diff changeset
88 SwsFilter swsF;
7aa3dba949f1 smartblur
michael
parents:
diff changeset
89
9494
543ab3909b78 sws_ prefix, more seperation between internal & external swscaler API
michael
parents: 8263
diff changeset
90 vec = sws_getGaussianVec(f->radius, f->quality);
543ab3909b78 sws_ prefix, more seperation between internal & external swscaler API
michael
parents: 8263
diff changeset
91 sws_scaleVec(vec, f->strength);
8106
7aa3dba949f1 smartblur
michael
parents:
diff changeset
92 vec->coeff[vec->length/2]+= 1.0 - f->strength;
7aa3dba949f1 smartblur
michael
parents:
diff changeset
93 swsF.lumH= swsF.lumV= vec;
7aa3dba949f1 smartblur
michael
parents:
diff changeset
94 swsF.chrH= swsF.chrV= NULL;
9494
543ab3909b78 sws_ prefix, more seperation between internal & external swscaler API
michael
parents: 8263
diff changeset
95 f->filterContext= sws_getContext(
19870
1e5cf11e8b1f Use PIX_FMT_* instead of IMGFMT_* when calling sws_getContext()
lucabe
parents: 18861
diff changeset
96 width, height, PIX_FMT_GRAY8, width, height, PIX_FMT_GRAY8, get_sws_cpuflags(), &swsF, NULL, NULL);
8106
7aa3dba949f1 smartblur
michael
parents:
diff changeset
97
9494
543ab3909b78 sws_ prefix, more seperation between internal & external swscaler API
michael
parents: 8263
diff changeset
98 sws_freeVec(vec);
8106
7aa3dba949f1 smartblur
michael
parents:
diff changeset
99
7aa3dba949f1 smartblur
michael
parents:
diff changeset
100 return 0;
7aa3dba949f1 smartblur
michael
parents:
diff changeset
101 }
7aa3dba949f1 smartblur
michael
parents:
diff changeset
102
7aa3dba949f1 smartblur
michael
parents:
diff changeset
103 static int config(struct vf_instance_s* vf,
7aa3dba949f1 smartblur
michael
parents:
diff changeset
104 int width, int height, int d_width, int d_height,
7aa3dba949f1 smartblur
michael
parents:
diff changeset
105 unsigned int flags, unsigned int outfmt){
7aa3dba949f1 smartblur
michael
parents:
diff changeset
106
7aa3dba949f1 smartblur
michael
parents:
diff changeset
107 int sw, sh;
7aa3dba949f1 smartblur
michael
parents:
diff changeset
108
7aa3dba949f1 smartblur
michael
parents:
diff changeset
109 allocStuff(&vf->priv->luma, width, height);
7aa3dba949f1 smartblur
michael
parents:
diff changeset
110
7aa3dba949f1 smartblur
michael
parents:
diff changeset
111 getSubSampleFactors(&sw, &sh, outfmt);
7aa3dba949f1 smartblur
michael
parents:
diff changeset
112 allocStuff(&vf->priv->chroma, width>>sw, height>>sh);
7aa3dba949f1 smartblur
michael
parents:
diff changeset
113
7aa3dba949f1 smartblur
michael
parents:
diff changeset
114 return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt);
7aa3dba949f1 smartblur
michael
parents:
diff changeset
115 }
7aa3dba949f1 smartblur
michael
parents:
diff changeset
116
7aa3dba949f1 smartblur
michael
parents:
diff changeset
117 static void freeBuffers(FilterParam *f){
9494
543ab3909b78 sws_ prefix, more seperation between internal & external swscaler API
michael
parents: 8263
diff changeset
118 if(f->filterContext) sws_freeContext(f->filterContext);
8106
7aa3dba949f1 smartblur
michael
parents:
diff changeset
119 f->filterContext=NULL;
7aa3dba949f1 smartblur
michael
parents:
diff changeset
120 }
7aa3dba949f1 smartblur
michael
parents:
diff changeset
121
7aa3dba949f1 smartblur
michael
parents:
diff changeset
122 static void uninit(struct vf_instance_s* vf){
7aa3dba949f1 smartblur
michael
parents:
diff changeset
123 if(!vf->priv) return;
7aa3dba949f1 smartblur
michael
parents:
diff changeset
124
7aa3dba949f1 smartblur
michael
parents:
diff changeset
125 freeBuffers(&vf->priv->luma);
7aa3dba949f1 smartblur
michael
parents:
diff changeset
126 freeBuffers(&vf->priv->chroma);
7aa3dba949f1 smartblur
michael
parents:
diff changeset
127
7aa3dba949f1 smartblur
michael
parents:
diff changeset
128 free(vf->priv);
7aa3dba949f1 smartblur
michael
parents:
diff changeset
129 vf->priv=NULL;
7aa3dba949f1 smartblur
michael
parents:
diff changeset
130 }
7aa3dba949f1 smartblur
michael
parents:
diff changeset
131
7aa3dba949f1 smartblur
michael
parents:
diff changeset
132 static inline void blur(uint8_t *dst, uint8_t *src, int w, int h, int dstStride, int srcStride, FilterParam *fp){
7aa3dba949f1 smartblur
michael
parents:
diff changeset
133 int x, y;
7aa3dba949f1 smartblur
michael
parents:
diff changeset
134 FilterParam f= *fp;
7aa3dba949f1 smartblur
michael
parents:
diff changeset
135 uint8_t *srcArray[3]= {src, NULL, NULL};
7aa3dba949f1 smartblur
michael
parents:
diff changeset
136 uint8_t *dstArray[3]= {dst, NULL, NULL};
7aa3dba949f1 smartblur
michael
parents:
diff changeset
137 int srcStrideArray[3]= {srcStride, 0, 0};
7aa3dba949f1 smartblur
michael
parents:
diff changeset
138 int dstStrideArray[3]= {dstStride, 0, 0};
7aa3dba949f1 smartblur
michael
parents:
diff changeset
139
9494
543ab3909b78 sws_ prefix, more seperation between internal & external swscaler API
michael
parents: 8263
diff changeset
140 sws_scale(f.filterContext, srcArray, srcStrideArray, 0, h, dstArray, dstStrideArray);
8106
7aa3dba949f1 smartblur
michael
parents:
diff changeset
141
7aa3dba949f1 smartblur
michael
parents:
diff changeset
142 if(f.threshold > 0){
7aa3dba949f1 smartblur
michael
parents:
diff changeset
143 for(y=0; y<h; y++){
7aa3dba949f1 smartblur
michael
parents:
diff changeset
144 for(x=0; x<w; x++){
7aa3dba949f1 smartblur
michael
parents:
diff changeset
145 const int orig= src[x + y*srcStride];
7aa3dba949f1 smartblur
michael
parents:
diff changeset
146 const int filtered= dst[x + y*dstStride];
7aa3dba949f1 smartblur
michael
parents:
diff changeset
147 const int diff= orig - filtered;
7aa3dba949f1 smartblur
michael
parents:
diff changeset
148
7aa3dba949f1 smartblur
michael
parents:
diff changeset
149 if(diff > 0){
7aa3dba949f1 smartblur
michael
parents:
diff changeset
150 if(diff > 2*f.threshold){
7aa3dba949f1 smartblur
michael
parents:
diff changeset
151 dst[x + y*dstStride]= orig;
7aa3dba949f1 smartblur
michael
parents:
diff changeset
152 }else if(diff > f.threshold){
7aa3dba949f1 smartblur
michael
parents:
diff changeset
153 dst[x + y*dstStride]= filtered + diff - f.threshold;
7aa3dba949f1 smartblur
michael
parents:
diff changeset
154 }
7aa3dba949f1 smartblur
michael
parents:
diff changeset
155 }else{
7aa3dba949f1 smartblur
michael
parents:
diff changeset
156 if(-diff > 2*f.threshold){
7aa3dba949f1 smartblur
michael
parents:
diff changeset
157 dst[x + y*dstStride]= orig;
7aa3dba949f1 smartblur
michael
parents:
diff changeset
158 }else if(-diff > f.threshold){
7aa3dba949f1 smartblur
michael
parents:
diff changeset
159 dst[x + y*dstStride]= filtered + diff + f.threshold;
7aa3dba949f1 smartblur
michael
parents:
diff changeset
160 }
7aa3dba949f1 smartblur
michael
parents:
diff changeset
161 }
7aa3dba949f1 smartblur
michael
parents:
diff changeset
162 }
7aa3dba949f1 smartblur
michael
parents:
diff changeset
163 }
7aa3dba949f1 smartblur
michael
parents:
diff changeset
164 }else if(f.threshold < 0){
7aa3dba949f1 smartblur
michael
parents:
diff changeset
165 for(y=0; y<h; y++){
7aa3dba949f1 smartblur
michael
parents:
diff changeset
166 for(x=0; x<w; x++){
7aa3dba949f1 smartblur
michael
parents:
diff changeset
167 const int orig= src[x + y*srcStride];
7aa3dba949f1 smartblur
michael
parents:
diff changeset
168 const int filtered= dst[x + y*dstStride];
7aa3dba949f1 smartblur
michael
parents:
diff changeset
169 const int diff= orig - filtered;
7aa3dba949f1 smartblur
michael
parents:
diff changeset
170
7aa3dba949f1 smartblur
michael
parents:
diff changeset
171 if(diff > 0){
7aa3dba949f1 smartblur
michael
parents:
diff changeset
172 if(diff > -2*f.threshold){
7aa3dba949f1 smartblur
michael
parents:
diff changeset
173 }else if(diff > -f.threshold){
7aa3dba949f1 smartblur
michael
parents:
diff changeset
174 dst[x + y*dstStride]= orig - diff - f.threshold;
7aa3dba949f1 smartblur
michael
parents:
diff changeset
175 }else
7aa3dba949f1 smartblur
michael
parents:
diff changeset
176 dst[x + y*dstStride]= orig;
7aa3dba949f1 smartblur
michael
parents:
diff changeset
177 }else{
7aa3dba949f1 smartblur
michael
parents:
diff changeset
178 if(diff < 2*f.threshold){
7aa3dba949f1 smartblur
michael
parents:
diff changeset
179 }else if(diff < f.threshold){
7aa3dba949f1 smartblur
michael
parents:
diff changeset
180 dst[x + y*dstStride]= orig - diff + f.threshold;
7aa3dba949f1 smartblur
michael
parents:
diff changeset
181 }else
7aa3dba949f1 smartblur
michael
parents:
diff changeset
182 dst[x + y*dstStride]= orig;
7aa3dba949f1 smartblur
michael
parents:
diff changeset
183 }
7aa3dba949f1 smartblur
michael
parents:
diff changeset
184 }
7aa3dba949f1 smartblur
michael
parents:
diff changeset
185 }
7aa3dba949f1 smartblur
michael
parents:
diff changeset
186 }
7aa3dba949f1 smartblur
michael
parents:
diff changeset
187 }
7aa3dba949f1 smartblur
michael
parents:
diff changeset
188
17906
20aca9baf5d8 passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents: 17367
diff changeset
189 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
8106
7aa3dba949f1 smartblur
michael
parents:
diff changeset
190 int cw= mpi->w >> mpi->chroma_x_shift;
7aa3dba949f1 smartblur
michael
parents:
diff changeset
191 int ch= mpi->h >> mpi->chroma_y_shift;
16154
abe49bc12544 when threshold != 0 the dest image must be readable
reimar
parents: 14542
diff changeset
192 FilterParam *f= &vf->priv;
8106
7aa3dba949f1 smartblur
michael
parents:
diff changeset
193
7aa3dba949f1 smartblur
michael
parents:
diff changeset
194 mp_image_t *dmpi=vf_get_image(vf->next,mpi->imgfmt,
16154
abe49bc12544 when threshold != 0 the dest image must be readable
reimar
parents: 14542
diff changeset
195 MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE|
abe49bc12544 when threshold != 0 the dest image must be readable
reimar
parents: 14542
diff changeset
196 (f->threshold) ? MP_IMGFLAG_READABLE : 0,
8106
7aa3dba949f1 smartblur
michael
parents:
diff changeset
197 mpi->w,mpi->h);
7aa3dba949f1 smartblur
michael
parents:
diff changeset
198
7aa3dba949f1 smartblur
michael
parents:
diff changeset
199 assert(mpi->flags&MP_IMGFLAG_PLANAR);
7aa3dba949f1 smartblur
michael
parents:
diff changeset
200
7aa3dba949f1 smartblur
michael
parents:
diff changeset
201 blur(dmpi->planes[0], mpi->planes[0], mpi->w,mpi->h, dmpi->stride[0], mpi->stride[0], &vf->priv->luma);
7aa3dba949f1 smartblur
michael
parents:
diff changeset
202 blur(dmpi->planes[1], mpi->planes[1], cw , ch , dmpi->stride[1], mpi->stride[1], &vf->priv->chroma);
7aa3dba949f1 smartblur
michael
parents:
diff changeset
203 blur(dmpi->planes[2], mpi->planes[2], cw , ch , dmpi->stride[2], mpi->stride[2], &vf->priv->chroma);
7aa3dba949f1 smartblur
michael
parents:
diff changeset
204
17906
20aca9baf5d8 passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents: 17367
diff changeset
205 return vf_next_put_image(vf,dmpi, pts);
8106
7aa3dba949f1 smartblur
michael
parents:
diff changeset
206 }
7aa3dba949f1 smartblur
michael
parents:
diff changeset
207
7aa3dba949f1 smartblur
michael
parents:
diff changeset
208 //===========================================================================//
7aa3dba949f1 smartblur
michael
parents:
diff changeset
209
7aa3dba949f1 smartblur
michael
parents:
diff changeset
210 static int query_format(struct vf_instance_s* vf, unsigned int fmt){
7aa3dba949f1 smartblur
michael
parents:
diff changeset
211 switch(fmt)
7aa3dba949f1 smartblur
michael
parents:
diff changeset
212 {
7aa3dba949f1 smartblur
michael
parents:
diff changeset
213 case IMGFMT_YV12:
7aa3dba949f1 smartblur
michael
parents:
diff changeset
214 case IMGFMT_I420:
7aa3dba949f1 smartblur
michael
parents:
diff changeset
215 case IMGFMT_IYUV:
7aa3dba949f1 smartblur
michael
parents:
diff changeset
216 case IMGFMT_YVU9:
7aa3dba949f1 smartblur
michael
parents:
diff changeset
217 case IMGFMT_444P:
7aa3dba949f1 smartblur
michael
parents:
diff changeset
218 case IMGFMT_422P:
7aa3dba949f1 smartblur
michael
parents:
diff changeset
219 case IMGFMT_411P:
7aa3dba949f1 smartblur
michael
parents:
diff changeset
220 return vf_next_query_format(vf, fmt);
7aa3dba949f1 smartblur
michael
parents:
diff changeset
221 }
7aa3dba949f1 smartblur
michael
parents:
diff changeset
222 return 0;
7aa3dba949f1 smartblur
michael
parents:
diff changeset
223 }
7aa3dba949f1 smartblur
michael
parents:
diff changeset
224
7aa3dba949f1 smartblur
michael
parents:
diff changeset
225 static int open(vf_instance_t *vf, char* args){
7aa3dba949f1 smartblur
michael
parents:
diff changeset
226 int e;
7aa3dba949f1 smartblur
michael
parents:
diff changeset
227
7aa3dba949f1 smartblur
michael
parents:
diff changeset
228 vf->config=config;
7aa3dba949f1 smartblur
michael
parents:
diff changeset
229 vf->put_image=put_image;
7aa3dba949f1 smartblur
michael
parents:
diff changeset
230 // vf->get_image=get_image;
7aa3dba949f1 smartblur
michael
parents:
diff changeset
231 vf->query_format=query_format;
7aa3dba949f1 smartblur
michael
parents:
diff changeset
232 vf->uninit=uninit;
7aa3dba949f1 smartblur
michael
parents:
diff changeset
233 vf->priv=malloc(sizeof(struct vf_priv_s));
7aa3dba949f1 smartblur
michael
parents:
diff changeset
234 memset(vf->priv, 0, sizeof(struct vf_priv_s));
7aa3dba949f1 smartblur
michael
parents:
diff changeset
235
7aa3dba949f1 smartblur
michael
parents:
diff changeset
236 if(args==NULL) return 0;
7aa3dba949f1 smartblur
michael
parents:
diff changeset
237
7aa3dba949f1 smartblur
michael
parents:
diff changeset
238 e=sscanf(args, "%f:%f:%d:%f:%f:%d",
7aa3dba949f1 smartblur
michael
parents:
diff changeset
239 &vf->priv->luma.radius,
7aa3dba949f1 smartblur
michael
parents:
diff changeset
240 &vf->priv->luma.strength,
7aa3dba949f1 smartblur
michael
parents:
diff changeset
241 &vf->priv->luma.threshold,
7aa3dba949f1 smartblur
michael
parents:
diff changeset
242 &vf->priv->chroma.radius,
7aa3dba949f1 smartblur
michael
parents:
diff changeset
243 &vf->priv->chroma.strength,
7aa3dba949f1 smartblur
michael
parents:
diff changeset
244 &vf->priv->chroma.threshold
7aa3dba949f1 smartblur
michael
parents:
diff changeset
245 );
7aa3dba949f1 smartblur
michael
parents:
diff changeset
246
7aa3dba949f1 smartblur
michael
parents:
diff changeset
247 vf->priv->luma.quality = vf->priv->chroma.quality= 3.0;
7aa3dba949f1 smartblur
michael
parents:
diff changeset
248
7aa3dba949f1 smartblur
michael
parents:
diff changeset
249 if(e==3){
7aa3dba949f1 smartblur
michael
parents:
diff changeset
250 vf->priv->chroma.radius= vf->priv->luma.radius;
7aa3dba949f1 smartblur
michael
parents:
diff changeset
251 vf->priv->chroma.strength= vf->priv->luma.strength;
7aa3dba949f1 smartblur
michael
parents:
diff changeset
252 vf->priv->chroma.threshold = vf->priv->luma.threshold;
7aa3dba949f1 smartblur
michael
parents:
diff changeset
253 }else if(e!=6)
7aa3dba949f1 smartblur
michael
parents:
diff changeset
254 return 0;
7aa3dba949f1 smartblur
michael
parents:
diff changeset
255
7aa3dba949f1 smartblur
michael
parents:
diff changeset
256 return 1;
7aa3dba949f1 smartblur
michael
parents:
diff changeset
257 }
7aa3dba949f1 smartblur
michael
parents:
diff changeset
258
25221
00fff9a3b735 Make all vf_info_t structs const
reimar
parents: 23373
diff changeset
259 const vf_info_t vf_info_smartblur = {
8106
7aa3dba949f1 smartblur
michael
parents:
diff changeset
260 "smart blur",
7aa3dba949f1 smartblur
michael
parents:
diff changeset
261 "smartblur",
7aa3dba949f1 smartblur
michael
parents:
diff changeset
262 "Michael Niedermayer",
7aa3dba949f1 smartblur
michael
parents:
diff changeset
263 "",
9593
e9a2af584986 Add the new -vf option wich is the same as vop in reverse order.
albeu
parents: 9494
diff changeset
264 open,
e9a2af584986 Add the new -vf option wich is the same as vop in reverse order.
albeu
parents: 9494
diff changeset
265 NULL
8106
7aa3dba949f1 smartblur
michael
parents:
diff changeset
266 };
7aa3dba949f1 smartblur
michael
parents:
diff changeset
267
7aa3dba949f1 smartblur
michael
parents:
diff changeset
268 //===========================================================================//