Exemple #1
0
static int alloc_sws_context(FilterParam *f, int width, int height, unsigned int flags)
{
	SwsVector *vec;
	SwsFilter sws_filter;

	vec = sws_getGaussianVec(f->radius, f->quality);

	if (!vec)
		return 0;

	sws_scaleVec(vec, f->strength);
	vec->coeff[vec->length / 2] += 1.0 - f->strength;
	sws_filter.lumH = sws_filter.lumV = vec;
	sws_filter.chrH = sws_filter.chrV = NULL;
	f->filter_context = sws_getCachedContext(NULL,
											 width, height, AV_PIX_FMT_GRAY8,
											 width, height, AV_PIX_FMT_GRAY8,
											 flags, &sws_filter, NULL, NULL);

	sws_freeVec(vec);

	if (!f->filter_context)
		return 0;

	return 1;
}
Exemple #2
0
static int allocStuff(FilterParam *f, int width, int height){
	int stride= (width+7)&~7;
	SwsVector *vec;
	SwsFilter swsF;
	int i,x,y;
	f->preFilterBuf= (uint8_t*)memalign(8, stride*height);
	f->preFilterStride= stride;

	vec = sws_getGaussianVec(f->preFilterRadius, f->quality);
	swsF.lumH= swsF.lumV= vec;
	swsF.chrH= swsF.chrV= NULL;
	f->preFilterContext= sws_getContext(
		width, height, PIX_FMT_GRAY8, width, height, PIX_FMT_GRAY8, get_sws_cpuflags()|SWS_POINT, &swsF, NULL, NULL);

	sws_freeVec(vec);
	vec = sws_getGaussianVec(f->strength, 5.0);
	for(i=0; i<512; i++){
		double d;
		int index= i-256 + vec->length/2;

		if(index<0 || index>=vec->length) 	d= 0.0;
		else					d= vec->coeff[index];

		f->colorDiffCoeff[i]= (int)(d/vec->coeff[vec->length/2]*(1<<12) + 0.5);
	}
	sws_freeVec(vec);
	vec = sws_getGaussianVec(f->radius, f->quality);
	f->distWidth= vec->length;
	f->distStride= (vec->length+7)&~7;
	f->distCoeff= (int32_t*)memalign(8, f->distWidth*f->distStride*sizeof(int32_t));

	for(y=0; y<vec->length; y++){
		for(x=0; x<vec->length; x++){
			double d= vec->coeff[x] * vec->coeff[y];

			f->distCoeff[x + y*f->distStride]= (int)(d*(1<<10) + 0.5);
//			if(y==vec->length/2)
//				printf("%6d ", f->distCoeff[x + y*f->distStride]);
		}
	}
	sws_freeVec(vec);

	return 0;
}
Exemple #3
0
static int allocStuff(FilterParam *f, int width, int height){
    SwsVector *vec;
    SwsFilter swsF;

    vec = sws_getGaussianVec(f->radius, f->quality);
    sws_scaleVec(vec, f->strength);
    vec->coeff[vec->length/2]+= 1.0 - f->strength;
    swsF.lumH= swsF.lumV= vec;
    swsF.chrH= swsF.chrV= NULL;
    f->filterContext= sws_getContext(
        width, height, PIX_FMT_GRAY8, width, height, PIX_FMT_GRAY8, SWS_BICUBIC, &swsF, NULL, NULL);

    sws_freeVec(vec);

    return 0;
}