annotate libmpcodecs/vf_sab.c @ 8739:66f3204117d6

trivial bigendian fix
author colin
date Fri, 03 Jan 2003 14:49:02 +0000
parents fd0da9a7d2e3
children 543ab3909b78
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8100
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
1 /*
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
2 Copyright (C) 2002 Michael Niedermayer <michaelni@gmx.at>
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
3
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
4 This program is free software; you can redistribute it and/or modify
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
5 it under the terms of the GNU General Public License as published by
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
6 the Free Software Foundation; either version 2 of the License, or
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
7 (at your option) any later version.
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
8
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
9 This program is distributed in the hope that it will be useful,
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
12 GNU General Public License for more details.
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
13
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
14 You should have received a copy of the GNU General Public License
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
15 along with this program; if not, write to the Free Software
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
16 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
17 */
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
18
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
19 #include <stdio.h>
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
20 #include <stdlib.h>
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
21 #include <string.h>
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
22 #include <inttypes.h>
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
23 #include <assert.h>
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
24
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
25 #include "../config.h"
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
26 #include "../mp_msg.h"
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
27
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
28 #ifdef HAVE_MALLOC_H
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
29 #include <malloc.h>
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
30 #endif
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
31
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
32 #include "img_format.h"
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
33 #include "mp_image.h"
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
34 #include "vf.h"
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
35 #include "../libvo/fastmemcpy.h"
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
36 #include "../postproc/swscale.h"
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
37
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
38
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
39 //===========================================================================//
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
40
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
41 typedef struct FilterParam{
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
42 float radius;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
43 float preFilterRadius;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
44 float strength;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
45 float quality;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
46 SwsContext *preFilterContext;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
47 uint8_t *preFilterBuf;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
48 int preFilterStride;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
49 int distWidth;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
50 int distStride;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
51 int *distCoeff;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
52 int colorDiffCoeff[512];
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
53 }FilterParam;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
54
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
55 struct vf_priv_s {
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
56 FilterParam luma;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
57 FilterParam chroma;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
58 };
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
59
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
60
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
61 /***************************************************************************/
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
62
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
63 //FIXME stupid code duplication
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
64 static void getSubSampleFactors(int *h, int *v, int format){
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
65 switch(format){
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
66 case IMGFMT_YV12:
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
67 case IMGFMT_I420:
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
68 *h=1;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
69 *v=1;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
70 break;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
71 case IMGFMT_YVU9:
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
72 *h=2;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
73 *v=2;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
74 break;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
75 case IMGFMT_444P:
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
76 *h=0;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
77 *v=0;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
78 break;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
79 case IMGFMT_422P:
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
80 *h=1;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
81 *v=0;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
82 break;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
83 case IMGFMT_411P:
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
84 *h=2;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
85 *v=0;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
86 break;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
87 }
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
88 }
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
89
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
90 static int allocStuff(FilterParam *f, int width, int height){
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
91 int stride= (width+7)&~7;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
92 SwsVector *vec;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
93 SwsFilter swsF;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
94 int i,x,y;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
95 f->preFilterBuf= (uint8_t*)memalign(8, stride*height);
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
96 f->preFilterStride= stride;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
97
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
98 vec = getGaussianVec(f->preFilterRadius, f->quality);
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
99 swsF.lumH= swsF.lumV= vec;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
100 swsF.chrH= swsF.chrV= NULL;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
101 f->preFilterContext= getSwsContext(
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
102 width, height, IMGFMT_Y8, width, height, IMGFMT_Y8, 0, &swsF, NULL);
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
103
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
104 freeVec(vec);
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
105 vec = getGaussianVec(f->strength, 5.0);
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
106 for(i=0; i<512; i++){
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
107 double d;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
108 int index= i-256 + vec->length/2;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
109
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
110 if(index<0 || index>=vec->length) d= 0.0;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
111 else d= vec->coeff[index];
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
112
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
113 f->colorDiffCoeff[i]= (int)(d/vec->coeff[vec->length/2]*(1<<12) + 0.5);
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
114 }
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
115 freeVec(vec);
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
116 vec = getGaussianVec(f->radius, f->quality);
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
117 f->distWidth= vec->length;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
118 f->distStride= (vec->length+7)&~7;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
119 f->distCoeff= (int32_t*)memalign(8, f->distWidth*f->distStride*sizeof(int32_t));
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
120
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
121 for(y=0; y<vec->length; y++){
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
122 for(x=0; x<vec->length; x++){
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
123 double d= vec->coeff[x] * vec->coeff[y];
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
124
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
125 f->distCoeff[x + y*f->distStride]= (int)(d*(1<<10) + 0.5);
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
126 // if(y==vec->length/2)
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
127 // printf("%6d ", f->distCoeff[x + y*f->distStride]);
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
128 }
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
129 }
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
130 freeVec(vec);
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
131
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
132 return 0;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
133 }
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
134
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
135 static int config(struct vf_instance_s* vf,
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
136 int width, int height, int d_width, int d_height,
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
137 unsigned int flags, unsigned int outfmt){
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
138
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
139 int sw, sh;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
140 //asm volatile("emms\n\t");
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
141 allocStuff(&vf->priv->luma, width, height);
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
142
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
143 getSubSampleFactors(&sw, &sh, outfmt);
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
144 allocStuff(&vf->priv->chroma, width>>sw, height>>sh);
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
145
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
146 return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt);
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
147 }
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
148
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
149 static void freeBuffers(FilterParam *f){
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
150 if(f->preFilterContext) freeSwsContext(f->preFilterContext);
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
151 f->preFilterContext=NULL;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
152
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
153 if(f->preFilterBuf) free(f->preFilterBuf);
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
154 f->preFilterBuf=NULL;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
155
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
156 if(f->distCoeff) free(f->distCoeff);
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
157 f->distCoeff=NULL;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
158 }
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
159
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
160 static void uninit(struct vf_instance_s* vf){
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
161 if(!vf->priv) return;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
162
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
163 freeBuffers(&vf->priv->luma);
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
164 freeBuffers(&vf->priv->chroma);
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
165
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
166 free(vf->priv);
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
167 vf->priv=NULL;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
168 }
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
169
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
170 static inline void blur(uint8_t *dst, uint8_t *src, int w, int h, int dstStride, int srcStride, FilterParam *fp){
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
171 int x, y;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
172 FilterParam f= *fp;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
173 const int radius= f.distWidth/2;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
174 uint8_t *srcArray[3]= {src, NULL, NULL};
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
175 uint8_t *dstArray[3]= {f.preFilterBuf, NULL, NULL};
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
176 int srcStrideArray[3]= {srcStride, 0, 0};
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
177 int dstStrideArray[3]= {f.preFilterStride, 0, 0};
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
178
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
179 f.preFilterContext->swScale(f.preFilterContext, srcArray, srcStrideArray, 0, h, dstArray, dstStrideArray);
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
180
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
181 for(y=0; y<h; y++){
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
182 for(x=0; x<w; x++){
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
183 int sum=0;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
184 int div=0;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
185 int dy;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
186 const int preVal= f.preFilterBuf[x + y*f.preFilterStride];
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
187 #if 0
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
188 const int srcVal= src[x + y*srcStride];
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
189 if((x/32)&1){
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
190 dst[x + y*dstStride]= srcVal;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
191 if(y%32==0) dst[x + y*dstStride]= 0;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
192 continue;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
193 }
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
194 #endif
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
195 if(x >= radius && x < w - radius){
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
196 for(dy=0; dy<radius*2+1; dy++){
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
197 int dx;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
198 int iy= y+dy - radius;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
199 if (iy<0) iy= -iy;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
200 else if(iy>=h) iy= h-iy-1;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
201
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
202 for(dx=0; dx<radius*2+1; dx++){
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
203 const int ix= x+dx - radius;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
204 int factor;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
205
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
206 factor= f.colorDiffCoeff[256+preVal - f.preFilterBuf[ix + iy*f.preFilterStride] ]
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
207 *f.distCoeff[dx + dy*f.distStride];
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
208 sum+= src[ix + iy*srcStride] *factor;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
209 div+= factor;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
210 }
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
211 }
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
212 }else{
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
213 for(dy=0; dy<radius*2+1; dy++){
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
214 int dx;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
215 int iy= y+dy - radius;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
216 if (iy<0) iy= -iy;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
217 else if(iy>=h) iy= h-iy-1;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
218
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
219 for(dx=0; dx<radius*2+1; dx++){
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
220 int ix= x+dx - radius;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
221 int factor;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
222 if (ix<0) ix= -ix;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
223 else if(ix>=w) ix= w-ix-1;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
224
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
225 factor= f.colorDiffCoeff[256+preVal - f.preFilterBuf[ix + iy*f.preFilterStride] ]
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
226 *f.distCoeff[dx + dy*f.distStride];
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
227 sum+= src[ix + iy*srcStride] *factor;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
228 div+= factor;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
229 }
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
230 }
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
231 }
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
232 dst[x + y*dstStride]= (sum + div/2)/div;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
233 }
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
234 }
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
235 }
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
236
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
237 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi){
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
238 int cw= mpi->w >> mpi->chroma_x_shift;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
239 int ch= mpi->h >> mpi->chroma_y_shift;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
240
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
241 mp_image_t *dmpi=vf_get_image(vf->next,mpi->imgfmt,
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
242 MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE,
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
243 mpi->w,mpi->h);
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
244
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
245 assert(mpi->flags&MP_IMGFLAG_PLANAR);
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
246
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
247 blur(dmpi->planes[0], mpi->planes[0], mpi->w,mpi->h, dmpi->stride[0], mpi->stride[0], &vf->priv->luma);
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
248 blur(dmpi->planes[1], mpi->planes[1], cw , ch , dmpi->stride[1], mpi->stride[1], &vf->priv->chroma);
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
249 blur(dmpi->planes[2], mpi->planes[2], cw , ch , dmpi->stride[2], mpi->stride[2], &vf->priv->chroma);
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
250
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
251 return vf_next_put_image(vf,dmpi);
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
252 }
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
253
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
254 //===========================================================================//
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
255
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
256 static int query_format(struct vf_instance_s* vf, unsigned int fmt){
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
257 switch(fmt)
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
258 {
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
259 case IMGFMT_YV12:
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
260 case IMGFMT_I420:
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
261 case IMGFMT_IYUV:
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
262 case IMGFMT_YVU9:
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
263 case IMGFMT_444P:
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
264 case IMGFMT_422P:
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
265 case IMGFMT_411P:
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
266 return vf_next_query_format(vf, fmt);
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
267 }
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
268 return 0;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
269 }
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
270
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
271 static int open(vf_instance_t *vf, char* args){
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
272 int e;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
273
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
274 vf->config=config;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
275 vf->put_image=put_image;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
276 // vf->get_image=get_image;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
277 vf->query_format=query_format;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
278 vf->uninit=uninit;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
279 vf->priv=malloc(sizeof(struct vf_priv_s));
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
280 memset(vf->priv, 0, sizeof(struct vf_priv_s));
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
281
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
282 if(args==NULL) return 0;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
283
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
284 e=sscanf(args, "%f:%f:%f:%f:%f:%f",
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
285 &vf->priv->luma.radius,
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
286 &vf->priv->luma.preFilterRadius,
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
287 &vf->priv->luma.strength,
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
288 &vf->priv->chroma.radius,
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
289 &vf->priv->chroma.preFilterRadius,
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
290 &vf->priv->chroma.strength
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
291 );
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
292
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
293 vf->priv->luma.quality = vf->priv->chroma.quality= 3.0;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
294
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
295 if(e==3){
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
296 vf->priv->chroma.radius= vf->priv->luma.radius;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
297 vf->priv->chroma.preFilterRadius = vf->priv->luma.preFilterRadius;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
298 vf->priv->chroma.strength= vf->priv->luma.strength;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
299 }else if(e!=6)
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
300 return 0;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
301
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
302 // if(vf->priv->luma.radius < 0) return 0;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
303 // if(vf->priv->chroma.radius < 0) return 0;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
304
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
305 return 1;
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
306 }
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
307
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
308 vf_info_t vf_info_sab = {
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
309 "shape adaptive blur",
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
310 "sab",
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
311 "Michael Niedermayer",
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
312 "",
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
313 open
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
314 };
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
315
fd0da9a7d2e3 shape adaptive blur (slightly slow though)
michael
parents:
diff changeset
316 //===========================================================================//