43 #define MIN_MATRIX_SIZE 3
44 #define MAX_MATRIX_SIZE 63
73 uint32_t **SC = fp->
SC;
79 int amount = fp->
amount * 65536.0;
82 int scalebits = (stepsX+stepsY)*2;
83 int32_t halfscale = 1 << ((stepsX+stepsY)*2-1);
88 if( dstStride == srcStride )
91 for( y=0; y<
height; y++, dst+=dstStride, src+=srcStride )
96 for( y=0; y<2*stepsY; y++ )
97 memset( SC[y], 0,
sizeof(SC[y][0]) * (width+2*stepsX) );
99 for( y=-stepsY; y<height+stepsY; y++ ) {
100 if( y < height ) src2 = src;
101 memset( SR, 0,
sizeof(SR[0]) * (2*stepsX-1) );
102 for( x=-stepsX; x<width+stepsX; x++ ) {
103 Tmp1 = x<=0 ? src2[0] : x>=width ? src2[width-1] : src2[x];
104 for( z=0; z<stepsX*2; z+=2 ) {
105 Tmp2 = SR[z+0] + Tmp1; SR[z+0] = Tmp1;
106 Tmp1 = SR[z+1] + Tmp2; SR[z+1] = Tmp2;
108 for( z=0; z<stepsY*2; z+=2 ) {
109 Tmp2 = SC[z+0][x+stepsX] + Tmp1; SC[z+0][x+stepsX] = Tmp1;
110 Tmp1 = SC[z+1][x+stepsX] + Tmp2; SC[z+1][x+stepsX] = Tmp2;
112 if( x>=stepsX && y>=stepsY ) {
113 uint8_t* srx = src - stepsY*srcStride + x - stepsX;
114 uint8_t* dsx = dst - stepsY*dstStride + x - stepsX;
116 res = (
int32_t)*srx + ( ( ( (
int32_t)*srx - (
int32_t)((Tmp1+halfscale) >> scalebits) ) * amount ) >> 16 );
117 *dsx = res>255 ? 255 : res<0 ? 0 : (
uint8_t)res;
129 static int config(
struct vf_instance *vf,
131 unsigned int flags,
unsigned int outfmt ) {
133 int z, stepsX, stepsY;
139 fp = &vf->priv->lumaParam;
140 effect = fp->
amount == 0 ?
"don't touch" : fp->
amount < 0 ?
"blur" :
"sharpen";
142 memset( fp->
SC, 0,
sizeof( fp->
SC ) );
145 for( z=0; z<2*stepsY; z++ )
146 fp->
SC[z] =
av_malloc(
sizeof(*(fp->
SC[z])) * (width+2*stepsX));
148 fp = &vf->priv->chromaParam;
149 effect = fp->
amount == 0 ?
"don't touch" : fp->
amount < 0 ?
"blur" :
"sharpen";
151 memset( fp->
SC, 0,
sizeof( fp->
SC ) );
154 for( z=0; z<2*stepsY; z++ )
155 fp->
SC[z] =
av_malloc(
sizeof(*(fp->
SC[z])) * (width+2*stepsX));
165 if( mpi->
imgfmt!=vf->priv->outfmt )
169 mpi->
planes[0] = vf->dmpi->planes[0];
170 mpi->
stride[0] = vf->dmpi->stride[0];
171 mpi->
width = vf->dmpi->width;
173 mpi->
planes[1] = vf->dmpi->planes[1];
174 mpi->
planes[2] = vf->dmpi->planes[2];
175 mpi->
stride[1] = vf->dmpi->stride[1];
176 mpi->
stride[2] = vf->dmpi->stride[2];
197 __asm__
volatile (
"emms\n\t");
201 __asm__
volatile (
"sfence\n\t");
207 static void uninit(
struct vf_instance *vf ) {
211 if( !vf->priv )
return;
213 fp = &vf->priv->lumaParam;
214 for( z=0; z<
sizeof(fp->
SC)/
sizeof(fp->
SC[0]); z++ ) {
218 fp = &vf->priv->chromaParam;
219 for( z=0; z<
sizeof(fp->
SC)/
sizeof(fp->
SC[0]); z++ ) {
248 char *max = args + strlen(args);
251 fp->
msizeX = ( pos && pos+1<max ) ? atoi( pos+1 ) : 0;
252 z = strchr( pos+1,
'x' );
253 fp->
msizeY = ( z && z+1<max ) ? atoi( pos=z+1 ) : fp->
msizeX;
260 pos = strchr( pos+1,
':' );
261 fp->
amount = ( pos && pos+1<max ) ? atof( pos+1 ) : 0;
283 char *args2 = strchr( args,
'l' );
292 args2 = strchr( args,
'c' );
316 "unsharp mask & gaussian blur",