comparison libmpcodecs/vf_sab.c @ 29263:0f1b5b68af32

whitespace cosmetics: Remove all trailing whitespace.
author diego
date Wed, 13 May 2009 02:58:57 +0000
parents 228817b21ccf
children a7b908875c14
comparison
equal deleted inserted replaced
29262:7d545a6b8aff 29263:0f1b5b68af32
101 vec = sws_getGaussianVec(f->preFilterRadius, f->quality); 101 vec = sws_getGaussianVec(f->preFilterRadius, f->quality);
102 swsF.lumH= swsF.lumV= vec; 102 swsF.lumH= swsF.lumV= vec;
103 swsF.chrH= swsF.chrV= NULL; 103 swsF.chrH= swsF.chrV= NULL;
104 f->preFilterContext= sws_getContext( 104 f->preFilterContext= sws_getContext(
105 width, height, PIX_FMT_GRAY8, width, height, PIX_FMT_GRAY8, get_sws_cpuflags()|SWS_POINT, &swsF, NULL, NULL); 105 width, height, PIX_FMT_GRAY8, width, height, PIX_FMT_GRAY8, get_sws_cpuflags()|SWS_POINT, &swsF, NULL, NULL);
106 106
107 sws_freeVec(vec); 107 sws_freeVec(vec);
108 vec = sws_getGaussianVec(f->strength, 5.0); 108 vec = sws_getGaussianVec(f->strength, 5.0);
109 for(i=0; i<512; i++){ 109 for(i=0; i<512; i++){
110 double d; 110 double d;
111 int index= i-256 + vec->length/2; 111 int index= i-256 + vec->length/2;
112 112
113 if(index<0 || index>=vec->length) d= 0.0; 113 if(index<0 || index>=vec->length) d= 0.0;
114 else d= vec->coeff[index]; 114 else d= vec->coeff[index];
115 115
116 f->colorDiffCoeff[i]= (int)(d/vec->coeff[vec->length/2]*(1<<12) + 0.5); 116 f->colorDiffCoeff[i]= (int)(d/vec->coeff[vec->length/2]*(1<<12) + 0.5);
117 } 117 }
118 sws_freeVec(vec); 118 sws_freeVec(vec);
119 vec = sws_getGaussianVec(f->radius, f->quality); 119 vec = sws_getGaussianVec(f->radius, f->quality);
120 f->distWidth= vec->length; 120 f->distWidth= vec->length;
122 f->distCoeff= (int32_t*)memalign(8, f->distWidth*f->distStride*sizeof(int32_t)); 122 f->distCoeff= (int32_t*)memalign(8, f->distWidth*f->distStride*sizeof(int32_t));
123 123
124 for(y=0; y<vec->length; y++){ 124 for(y=0; y<vec->length; y++){
125 for(x=0; x<vec->length; x++){ 125 for(x=0; x<vec->length; x++){
126 double d= vec->coeff[x] * vec->coeff[y]; 126 double d= vec->coeff[x] * vec->coeff[y];
127 127
128 f->distCoeff[x + y*f->distStride]= (int)(d*(1<<10) + 0.5); 128 f->distCoeff[x + y*f->distStride]= (int)(d*(1<<10) + 0.5);
129 // if(y==vec->length/2) 129 // if(y==vec->length/2)
130 // printf("%6d ", f->distCoeff[x + y*f->distStride]); 130 // printf("%6d ", f->distCoeff[x + y*f->distStride]);
131 } 131 }
132 } 132 }
133 sws_freeVec(vec); 133 sws_freeVec(vec);
134 134
135 return 0; 135 return 0;
136 } 136 }
137 137
138 static int config(struct vf_instance_s* vf, 138 static int config(struct vf_instance_s* vf,
139 int width, int height, int d_width, int d_height, 139 int width, int height, int d_width, int d_height,
140 unsigned int flags, unsigned int outfmt){ 140 unsigned int flags, unsigned int outfmt){
141 141
142 int sw, sh; 142 int sw, sh;
143 //__asm__ volatile("emms\n\t"); 143 //__asm__ volatile("emms\n\t");
144 allocStuff(&vf->priv->luma, width, height); 144 allocStuff(&vf->priv->luma, width, height);
145 145
146 getSubSampleFactors(&sw, &sh, outfmt); 146 getSubSampleFactors(&sw, &sh, outfmt);
147 allocStuff(&vf->priv->chroma, width>>sw, height>>sh); 147 allocStuff(&vf->priv->chroma, width>>sw, height>>sh);
148 148
149 return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt); 149 return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt);
150 } 150 }
151 151
152 static void freeBuffers(FilterParam *f){ 152 static void freeBuffers(FilterParam *f){
153 if(f->preFilterContext) sws_freeContext(f->preFilterContext); 153 if(f->preFilterContext) sws_freeContext(f->preFilterContext);
154 f->preFilterContext=NULL; 154 f->preFilterContext=NULL;
155 155
156 if(f->preFilterBuf) free(f->preFilterBuf); 156 if(f->preFilterBuf) free(f->preFilterBuf);
157 f->preFilterBuf=NULL; 157 f->preFilterBuf=NULL;
158 158
159 if(f->distCoeff) free(f->distCoeff); 159 if(f->distCoeff) free(f->distCoeff);
160 f->distCoeff=NULL; 160 f->distCoeff=NULL;
161 } 161 }
162 162
163 static void uninit(struct vf_instance_s* vf){ 163 static void uninit(struct vf_instance_s* vf){
179 int srcStrideArray[MP_MAX_PLANES]= {srcStride}; 179 int srcStrideArray[MP_MAX_PLANES]= {srcStride};
180 int dstStrideArray[MP_MAX_PLANES]= {f.preFilterStride}; 180 int dstStrideArray[MP_MAX_PLANES]= {f.preFilterStride};
181 181
182 // f.preFilterContext->swScale(f.preFilterContext, srcArray, srcStrideArray, 0, h, dstArray, dstStrideArray); 182 // f.preFilterContext->swScale(f.preFilterContext, srcArray, srcStrideArray, 0, h, dstArray, dstStrideArray);
183 sws_scale(f.preFilterContext, srcArray, srcStrideArray, 0, h, dstArray, dstStrideArray); 183 sws_scale(f.preFilterContext, srcArray, srcStrideArray, 0, h, dstArray, dstStrideArray);
184 184
185 for(y=0; y<h; y++){ 185 for(y=0; y<h; y++){
186 for(x=0; x<w; x++){ 186 for(x=0; x<w; x++){
187 int sum=0; 187 int sum=0;
188 int div=0; 188 int div=0;
189 int dy; 189 int dy;
245 mp_image_t *dmpi=vf_get_image(vf->next,mpi->imgfmt, 245 mp_image_t *dmpi=vf_get_image(vf->next,mpi->imgfmt,
246 MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE, 246 MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE,
247 mpi->w,mpi->h); 247 mpi->w,mpi->h);
248 248
249 assert(mpi->flags&MP_IMGFLAG_PLANAR); 249 assert(mpi->flags&MP_IMGFLAG_PLANAR);
250 250
251 blur(dmpi->planes[0], mpi->planes[0], mpi->w,mpi->h, dmpi->stride[0], mpi->stride[0], &vf->priv->luma); 251 blur(dmpi->planes[0], mpi->planes[0], mpi->w,mpi->h, dmpi->stride[0], mpi->stride[0], &vf->priv->luma);
252 blur(dmpi->planes[1], mpi->planes[1], cw , ch , dmpi->stride[1], mpi->stride[1], &vf->priv->chroma); 252 blur(dmpi->planes[1], mpi->planes[1], cw , ch , dmpi->stride[1], mpi->stride[1], &vf->priv->chroma);
253 blur(dmpi->planes[2], mpi->planes[2], cw , ch , dmpi->stride[2], mpi->stride[2], &vf->priv->chroma); 253 blur(dmpi->planes[2], mpi->planes[2], cw , ch , dmpi->stride[2], mpi->stride[2], &vf->priv->chroma);
254 254
255 return vf_next_put_image(vf,dmpi, pts); 255 return vf_next_put_image(vf,dmpi, pts);
256 } 256 }
257 257
258 //===========================================================================// 258 //===========================================================================//
259 259
282 vf->uninit=uninit; 282 vf->uninit=uninit;
283 vf->priv=malloc(sizeof(struct vf_priv_s)); 283 vf->priv=malloc(sizeof(struct vf_priv_s));
284 memset(vf->priv, 0, sizeof(struct vf_priv_s)); 284 memset(vf->priv, 0, sizeof(struct vf_priv_s));
285 285
286 if(args==NULL) return 0; 286 if(args==NULL) return 0;
287 287
288 e=sscanf(args, "%f:%f:%f:%f:%f:%f", 288 e=sscanf(args, "%f:%f:%f:%f:%f:%f",
289 &vf->priv->luma.radius, 289 &vf->priv->luma.radius,
290 &vf->priv->luma.preFilterRadius, 290 &vf->priv->luma.preFilterRadius,
291 &vf->priv->luma.strength, 291 &vf->priv->luma.strength,
292 &vf->priv->chroma.radius, 292 &vf->priv->chroma.radius,
293 &vf->priv->chroma.preFilterRadius, 293 &vf->priv->chroma.preFilterRadius,
294 &vf->priv->chroma.strength 294 &vf->priv->chroma.strength
295 ); 295 );
296 296
297 vf->priv->luma.quality = vf->priv->chroma.quality= 3.0; 297 vf->priv->luma.quality = vf->priv->chroma.quality= 3.0;
298 298
299 if(e==3){ 299 if(e==3){
300 vf->priv->chroma.radius= vf->priv->luma.radius; 300 vf->priv->chroma.radius= vf->priv->luma.radius;
301 vf->priv->chroma.preFilterRadius = vf->priv->luma.preFilterRadius; 301 vf->priv->chroma.preFilterRadius = vf->priv->luma.preFilterRadius;
302 vf->priv->chroma.strength= vf->priv->luma.strength; 302 vf->priv->chroma.strength= vf->priv->luma.strength;
303 }else if(e!=6) 303 }else if(e!=6)
304 return 0; 304 return 0;
305 305
306 // if(vf->priv->luma.radius < 0) return 0; 306 // if(vf->priv->luma.radius < 0) return 0;
307 // if(vf->priv->chroma.radius < 0) return 0; 307 // if(vf->priv->chroma.radius < 0) return 0;
308 308
309 return 1; 309 return 1;
310 } 310 }
311 311
312 const vf_info_t vf_info_sab = { 312 const vf_info_t vf_info_sab = {
313 "shape adaptive blur", 313 "shape adaptive blur",