Commit 221b804f authored by Diego Biurrun's avatar Diego Biurrun

cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.

Originally committed as revision 23173 to svn://svn.mplayerhq.hu/mplayer/trunk/libswscale
parent 07d84a4e
......@@ -36,8 +36,8 @@ static uint64_t getSSD(uint8_t *src1, uint8_t *src2, int stride1, int stride2, i
//printf("%d %d\n", w, h);
for(y=0; y<h; y++){
for(x=0; x<w; x++){
for (y=0; y<h; y++){
for (x=0; x<w; x++){
int d= src1[x + y*stride1] - src2[x + y*stride2];
ssd+= d*d;
//printf("%d", abs(src1[x + y*stride1] - src2[x + y*stride2])/26 );
......@@ -61,14 +61,14 @@ static int doTest(uint8_t *ref[3], int refStride[3], int w, int h, int srcFormat
int res;
res = 0;
for(i=0; i<3; i++){
for (i=0; i<3; i++){
// avoid stride % bpp != 0
if(srcFormat==PIX_FMT_RGB24 || srcFormat==PIX_FMT_BGR24)
if (srcFormat==PIX_FMT_RGB24 || srcFormat==PIX_FMT_BGR24)
srcStride[i]= srcW*3;
else
srcStride[i]= srcW*4;
if(dstFormat==PIX_FMT_RGB24 || dstFormat==PIX_FMT_BGR24)
if (dstFormat==PIX_FMT_RGB24 || dstFormat==PIX_FMT_BGR24)
dstStride[i]= dstW*3;
else
dstStride[i]= dstW*4;
......@@ -127,13 +127,13 @@ static int doTest(uint8_t *ref[3], int refStride[3], int w, int h, int srcFormat
ssdU= getSSD(ref[1], out[1], refStride[1], refStride[1], (w+1)>>1, (h+1)>>1);
ssdV= getSSD(ref[2], out[2], refStride[2], refStride[2], (w+1)>>1, (h+1)>>1);
if(srcFormat == PIX_FMT_GRAY8 || dstFormat==PIX_FMT_GRAY8) ssdU=ssdV=0; //FIXME check that output is really gray
if (srcFormat == PIX_FMT_GRAY8 || dstFormat==PIX_FMT_GRAY8) ssdU=ssdV=0; //FIXME check that output is really gray
ssdY/= w*h;
ssdU/= w*h/4;
ssdV/= w*h/4;
if(ssdY>100 || ssdU>100 || ssdV>100){
if (ssdY>100 || ssdU>100 || ssdV>100){
printf(" %s %dx%d -> %s %4dx%4d flags=%2d SSD=%5lld,%5lld,%5lld\n",
sws_format_name(srcFormat), srcW, srcH,
sws_format_name(dstFormat), dstW, dstH,
......@@ -147,7 +147,7 @@ static int doTest(uint8_t *ref[3], int refStride[3], int w, int h, int srcFormat
sws_freeContext(dstContext);
sws_freeContext(outContext);
for(i=0; i<3; i++){
for (i=0; i<3; i++){
free(src[i]);
free(dst[i]);
free(out[i]);
......@@ -165,17 +165,17 @@ static void selfTest(uint8_t *src[3], int stride[3], int w, int h){
int srcW, srcH, dstW, dstH;
int flags;
for(srcFormat = 0; srcFormat < PIX_FMT_NB; srcFormat++) {
for(dstFormat = 0; dstFormat < PIX_FMT_NB; dstFormat++) {
for (srcFormat = 0; srcFormat < PIX_FMT_NB; srcFormat++) {
for (dstFormat = 0; dstFormat < PIX_FMT_NB; dstFormat++) {
printf("%s -> %s\n",
sws_format_name(srcFormat),
sws_format_name(dstFormat));
srcW= w;
srcH= h;
for(dstW=w - w/3; dstW<= 4*w/3; dstW+= w/3){
for(dstH=h - h/3; dstH<= 4*h/3; dstH+= h/3){
for(flags=1; flags<33; flags*=2) {
for (dstW=w - w/3; dstW<= 4*w/3; dstW+= w/3){
for (dstH=h - h/3; dstH<= 4*h/3; dstH+= h/3){
for (flags=1; flags<33; flags*=2) {
int res;
res = doTest(src, stride, w, h, srcFormat, dstFormat,
......@@ -207,8 +207,8 @@ int main(int argc, char **argv){
sws= sws_getContext(W/12, H/12, PIX_FMT_RGB32, W, H, PIX_FMT_YUV420P, 2, NULL, NULL, NULL);
for(y=0; y<H; y++){
for(x=0; x<W*4; x++){
for (y=0; y<H; y++){
for (x=0; x<W*4; x++){
rgb_data[ x + y*4*W]= random();
}
}
......
......@@ -102,21 +102,21 @@ untested special converters
#define PI 3.14159265358979323846
#endif
#define isSupportedIn(x) ((x)==PIX_FMT_YUV420P || (x)==PIX_FMT_YUYV422 || (x)==PIX_FMT_UYVY422\
|| (x)==PIX_FMT_RGB32|| (x)==PIX_FMT_BGR24|| (x)==PIX_FMT_BGR565|| (x)==PIX_FMT_BGR555\
|| (x)==PIX_FMT_BGR32|| (x)==PIX_FMT_RGB24|| (x)==PIX_FMT_RGB565|| (x)==PIX_FMT_RGB555\
|| (x)==PIX_FMT_GRAY8 || (x)==PIX_FMT_YUV410P\
|| (x)==PIX_FMT_GRAY16BE || (x)==PIX_FMT_GRAY16LE\
|| (x)==PIX_FMT_YUV444P || (x)==PIX_FMT_YUV422P || (x)==PIX_FMT_YUV411P\
|| (x)==PIX_FMT_PAL8 || (x)==PIX_FMT_BGR8 || (x)==PIX_FMT_RGB8\
#define isSupportedIn(x) ((x)==PIX_FMT_YUV420P || (x)==PIX_FMT_YUYV422 || (x)==PIX_FMT_UYVY422 \
|| (x)==PIX_FMT_RGB32 || (x)==PIX_FMT_BGR24 || (x)==PIX_FMT_BGR565 || (x)==PIX_FMT_BGR555 \
|| (x)==PIX_FMT_BGR32 || (x)==PIX_FMT_RGB24 || (x)==PIX_FMT_RGB565 || (x)==PIX_FMT_RGB555 \
|| (x)==PIX_FMT_GRAY8 || (x)==PIX_FMT_YUV410P \
|| (x)==PIX_FMT_GRAY16BE || (x)==PIX_FMT_GRAY16LE \
|| (x)==PIX_FMT_YUV444P || (x)==PIX_FMT_YUV422P || (x)==PIX_FMT_YUV411P \
|| (x)==PIX_FMT_PAL8 || (x)==PIX_FMT_BGR8 || (x)==PIX_FMT_RGB8 \
|| (x)==PIX_FMT_BGR4_BYTE || (x)==PIX_FMT_RGB4_BYTE)
#define isSupportedOut(x) ((x)==PIX_FMT_YUV420P || (x)==PIX_FMT_YUYV422 || (x)==PIX_FMT_UYVY422\
|| (x)==PIX_FMT_YUV444P || (x)==PIX_FMT_YUV422P || (x)==PIX_FMT_YUV411P\
|| isRGB(x) || isBGR(x)\
|| (x)==PIX_FMT_NV12 || (x)==PIX_FMT_NV21\
|| (x)==PIX_FMT_GRAY16BE || (x)==PIX_FMT_GRAY16LE\
#define isSupportedOut(x) ((x)==PIX_FMT_YUV420P || (x)==PIX_FMT_YUYV422 || (x)==PIX_FMT_UYVY422 \
|| (x)==PIX_FMT_YUV444P || (x)==PIX_FMT_YUV422P || (x)==PIX_FMT_YUV411P \
|| isRGB(x) || isBGR(x) \
|| (x)==PIX_FMT_NV12 || (x)==PIX_FMT_NV21 \
|| (x)==PIX_FMT_GRAY16BE || (x)==PIX_FMT_GRAY16LE \
|| (x)==PIX_FMT_GRAY8 || (x)==PIX_FMT_YUV410P)
#define isPacked(x) ((x)==PIX_FMT_PAL8 || (x)==PIX_FMT_YUYV422 ||\
#define isPacked(x) ((x)==PIX_FMT_PAL8 || (x)==PIX_FMT_YUYV422 || \
(x)==PIX_FMT_UYVY422 || isRGB(x) || isBGR(x))
#define RGB2YUV_SHIFT 16
......@@ -191,7 +191,7 @@ static const uint64_t bgr2UCoeff attribute_used __attribute__((aligned(8))) = 0
static const uint64_t bgr2VCoeff attribute_used __attribute__((aligned(8))) = 0x00003831D0E6F6EAULL;
#endif /* FAST_BGR2YV12 */
static const uint64_t bgr2YOffset attribute_used __attribute__((aligned(8))) = 0x1010101010101010ULL;
static const uint64_t bgr2UVOffset attribute_used __attribute__((aligned(8)))= 0x8080808080808080ULL;
static const uint64_t bgr2UVOffset attribute_used __attribute__((aligned(8))) = 0x8080808080808080ULL;
static const uint64_t w1111 attribute_used __attribute__((aligned(8))) = 0x0001000100010001ULL;
#endif /* defined(ARCH_X86) */
......@@ -300,7 +300,7 @@ void in_asm_used_var_warning_killer()
volatile int i= bF8+bFC+w10+
bm00001111+bm00000111+bm11111000+b16Mask+g16Mask+r16Mask+b15Mask+g15Mask+r15Mask+
M24A+M24B+M24C+w02 + b5Dither+g5Dither+r5Dither+g6Dither+dither4[0]+dither8[0]+bm01010101;
if(i) i=0;
if (i) i=0;
}
#endif
......@@ -310,23 +310,23 @@ static inline void yuv2yuvXinC(int16_t *lumFilter, int16_t **lumSrc, int lumFilt
{
//FIXME Optimize (just quickly writen not opti..)
int i;
for(i=0; i<dstW; i++)
for (i=0; i<dstW; i++)
{
int val=1<<18;
int j;
for(j=0; j<lumFilterSize; j++)
for (j=0; j<lumFilterSize; j++)
val += lumSrc[j][i] * lumFilter[j];
dest[i]= av_clip_uint8(val>>19);
}
if(uDest != NULL)
for(i=0; i<chrDstW; i++)
if (uDest != NULL)
for (i=0; i<chrDstW; i++)
{
int u=1<<18;
int v=1<<18;
int j;
for(j=0; j<chrFilterSize; j++)
for (j=0; j<chrFilterSize; j++)
{
u += chrSrc[j][i] * chrFilter[j];
v += chrSrc[j][i + 2048] * chrFilter[j];
......@@ -343,26 +343,26 @@ static inline void yuv2nv12XinC(int16_t *lumFilter, int16_t **lumSrc, int lumFil
{
//FIXME Optimize (just quickly writen not opti..)
int i;
for(i=0; i<dstW; i++)
for (i=0; i<dstW; i++)
{
int val=1<<18;
int j;
for(j=0; j<lumFilterSize; j++)
for (j=0; j<lumFilterSize; j++)
val += lumSrc[j][i] * lumFilter[j];
dest[i]= av_clip_uint8(val>>19);
}
if(uDest == NULL)
if (uDest == NULL)
return;
if(dstFormat == PIX_FMT_NV12)
for(i=0; i<chrDstW; i++)
if (dstFormat == PIX_FMT_NV12)
for (i=0; i<chrDstW; i++)
{
int u=1<<18;
int v=1<<18;
int j;
for(j=0; j<chrFilterSize; j++)
for (j=0; j<chrFilterSize; j++)
{
u += chrSrc[j][i] * chrFilter[j];
v += chrSrc[j][i + 2048] * chrFilter[j];
......@@ -372,12 +372,12 @@ static inline void yuv2nv12XinC(int16_t *lumFilter, int16_t **lumSrc, int lumFil
uDest[2*i+1]= av_clip_uint8(v>>19);
}
else
for(i=0; i<chrDstW; i++)
for (i=0; i<chrDstW; i++)
{
int u=1<<18;
int v=1<<18;
int j;
for(j=0; j<chrFilterSize; j++)
for (j=0; j<chrFilterSize; j++)
{
u += chrSrc[j][i] * chrFilter[j];
v += chrSrc[j][i + 2048] * chrFilter[j];
......@@ -389,21 +389,21 @@ static inline void yuv2nv12XinC(int16_t *lumFilter, int16_t **lumSrc, int lumFil
}
#define YSCALE_YUV_2_PACKEDX_C(type) \
for(i=0; i<(dstW>>1); i++){\
for (i=0; i<(dstW>>1); i++){\
int j;\
int Y1=1<<18;\
int Y2=1<<18;\
int U=1<<18;\
int V=1<<18;\
int Y1 = 1<<18;\
int Y2 = 1<<18;\
int U = 1<<18;\
int V = 1<<18;\
type attribute_unused *r, *b, *g;\
const int i2= 2*i;\
\
for(j=0; j<lumFilterSize; j++)\
for (j=0; j<lumFilterSize; j++)\
{\
Y1 += lumSrc[j][i2] * lumFilter[j];\
Y2 += lumSrc[j][i2+1] * lumFilter[j];\
}\
for(j=0; j<chrFilterSize; j++)\
for (j=0; j<chrFilterSize; j++)\
{\
U += chrSrc[j][i] * chrFilter[j];\
V += chrSrc[j][i+2048] * chrFilter[j];\
......@@ -412,31 +412,31 @@ static inline void yuv2nv12XinC(int16_t *lumFilter, int16_t **lumSrc, int lumFil
Y2>>=19;\
U >>=19;\
V >>=19;\
if((Y1|Y2|U|V)&256)\
if ((Y1|Y2|U|V)&256)\
{\
if(Y1>255) Y1=255;\
else if(Y1<0)Y1=0;\
if(Y2>255) Y2=255;\
else if(Y2<0)Y2=0;\
if(U>255) U=255;\
else if(U<0) U=0;\
if(V>255) V=255;\
else if(V<0) V=0;\
if (Y1>255) Y1=255; \
else if (Y1<0)Y1=0; \
if (Y2>255) Y2=255; \
else if (Y2<0)Y2=0; \
if (U>255) U=255; \
else if (U<0) U=0; \
if (V>255) V=255; \
else if (V<0) V=0; \
}
#define YSCALE_YUV_2_RGBX_C(type) \
YSCALE_YUV_2_PACKEDX_C(type)\
r = (type *)c->table_rV[V];\
g = (type *)(c->table_gU[U] + c->table_gV[V]);\
b = (type *)c->table_bU[U];\
YSCALE_YUV_2_PACKEDX_C(type) \
r = (type *)c->table_rV[V]; \
g = (type *)(c->table_gU[U] + c->table_gV[V]); \
b = (type *)c->table_bU[U]; \
#define YSCALE_YUV_2_PACKED2_C \
for(i=0; i<(dstW>>1); i++){\
const int i2= 2*i;\
int Y1= (buf0[i2 ]*yalpha1+buf1[i2 ]*yalpha)>>19;\
int Y2= (buf0[i2+1]*yalpha1+buf1[i2+1]*yalpha)>>19;\
int U= (uvbuf0[i ]*uvalpha1+uvbuf1[i ]*uvalpha)>>19;\
int V= (uvbuf0[i+2048]*uvalpha1+uvbuf1[i+2048]*uvalpha)>>19;\
for (i=0; i<(dstW>>1); i++){ \
const int i2= 2*i; \
int Y1= (buf0[i2 ]*yalpha1+buf1[i2 ]*yalpha)>>19; \
int Y2= (buf0[i2+1]*yalpha1+buf1[i2+1]*yalpha)>>19; \
int U= (uvbuf0[i ]*uvalpha1+uvbuf1[i ]*uvalpha)>>19; \
int V= (uvbuf0[i+2048]*uvalpha1+uvbuf1[i+2048]*uvalpha)>>19; \
#define YSCALE_YUV_2_RGB2_C(type) \
YSCALE_YUV_2_PACKED2_C\
......@@ -446,7 +446,7 @@ static inline void yuv2nv12XinC(int16_t *lumFilter, int16_t **lumSrc, int lumFil
b = (type *)c->table_bU[U];\
#define YSCALE_YUV_2_PACKED1_C \
for(i=0; i<(dstW>>1); i++){\
for (i=0; i<(dstW>>1); i++){\
const int i2= 2*i;\
int Y1= buf0[i2 ]>>7;\
int Y2= buf0[i2+1]>>7;\
......@@ -461,7 +461,7 @@ static inline void yuv2nv12XinC(int16_t *lumFilter, int16_t **lumSrc, int lumFil
b = (type *)c->table_bU[U];\
#define YSCALE_YUV_2_PACKED1B_C \
for(i=0; i<(dstW>>1); i++){\
for (i=0; i<(dstW>>1); i++){\
const int i2= 2*i;\
int Y1= buf0[i2 ]>>7;\
int Y2= buf0[i2+1]>>7;\
......@@ -574,7 +574,7 @@ static inline void yuv2nv12XinC(int16_t *lumFilter, int16_t **lumSrc, int lumFil
{\
const uint8_t * const d128=dither_8x8_220[y&7];\
uint8_t *g= c->table_gU[128] + c->table_gV[128];\
for(i=0; i<dstW-7; i+=8){\
for (i=0; i<dstW-7; i+=8){\
int acc;\
acc = g[((buf0[i ]*yalpha1+buf1[i ]*yalpha)>>19) + d128[0]];\
acc+= acc + g[((buf0[i+1]*yalpha1+buf1[i+1]*yalpha)>>19) + d128[1]];\
......@@ -605,7 +605,7 @@ static inline void yuv2nv12XinC(int16_t *lumFilter, int16_t **lumSrc, int lumFil
int error_in3=0;\
int f=0;\
\
for(i=dstW>>1; i<dstW; i++){\
for (i=dstW>>1; i<dstW; i++){\
int in= ((buf0[i ]*yalpha1+buf1[i ]*yalpha)>>19);\
int in2 = (76309 * (in - 16) + 32768) >> 16;\
int in3 = (in2 < 0) ? 0 : ((in2 > 255) ? 255 : in2);\
......@@ -616,8 +616,8 @@ static inline void yuv2nv12XinC(int16_t *lumFilter, int16_t **lumSrc, int lumFil
error_new+= FFABS(last_new[y][i] - new);\
error_in3+= FFABS(last_in3[y][i] - in3);\
f= error_new - error_in3*4;\
if(f<0) f=0;\
if(f>256) f=256;\
if (f<0) f=0;\
if (f>256) f=256;\
\
topLeft= top[i];\
left= top[i]= old - new;\
......@@ -625,7 +625,7 @@ static inline void yuv2nv12XinC(int16_t *lumFilter, int16_t **lumSrc, int lumFil
last_in3[y][i]= in3;\
\
acc+= acc + (new&1);\
if((i&7)==6){\
if ((i&7)==6){\
((uint8_t*)dest)[0]= acc;\
((uint8_t*)dest)++;\
}\
......@@ -757,28 +757,28 @@ static inline void yuv2packedXinC(SwsContext *c, int16_t *lumFilter, int16_t **l
const uint8_t * const d128=dither_8x8_220[y&7];
uint8_t *g= c->table_gU[128] + c->table_gV[128];
int acc=0;
for(i=0; i<dstW-1; i+=2){
for (i=0; i<dstW-1; i+=2){
int j;
int Y1=1<<18;
int Y2=1<<18;
for(j=0; j<lumFilterSize; j++)
for (j=0; j<lumFilterSize; j++)
{
Y1 += lumSrc[j][i] * lumFilter[j];
Y2 += lumSrc[j][i+1] * lumFilter[j];
}
Y1>>=19;
Y2>>=19;
if((Y1|Y2)&256)
if ((Y1|Y2)&256)
{
if(Y1>255) Y1=255;
else if(Y1<0)Y1=0;
if(Y2>255) Y2=255;
else if(Y2<0)Y2=0;
if (Y1>255) Y1=255;
else if (Y1<0)Y1=0;
if (Y2>255) Y2=255;
else if (Y2<0)Y2=0;
}
acc+= acc + g[Y1+d128[(i+0)&7]];
acc+= acc + g[Y2+d128[(i+1)&7]];
if((i&7)==6){
if ((i&7)==6){
((uint8_t*)dest)[0]= acc;
dest++;
}
......@@ -903,7 +903,7 @@ static inline void yuv2packedXinC(SwsContext *c, int16_t *lumFilter, int16_t **l
static double getSplineCoeff(double a, double b, double c, double d, double dist)
{
// printf("%f %f %f %f %f\n", a,b,c,d,dist);
if(dist<=1.0) return ((d*dist + c)*dist + b)*dist +a;
if (dist<=1.0) return ((d*dist + c)*dist + b)*dist +a;
else return getSplineCoeff( 0.0,
b+ 2.0*c + 3.0*d,
c + 3.0*d,
......@@ -922,28 +922,28 @@ static inline int initFilter(int16_t **outFilter, int16_t **filterPos, int *outF
double *filter=NULL;
double *filter2=NULL;
#if defined(ARCH_X86)
if(flags & SWS_CPU_CAPS_MMX)
if (flags & SWS_CPU_CAPS_MMX)
asm volatile("emms\n\t"::: "memory"); //FIXME this shouldnt be required but it IS (even for non mmx versions)
#endif
// Note the +1 is for the MMXscaler which reads over the end
*filterPos = av_malloc((dstW+1)*sizeof(int16_t));
if(FFABS(xInc - 0x10000) <10) // unscaled
if (FFABS(xInc - 0x10000) <10) // unscaled
{
int i;
filterSize= 1;
filter= av_malloc(dstW*sizeof(double)*filterSize);
for(i=0; i<dstW*filterSize; i++) filter[i]=0;
for (i=0; i<dstW*filterSize; i++) filter[i]=0;
for(i=0; i<dstW; i++)
for (i=0; i<dstW; i++)
{
filter[i*filterSize]=1;
(*filterPos)[i]=i;
}
}
else if(flags&SWS_POINT) // lame looking point sampling mode
else if (flags&SWS_POINT) // lame looking point sampling mode
{
int i;
int xDstInSrc;
......@@ -951,7 +951,7 @@ static inline int initFilter(int16_t **outFilter, int16_t **filterPos, int *outF
filter= av_malloc(dstW*sizeof(double)*filterSize);
xDstInSrc= xInc/2 - 0x8000;
for(i=0; i<dstW; i++)
for (i=0; i<dstW; i++)
{
int xx= (xDstInSrc - ((filterSize-1)<<15) + (1<<15))>>16;
......@@ -960,28 +960,28 @@ static inline int initFilter(int16_t **outFilter, int16_t **filterPos, int *outF
xDstInSrc+= xInc;
}
}
else if((xInc <= (1<<16) && (flags&SWS_AREA)) || (flags&SWS_FAST_BILINEAR)) // bilinear upscale
else if ((xInc <= (1<<16) && (flags&SWS_AREA)) || (flags&SWS_FAST_BILINEAR)) // bilinear upscale
{
int i;
int xDstInSrc;
if (flags&SWS_BICUBIC) filterSize= 4;
else if(flags&SWS_X ) filterSize= 4;
else if (flags&SWS_X ) filterSize= 4;
else filterSize= 2; // SWS_BILINEAR / SWS_AREA
filter= av_malloc(dstW*sizeof(double)*filterSize);
xDstInSrc= xInc/2 - 0x8000;
for(i=0; i<dstW; i++)
for (i=0; i<dstW; i++)
{
int xx= (xDstInSrc - ((filterSize-1)<<15) + (1<<15))>>16;
int j;
(*filterPos)[i]= xx;
//Bilinear upscale / linear interpolate / Area averaging
for(j=0; j<filterSize; j++)
for (j=0; j<filterSize; j++)
{
double d= FFABS((xx<<16) - xDstInSrc)/(double)(1<<16);
double coeff= 1.0 - d;
if(coeff<0) coeff=0;
if (coeff<0) coeff=0;
filter[i*filterSize + j]= coeff;
xx++;
}
......@@ -995,94 +995,94 @@ static inline int initFilter(int16_t **outFilter, int16_t **filterPos, int *outF
const double xInc1= (double)xInc / (double)(1<<16);
if (flags&SWS_BICUBIC) sizeFactor= 4.0;
else if(flags&SWS_X) sizeFactor= 8.0;
else if(flags&SWS_AREA) sizeFactor= 1.0; //downscale only, for upscale it is bilinear
else if(flags&SWS_GAUSS) sizeFactor= 8.0; // infinite ;)
else if(flags&SWS_LANCZOS) sizeFactor= param[0] != SWS_PARAM_DEFAULT ? 2.0*param[0] : 6.0;
else if(flags&SWS_SINC) sizeFactor= 20.0; // infinite ;)
else if(flags&SWS_SPLINE) sizeFactor= 20.0; // infinite ;)
else if(flags&SWS_BILINEAR) sizeFactor= 2.0;
else if (flags&SWS_X) sizeFactor= 8.0;
else if (flags&SWS_AREA) sizeFactor= 1.0; //downscale only, for upscale it is bilinear
else if (flags&SWS_GAUSS) sizeFactor= 8.0; // infinite ;)
else if (flags&SWS_LANCZOS) sizeFactor= param[0] != SWS_PARAM_DEFAULT ? 2.0*param[0] : 6.0;
else if (flags&SWS_SINC) sizeFactor= 20.0; // infinite ;)
else if (flags&SWS_SPLINE) sizeFactor= 20.0; // infinite ;)
else if (flags&SWS_BILINEAR) sizeFactor= 2.0;
else {
sizeFactor= 0.0; //GCC warning killer
ASSERT(0)
}
if(xInc1 <= 1.0) filterSizeInSrc= sizeFactor; // upscale
if (xInc1 <= 1.0) filterSizeInSrc= sizeFactor; // upscale
else filterSizeInSrc= sizeFactor*srcW / (double)dstW;
filterSize= (int)ceil(1 + filterSizeInSrc); // will be reduced later if possible
if(filterSize > srcW-2) filterSize=srcW-2;
if (filterSize > srcW-2) filterSize=srcW-2;
filter= av_malloc(dstW*sizeof(double)*filterSize);
xDstInSrc= xInc1 / 2.0 - 0.5;
for(i=0; i<dstW; i++)
for (i=0; i<dstW; i++)
{
int xx= (int)(xDstInSrc - (filterSize-1)*0.5 + 0.5);
int j;
(*filterPos)[i]= xx;
for(j=0; j<filterSize; j++)
for (j=0; j<filterSize; j++)
{
double d= FFABS(xx - xDstInSrc)/filterSizeInSrc*sizeFactor;
double coeff;
if(flags & SWS_BICUBIC)
if (flags & SWS_BICUBIC)
{
double B= param[0] != SWS_PARAM_DEFAULT ? param[0] : 0.0;
double C= param[1] != SWS_PARAM_DEFAULT ? param[1] : 0.6;
if(d<1.0)
if (d<1.0)
coeff = (12-9*B-6*C)*d*d*d + (-18+12*B+6*C)*d*d + 6-2*B;
else if(d<2.0)
else if (d<2.0)
coeff = (-B-6*C)*d*d*d + (6*B+30*C)*d*d + (-12*B-48*C)*d +8*B+24*C;
else
coeff=0.0;
}
/* else if(flags & SWS_X)
/* else if (flags & SWS_X)
{
double p= param ? param*0.01 : 0.3;
coeff = d ? sin(d*PI)/(d*PI) : 1.0;
coeff*= pow(2.0, - p*d*d);
}*/
else if(flags & SWS_X)
else if (flags & SWS_X)
{
double A= param[0] != SWS_PARAM_DEFAULT ? param[0] : 1.0;
if(d<1.0)
if (d<1.0)
coeff = cos(d*PI);
else
coeff=-1.0;
if(coeff<0.0) coeff= -pow(-coeff, A);
if (coeff<0.0) coeff= -pow(-coeff, A);
else coeff= pow( coeff, A);
coeff= coeff*0.5 + 0.5;
}
else if(flags & SWS_AREA)
else if (flags & SWS_AREA)
{
double srcPixelSize= 1.0/xInc1;
if(d + srcPixelSize/2 < 0.5) coeff= 1.0;
else if(d - srcPixelSize/2 < 0.5) coeff= (0.5-d)/srcPixelSize + 0.5;
if (d + srcPixelSize/2 < 0.5) coeff= 1.0;
else if (d - srcPixelSize/2 < 0.5) coeff= (0.5-d)/srcPixelSize + 0.5;
else coeff=0.0;
}
else if(flags & SWS_GAUSS)
else if (flags & SWS_GAUSS)
{
double p= param[0] != SWS_PARAM_DEFAULT ? param[0] : 3.0;
coeff = pow(2.0, - p*d*d);
}
else if(flags & SWS_SINC)
else if (flags & SWS_SINC)
{
coeff = d ? sin(d*PI)/(d*PI) : 1.0;
}
else if(flags & SWS_LANCZOS)
else if (flags & SWS_LANCZOS)
{
double p= param[0] != SWS_PARAM_DEFAULT ? param[0] : 3.0;
coeff = d ? sin(d*PI)*sin(d*PI/p)/(d*d*PI*PI/p) : 1.0;
if(d>p) coeff=0;
if (d>p) coeff=0;
}
else if(flags & SWS_BILINEAR)
else if (flags & SWS_BILINEAR)
{
coeff= 1.0 - d;
if(coeff<0) coeff=0;
if (coeff<0) coeff=0;
}
else if(flags & SWS_SPLINE)
else if (flags & SWS_SPLINE)
{
double p=-2.196152422706632;
coeff = getSplineCoeff(1.0, 0.0, p, -p-1.0, d);
......@@ -1104,12 +1104,12 @@ static inline int initFilter(int16_t **outFilter, int16_t **filterPos, int *outF
*/
ASSERT(filterSize>0)
filter2Size= filterSize;
if(srcFilter) filter2Size+= srcFilter->length - 1;
if(dstFilter) filter2Size+= dstFilter->length - 1;
if (srcFilter) filter2Size+= srcFilter->length - 1;
if (dstFilter) filter2Size+= dstFilter->length - 1;
ASSERT(filter2Size>0)
filter2= av_malloc(filter2Size*dstW*sizeof(double));
for(i=0; i<dstW; i++)
for (i=0; i<dstW; i++)
{
int j;
SwsVector scaleFilter;
......@@ -1118,45 +1118,45 @@ static inline int initFilter(int16_t **outFilter, int16_t **filterPos, int *outF
scaleFilter.coeff= filter + i*filterSize;
scaleFilter.length= filterSize;
if(srcFilter) outVec= sws_getConvVec(srcFilter, &scaleFilter);
if (srcFilter) outVec= sws_getConvVec(srcFilter, &scaleFilter);
else outVec= &scaleFilter;
ASSERT(outVec->length == filter2Size)
//FIXME dstFilter
for(j=0; j<outVec->length; j++)
for (j=0; j<outVec->length; j++)
{
filter2[i*filter2Size + j]= outVec->coeff[j];
}
(*filterPos)[i]+= (filterSize-1)/2 - (filter2Size-1)/2;
if(outVec != &scaleFilter) sws_freeVec(outVec);
if (outVec != &scaleFilter) sws_freeVec(outVec);
}
av_free(filter); filter=NULL;
/* try to reduce the filter-size (step1 find size and shift left) */
// Assume its near normalized (*0.5 or *2.0 is ok but * 0.001 is not)
minFilterSize= 0;
for(i=dstW-1; i>=0; i--)
for (i=dstW-1; i>=0; i--)
{
int min= filter2Size;
int j;
double cutOff=0.0;
/* get rid off near zero elements on the left by shifting left */
for(j=0; j<filter2Size; j++)
for (j=0; j<filter2Size; j++)
{
int k;
cutOff += FFABS(filter2[i*filter2Size]);
if(cutOff > SWS_MAX_REDUCE_CUTOFF) break;
if (cutOff > SWS_MAX_REDUCE_CUTOFF) break;
/* preserve Monotonicity because the core can't handle the filter otherwise */
if(i<dstW-1 && (*filterPos)[i] >= (*filterPos)[i+1]) break;
if (i<dstW-1 && (*filterPos)[i] >= (*filterPos)[i+1]) break;
// Move filter coeffs left
for(k=1; k<filter2Size; k++)
for (k=1; k<filter2Size; k++)
filter2[i*filter2Size + k - 1]= filter2[i*filter2Size + k];
filter2[i*filter2Size + k - 1]= 0.0;
(*filterPos)[i]++;
......@@ -1164,15 +1164,15 @@ static inline int initFilter(int16_t **outFilter, int16_t **filterPos, int *outF
cutOff=0.0;
/* count near zeros on the right */
for(j=filter2Size-1; j>0; j--)
for (j=filter2Size-1; j>0; j--)
{
cutOff += FFABS(filter2[i*filter2Size + j]);
if(cutOff > SWS_MAX_REDUCE_CUTOFF) break;
if (cutOff > SWS_MAX_REDUCE_CUTOFF) break;
min--;
}
if(min>minFilterSize) minFilterSize= min;
if (min>minFilterSize) minFilterSize= min;
}
if (flags & SWS_CPU_CAPS_ALTIVEC) {
......@@ -1192,7 +1192,7 @@ static inline int initFilter(int16_t **outFilter, int16_t **filterPos, int *outF
if (flags & SWS_CPU_CAPS_MMX) {
// special case for unscaled vertical filtering
if(minFilterSize == 1 && filterAlign == 2)
if (minFilterSize == 1 && filterAlign == 2)
filterAlign= 1;
}
......@@ -1200,20 +1200,20 @@ static inline int initFilter(int16_t **outFilter, int16_t **filterPos, int *outF
filterSize= (minFilterSize +(filterAlign-1)) & (~(filterAlign-1));
ASSERT(filterSize > 0)
filter= av_malloc(filterSize*dstW*sizeof(double));
if(filterSize >= MAX_FILTER_SIZE)
if (filterSize >= MAX_FILTER_SIZE)
return -1;
*outFilterSize= filterSize;
if(flags&SWS_PRINT_INFO)
if (flags&SWS_PRINT_INFO)
av_log(NULL, AV_LOG_VERBOSE, "SwScaler: reducing / aligning filtersize %d -> %d\n", filter2Size, filterSize);
/* try to reduce the filter-size (step2 reduce it) */
for(i=0; i<dstW; i++)
for (i=0; i<dstW; i++)
{
int j;
for(j=0; j<filterSize; j++)
for (j=0; j<filterSize; j++)
{
if(j>=filter2Size) filter[i*filterSize + j]= 0.0;
if (j>=filter2Size) filter[i*filterSize + j]= 0.0;
else filter[i*filterSize + j]= filter2[i*filter2Size + j];
}
}
......@@ -1223,13 +1223,13 @@ static inline int initFilter(int16_t **outFilter, int16_t **filterPos, int *outF
//FIXME try to align filterpos if possible
//fix borders
for(i=0; i<dstW; i++)
for (i=0; i<dstW; i++)
{
int j;
if((*filterPos)[i] < 0)
if ((*filterPos)[i] < 0)
{
// Move filter coeffs left to compensate for filterPos
for(j=1; j<filterSize; j++)
for (j=1; j<filterSize; j++)
{
int left= FFMAX(j + (*filterPos)[i], 0);
filter[i*filterSize + left] += filter[i*filterSize + j];
......@@ -1238,11 +1238,11 @@ static inline int initFilter(int16_t **outFilter, int16_t **filterPos, int *outF
(*filterPos)[i]= 0;
}
if((*filterPos)[i] + filterSize > srcW)
if ((*filterPos)[i] + filterSize > srcW)
{
int shift= (*filterPos)[i] + filterSize - srcW;
// Move filter coeffs right to compensate for filterPos
for(j=filterSize-2; j>=0; j--)
for (j=filterSize-2; j>=0; j--)
{
int right= FFMIN(j + shift, filterSize-1);
filter[i*filterSize +right] += filter[i*filterSize +j];
......@@ -1257,19 +1257,19 @@ static inline int initFilter(int16_t **outFilter, int16_t **filterPos, int *outF
*outFilter= av_mallocz(*outFilterSize*(dstW+1)*sizeof(int16_t));
/* Normalize & Store in outFilter */
for(i=0; i<dstW; i++)
for (i=0; i<dstW; i++)
{
int j;
double error=0;
double sum=0;
double scale= one;
for(j=0; j<filterSize; j++)
for (j=0; j<filterSize; j++)
{
sum+= filter[i*filterSize + j];
}
scale/= sum;
for(j=0; j<*outFilterSize; j++)
for (j=0; j<*outFilterSize; j++)
{
double v= filter[i*filterSize + j]*scale + error;
int intV= floor(v + 0.5);
......@@ -1279,7 +1279,7 @@ static inline int initFilter(int16_t **outFilter, int16_t **filterPos, int *outF
}
(*filterPos)[dstW]= (*filterPos)[dstW-1]; // the MMX scaler will read over the end
for(i=0; i<*outFilterSize; i++)
for (i=0; i<*outFilterSize; i++)
{
int j= dstW*(*outFilterSize);
(*outFilter)[j + i]= (*outFilter)[j + i - (*outFilterSize)];
......@@ -1312,9 +1312,9 @@ static void initMMX2HScaler(int dstW, int xInc, uint8_t *funnyCode, int16_t *fil
"jmp 9f \n\t"
// Begin
"0: \n\t"
"movq (%%"REG_d", %%"REG_a"), %%mm3\n\t"
"movd (%%"REG_c", %%"REG_S"), %%mm0\n\t"
"movd 1(%%"REG_c", %%"REG_S"), %%mm1\n\t"
"movq (%%"REG_d", %%"REG_a"), %%mm3 \n\t"
"movd (%%"REG_c", %%"REG_S"), %%mm0 \n\t"
"movd 1(%%"REG_c", %%"REG_S"), %%mm1 \n\t"
"punpcklbw %%mm7, %%mm1 \n\t"
"punpcklbw %%mm7, %%mm0 \n\t"
"pshufw $0xFF, %%mm1, %%mm1 \n\t"
......@@ -1322,17 +1322,17 @@ static void initMMX2HScaler(int dstW, int xInc, uint8_t *funnyCode, int16_t *fil
"pshufw $0xFF, %%mm0, %%mm0 \n\t"
"2: \n\t"
"psubw %%mm1, %%mm0 \n\t"
"movl 8(%%"REG_b", %%"REG_a"), %%esi\n\t"
"movl 8(%%"REG_b", %%"REG_a"), %%esi \n\t"
"pmullw %%mm3, %%mm0 \n\t"
"psllw $7, %%mm1 \n\t"
"paddw %%mm1, %%mm0 \n\t"
"movq %%mm0, (%%"REG_D", %%"REG_a")\n\t"
"movq %%mm0, (%%"REG_D", %%"REG_a") \n\t"
"add $8, %%"REG_a" \n\t"
// End
"9: \n\t"
// "int $3\n\t"
// "int $3 \n\t"
"lea 0b, %0 \n\t"
"lea 1b, %1 \n\t"
"lea 2b, %2 \n\t"
......@@ -1352,25 +1352,25 @@ static void initMMX2HScaler(int dstW, int xInc, uint8_t *funnyCode, int16_t *fil
"jmp 9f \n\t"
// Begin
"0: \n\t"
"movq (%%"REG_d", %%"REG_a"), %%mm3\n\t"
"movd (%%"REG_c", %%"REG_S"), %%mm0\n\t"
"movq (%%"REG_d", %%"REG_a"), %%mm3 \n\t"
"movd (%%"REG_c", %%"REG_S"), %%mm0 \n\t"
"punpcklbw %%mm7, %%mm0 \n\t"
"pshufw $0xFF, %%mm0, %%mm1 \n\t"
"1: \n\t"
"pshufw $0xFF, %%mm0, %%mm0 \n\t"
"2: \n\t"
"psubw %%mm1, %%mm0 \n\t"
"movl 8(%%"REG_b", %%"REG_a"), %%esi\n\t"
"movl 8(%%"REG_b", %%"REG_a"), %%esi \n\t"
"pmullw %%mm3, %%mm0 \n\t"
"psllw $7, %%mm1 \n\t"
"paddw %%mm1, %%mm0 \n\t"
"movq %%mm0, (%%"REG_D", %%"REG_a")\n\t"
"movq %%mm0, (%%"REG_D", %%"REG_a") \n\t"
"add $8, %%"REG_a" \n\t"
// End
"9: \n\t"
// "int $3\n\t"
// "int $3 \n\t"
"lea 0b, %0 \n\t"
"lea 1b, %1 \n\t"
"lea 2b, %2 \n\t"
......@@ -1389,11 +1389,11 @@ static void initMMX2HScaler(int dstW, int xInc, uint8_t *funnyCode, int16_t *fil
xpos= 0; //lumXInc/2 - 0x8000; // difference between pixel centers
fragmentPos=0;
for(i=0; i<dstW/numSplits; i++)
for (i=0; i<dstW/numSplits; i++)
{
int xx=xpos>>16;
if((i&3) == 0)
if ((i&3) == 0)
{
int a=0;
int b=((xpos+xInc)>>16) - xx;
......@@ -1406,7 +1406,7 @@ static void initMMX2HScaler(int dstW, int xInc, uint8_t *funnyCode, int16_t *fil
filter[i+3] = (((xpos+xInc*3) & 0xFFFF) ^ 0xFFFF)>>9;
filterPos[i/2]= xx;
if(d+1<4)
if (d+1<4)
{
int maxShift= 3-(d+1);
int shift=0;
......@@ -1418,10 +1418,10 @@ static void initMMX2HScaler(int dstW, int xInc, uint8_t *funnyCode, int16_t *fil
funnyCode[fragmentPos + imm8OfPShufW2B]=
a | (b<<2) | (c<<4) | (d<<6);
if(i+3>=dstW) shift=maxShift; //avoid overread
else if((filterPos[i/2]&3) <= maxShift) shift=filterPos[i/2]&3; //Align
if (i+3>=dstW) shift=maxShift; //avoid overread
else if ((filterPos[i/2]&3) <= maxShift) shift=filterPos[i/2]&3; //Align
if(shift && i>=shift)
if (shift && i>=shift)
{
funnyCode[fragmentPos + imm8OfPShufW1B]+= 0x55*shift;
funnyCode[fragmentPos + imm8OfPShufW2B]+= 0x55*shift;
......@@ -1441,10 +1441,10 @@ static void initMMX2HScaler(int dstW, int xInc, uint8_t *funnyCode, int16_t *fil
funnyCode[fragmentPos + imm8OfPShufW2A]=
a | (b<<2) | (c<<4) | (d<<6);
if(i+4>=dstW) shift=maxShift; //avoid overread
else if((filterPos[i/2]&3) <= maxShift) shift=filterPos[i/2]&3; //partial align
if (i+4>=dstW) shift=maxShift; //avoid overread
else if ((filterPos[i/2]&3) <= maxShift) shift=filterPos[i/2]&3; //partial align
if(shift && i>=shift)
if (shift && i>=shift)
{
funnyCode[fragmentPos + imm8OfPShufW1A]+= 0x55*shift;
funnyCode[fragmentPos + imm8OfPShufW2A]+= 0x55*shift;
......@@ -1465,7 +1465,7 @@ static void initMMX2HScaler(int dstW, int xInc, uint8_t *funnyCode, int16_t *fil
static void globalInit(void){
// generating tables:
int i;
for(i=0; i<768; i++){
for (i=0; i<768; i++){
int c= av_clip_uint8(i-256);
clip_table[i]=c;
}
......@@ -1476,18 +1476,18 @@ static SwsFunc getSwsFunc(int flags){
#if defined(RUNTIME_CPUDETECT) && defined (CONFIG_GPL)
#if defined(ARCH_X86)
// ordered per speed fasterst first
if(flags & SWS_CPU_CAPS_MMX2)
if (flags & SWS_CPU_CAPS_MMX2)
return swScale_MMX2;
else if(flags & SWS_CPU_CAPS_3DNOW)
else if (flags & SWS_CPU_CAPS_3DNOW)
return swScale_3DNow;
else if(flags & SWS_CPU_CAPS_MMX)
else if (flags & SWS_CPU_CAPS_MMX)
return swScale_MMX;
else
return swScale_C;
#else
#ifdef ARCH_POWERPC
if(flags & SWS_CPU_CAPS_ALTIVEC)
if (flags & SWS_CPU_CAPS_ALTIVEC)
return swScale_altivec;
else
return swScale_C;
......@@ -1513,14 +1513,14 @@ static int PlanarToNV12Wrapper(SwsContext *c, uint8_t* src[], int srcStride[], i
int srcSliceH, uint8_t* dstParam[], int dstStride[]){
uint8_t *dst=dstParam[0] + dstStride[0]*srcSliceY;
/* Copy Y plane */
if(dstStride[0]==srcStride[0] && srcStride[0] > 0)
if (dstStride[0]==srcStride[0] && srcStride[0] > 0)
memcpy(dst, src[0], srcSliceH*dstStride[0]);
else
{
int i;
uint8_t *srcPtr= src[0];
uint8_t *dstPtr= dst;
for(i=0; i<srcSliceH; i++)
for (i=0; i<srcSliceH; i++)
{
memcpy(dstPtr, srcPtr, c->srcW);
srcPtr+= srcStride[0];
......@@ -1566,7 +1566,7 @@ static int rgb2rgbWrapper(SwsContext *c, uint8_t* src[], int srcStride[], int sr
void (*conv)(const uint8_t *src, uint8_t *dst, long src_size)=NULL;
/* BGR -> BGR */
if( (isBGR(srcFormat) && isBGR(dstFormat))
if ( (isBGR(srcFormat) && isBGR(dstFormat))
|| (isRGB(srcFormat) && isRGB(dstFormat))){
switch(srcId | (dstId<<4)){
case 0x34: conv= rgb16to15; break;
......@@ -1584,7 +1584,7 @@ static int rgb2rgbWrapper(SwsContext *c, uint8_t* src[], int srcStride[], int sr
default: av_log(c, AV_LOG_ERROR, "swScaler: internal error %s -> %s converter\n",
sws_format_name(srcFormat), sws_format_name(dstFormat)); break;
}
}else if( (isBGR(srcFormat) && isRGB(dstFormat))
}else if ( (isBGR(srcFormat) && isRGB(dstFormat))
|| (isRGB(srcFormat) && isBGR(dstFormat))){
switch(srcId | (dstId<<4)){
case 0x33: conv= rgb15tobgr15; break;
......@@ -1611,7 +1611,7 @@ static int rgb2rgbWrapper(SwsContext *c, uint8_t* src[], int srcStride[], int sr
sws_format_name(srcFormat), sws_format_name(dstFormat));
}
if(dstStride[0]*srcBpp == srcStride[0]*dstBpp)
if (dstStride[0]*srcBpp == srcStride[0]*dstBpp)
conv(src[0], dst[0] + dstStride[0]*srcSliceY, srcSliceH*srcStride[0]);
else
{
......@@ -1619,7 +1619,7 @@ static int rgb2rgbWrapper(SwsContext *c, uint8_t* src[], int srcStride[], int sr
uint8_t *srcPtr= src[0];
uint8_t *dstPtr= dst[0] + dstStride[0]*srcSliceY;
for(i=0; i<srcSliceH; i++)
for (i=0; i<srcSliceH; i++)
{
conv(srcPtr, dstPtr, c->srcW*srcBpp);
srcPtr+= srcStride[0];
......@@ -1647,13 +1647,13 @@ static int yvu9toyv12Wrapper(SwsContext *c, uint8_t* src[], int srcStride[], int
int i;
/* copy Y */
if(srcStride[0]==dstStride[0] && srcStride[0] > 0)
if (srcStride[0]==dstStride[0] && srcStride[0] > 0)
memcpy(dst[0]+ srcSliceY*dstStride[0], src[0], srcStride[0]*srcSliceH);
else{
uint8_t *srcPtr= src[0];
uint8_t *dstPtr= dst[0] + dstStride[0]*srcSliceY;
for(i=0; i<srcSliceH; i++)
for (i=0; i<srcSliceH; i++)
{
memcpy(dstPtr, srcPtr, c->srcW);
srcPtr+= srcStride[0];
......@@ -1661,7 +1661,7 @@ static int yvu9toyv12Wrapper(SwsContext *c, uint8_t* src[], int srcStride[], int
}
}
if(c->dstFormat==PIX_FMT_YUV420P){
if (c->dstFormat==PIX_FMT_YUV420P){
planar2x(src[1], dst[1], c->chrSrcW, c->chrSrcH, srcStride[1], dstStride[1]);
planar2x(src[2], dst[2], c->chrSrcW, c->chrSrcH, srcStride[2], dstStride[2]);
}else{
......@@ -1675,9 +1675,9 @@ static int yvu9toyv12Wrapper(SwsContext *c, uint8_t* src[], int srcStride[], int
static int simpleCopy(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,
int srcSliceH, uint8_t* dst[], int dstStride[]){
if(isPacked(c->srcFormat))
if (isPacked(c->srcFormat))
{
if(dstStride[0]==srcStride[0] && srcStride[0] > 0)
if (dstStride[0]==srcStride[0] && srcStride[0] > 0)
memcpy(dst[0] + dstStride[0]*srcSliceY, src[0], srcSliceH*dstStride[0]);
else
{
......@@ -1691,7 +1691,7 @@ static int simpleCopy(SwsContext *c, uint8_t* src[], int srcStride[], int srcSli
&& length+c->srcW <= FFABS(srcStride[0])) length+= c->srcW;
ASSERT(length!=0);
for(i=0; i<srcSliceH; i++)
for (i=0; i<srcSliceH; i++)
{
memcpy(dstPtr, srcPtr, length);
srcPtr+= srcStride[0];
......@@ -1702,27 +1702,27 @@ static int simpleCopy(SwsContext *c, uint8_t* src[], int srcStride[], int srcSli
else
{ /* Planar YUV or gray */
int plane;
for(plane=0; plane<3; plane++)
for (plane=0; plane<3; plane++)
{
int length= plane==0 ? c->srcW : -((-c->srcW )>>c->chrDstHSubSample);
int y= plane==0 ? srcSliceY: -((-srcSliceY)>>c->chrDstVSubSample);
int height= plane==0 ? srcSliceH: -((-srcSliceH)>>c->chrDstVSubSample);
if((isGray(c->srcFormat) || isGray(c->dstFormat)) && plane>0)
if ((isGray(c->srcFormat) || isGray(c->dstFormat)) && plane>0)
{
if(!isGray(c->dstFormat))
if (!isGray(c->dstFormat))
memset(dst[plane], 128, dstStride[plane]*height);
}
else
{
if(dstStride[plane]==srcStride[plane] && srcStride[plane] > 0)
if (dstStride[plane]==srcStride[plane] && srcStride[plane] > 0)
memcpy(dst[plane] + dstStride[plane]*y, src[plane], height*dstStride[plane]);
else
{
int i;
uint8_t *srcPtr= src[plane];
uint8_t *dstPtr= dst[plane] + dstStride[plane]*y;
for(i=0; i<height; i++)
for (i=0; i<height; i++)
{
memcpy(dstPtr, srcPtr, length);
srcPtr+= srcStride[plane];
......@@ -1745,15 +1745,15 @@ static int gray16togray(SwsContext *c, uint8_t* src[], int srcStride[], int srcS
uint8_t *srcPtr= src[0];
uint8_t *dstPtr= dst[0] + dstStride[0]*y;
if(!isGray(c->dstFormat)){
if (!isGray(c->dstFormat)){
int height= -((-srcSliceH)>>c->chrDstVSubSample);
memset(dst[1], 128, dstStride[1]*height);
memset(dst[2], 128, dstStride[2]*height);
}
if(c->srcFormat == PIX_FMT_GRAY16LE) srcPtr++;
for(i=0; i<height; i++)
if (c->srcFormat == PIX_FMT_GRAY16LE) srcPtr++;
for (i=0; i<height; i++)
{
for(j=0; j<length; j++) dstPtr[j] = srcPtr[j<<1];
for (j=0; j<length; j++) dstPtr[j] = srcPtr[j<<1];
srcPtr+= srcStride[0];
dstPtr+= dstStride[0];
}
......@@ -1769,9 +1769,9 @@ static int graytogray16(SwsContext *c, uint8_t* src[], int srcStride[], int srcS
int i, j;
uint8_t *srcPtr= src[0];
uint8_t *dstPtr= dst[0] + dstStride[0]*y;
for(i=0; i<height; i++)
for (i=0; i<height; i++)
{
for(j=0; j<length; j++)
for (j=0; j<length; j++)
{
dstPtr[j<<1] = srcPtr[j];
dstPtr[(j<<1)+1] = srcPtr[j];
......@@ -1791,9 +1791,9 @@ static int gray16swap(SwsContext *c, uint8_t* src[], int srcStride[], int srcSli
int i, j;
uint16_t *srcPtr= src[0];
uint16_t *dstPtr= dst[0] + dstStride[0]*y/2;
for(i=0; i<height; i++)
for (i=0; i<height; i++)
{
for(j=0; j<length; j++) dstPtr[j] = bswap_16(srcPtr[j]);
for (j=0; j<length; j++) dstPtr[j] = bswap_16(srcPtr[j]);
srcPtr+= srcStride[0]/2;
dstPtr+= dstStride[0]/2;
}
......@@ -1842,8 +1842,8 @@ static void getSubSampleFactors(int *h, int *v, int format){
static uint16_t roundToInt16(int64_t f){
int r= (f + (1<<15))>>16;
if(r<-0x7FFF) return 0x8000;
else if(r> 0x7FFF) return 0x7FFF;
if (r<-0x7FFF) return 0x8000;
else if (r> 0x7FFF) return 0x7FFF;
else return r;
}
......@@ -1860,7 +1860,7 @@ int sws_setColorspaceDetails(SwsContext *c, const int inv_table[4], int srcRange
int64_t cy = 1<<16;
int64_t oy = 0;
if(isYUV(c->dstFormat) || isGray(c->dstFormat)) return -1;
if (isYUV(c->dstFormat) || isGray(c->dstFormat)) return -1;
memcpy(c->srcColorspaceTable, inv_table, sizeof(int)*4);
memcpy(c->dstColorspaceTable, table, sizeof(int)*4);
......@@ -1873,7 +1873,7 @@ int sws_setColorspaceDetails(SwsContext *c, const int inv_table[4], int srcRange
c->uOffset= 0x0400040004000400LL;
c->vOffset= 0x0400040004000400LL;
if(!srcRange){
if (!srcRange){
cy= (cy*255) / 219;
oy= 16<<16;
}else{
......@@ -1912,7 +1912,7 @@ int sws_setColorspaceDetails(SwsContext *c, const int inv_table[4], int srcRange
* @return -1 if not supported
*/
int sws_getColorspaceDetails(SwsContext *c, int **inv_table, int *srcRange, int **table, int *dstRange, int *brightness, int *contrast, int *saturation){
if(isYUV(c->dstFormat) || isGray(c->dstFormat)) return -1;
if (isYUV(c->dstFormat) || isGray(c->dstFormat)) return -1;
*inv_table = c->srcColorspaceTable;
*table = c->dstColorspaceTable;
......@@ -1952,7 +1952,7 @@ SwsContext *sws_getContext(int srcW, int srcH, int srcFormat, int dstW, int dstH
int srcRange, dstRange;
SwsFilter dummyFilter= {NULL, NULL, NULL, NULL};
#if defined(ARCH_X86)
if(flags & SWS_CPU_CAPS_MMX)
if (flags & SWS_CPU_CAPS_MMX)
asm volatile("emms\n\t"::: "memory");
#endif
......@@ -1968,8 +1968,8 @@ SwsContext *sws_getContext(int srcW, int srcH, int srcFormat, int dstW, int dstH
flags |= SWS_CPU_CAPS_ALTIVEC;
#endif
#endif /* RUNTIME_CPUDETECT */
if(clip_table[512] != 255) globalInit();
if(rgb15to16 == NULL) sws_rgb2rgb_init(flags);
if (clip_table[512] != 255) globalInit();
if (rgb15to16 == NULL) sws_rgb2rgb_init(flags);
unscaled = (srcW == dstW && srcH == dstH);
needsDither= (isBGR(dstFormat) || isRGB(dstFormat))
......@@ -1979,27 +1979,27 @@ SwsContext *sws_getContext(int srcW, int srcH, int srcFormat, int dstW, int dstH
srcRange = handle_jpeg(&srcFormat);
dstRange = handle_jpeg(&dstFormat);
if(!isSupportedIn(srcFormat))
if (!isSupportedIn(srcFormat))
{
av_log(NULL, AV_LOG_ERROR, "swScaler: %s is not supported as input format\n", sws_format_name(srcFormat));
return NULL;
}
if(!isSupportedOut(dstFormat))
if (!isSupportedOut(dstFormat))
{
av_log(NULL, AV_LOG_ERROR, "swScaler: %s is not supported as output format\n", sws_format_name(dstFormat));
return NULL;
}
/* sanity check */
if(srcW<4 || srcH<1 || dstW<8 || dstH<1) //FIXME check if these are enough and try to lowwer them after fixing the relevant parts of the code
if (srcW<4 || srcH<1 || dstW<8 || dstH<1) //FIXME check if these are enough and try to lowwer them after fixing the relevant parts of the code
{
av_log(NULL, AV_LOG_ERROR, "swScaler: %dx%d -> %dx%d is invalid scaling dimension\n",
srcW, srcH, dstW, dstH);
return NULL;
}
if(!dstFilter) dstFilter= &dummyFilter;
if(!srcFilter) srcFilter= &dummyFilter;
if (!dstFilter) dstFilter= &dummyFilter;
if (!srcFilter) srcFilter= &dummyFilter;
c= av_mallocz(sizeof(SwsContext));
......@@ -2016,33 +2016,33 @@ SwsContext *sws_getContext(int srcW, int srcH, int srcFormat, int dstW, int dstH
c->vRounder= 4* 0x0001000100010001ULL;
usesHFilter= usesVFilter= 0;
if(dstFilter->lumV!=NULL && dstFilter->lumV->length>1) usesVFilter=1;
if(dstFilter->lumH!=NULL && dstFilter->lumH->length>1) usesHFilter=1;
if(dstFilter->chrV!=NULL && dstFilter->chrV->length>1) usesVFilter=1;
if(dstFilter->chrH!=NULL && dstFilter->chrH->length>1) usesHFilter=1;
if(srcFilter->lumV!=NULL && srcFilter->lumV->length>1) usesVFilter=1;
if(srcFilter->lumH!=NULL && srcFilter->lumH->length>1) usesHFilter=1;
if(srcFilter->chrV!=NULL && srcFilter->chrV->length>1) usesVFilter=1;
if(srcFilter->chrH!=NULL && srcFilter->chrH->length>1) usesHFilter=1;
if (dstFilter->lumV!=NULL && dstFilter->lumV->length>1) usesVFilter=1;
if (dstFilter->lumH!=NULL && dstFilter->lumH->length>1) usesHFilter=1;
if (dstFilter->chrV!=NULL && dstFilter->chrV->length>1) usesVFilter=1;
if (dstFilter->chrH!=NULL && dstFilter->chrH->length>1) usesHFilter=1;
if (srcFilter->lumV!=NULL && srcFilter->lumV->length>1) usesVFilter=1;
if (srcFilter->lumH!=NULL && srcFilter->lumH->length>1) usesHFilter=1;
if (srcFilter->chrV!=NULL && srcFilter->chrV->length>1) usesVFilter=1;
if (srcFilter->chrH!=NULL && srcFilter->chrH->length>1) usesHFilter=1;
getSubSampleFactors(&c->chrSrcHSubSample, &c->chrSrcVSubSample, srcFormat);
getSubSampleFactors(&c->chrDstHSubSample, &c->chrDstVSubSample, dstFormat);
// reuse chroma for 2 pixles rgb/bgr unless user wants full chroma interpolation
if((isBGR(dstFormat) || isRGB(dstFormat)) && !(flags&SWS_FULL_CHR_H_INT)) c->chrDstHSubSample=1;
if ((isBGR(dstFormat) || isRGB(dstFormat)) && !(flags&SWS_FULL_CHR_H_INT)) c->chrDstHSubSample=1;
// drop some chroma lines if the user wants it
c->vChrDrop= (flags&SWS_SRC_V_CHR_DROP_MASK)>>SWS_SRC_V_CHR_DROP_SHIFT;
c->chrSrcVSubSample+= c->vChrDrop;
// drop every 2. pixel for chroma calculation unless user wants full chroma
if((isBGR(srcFormat) || isRGB(srcFormat)) && !(flags&SWS_FULL_CHR_H_INP)
if ((isBGR(srcFormat) || isRGB(srcFormat)) && !(flags&SWS_FULL_CHR_H_INP)
&& srcFormat!=PIX_FMT_RGB8 && srcFormat!=PIX_FMT_BGR8
&& srcFormat!=PIX_FMT_RGB4 && srcFormat!=PIX_FMT_BGR4
&& srcFormat!=PIX_FMT_RGB4_BYTE && srcFormat!=PIX_FMT_BGR4_BYTE)
c->chrSrcHSubSample=1;
if(param){
if (param){
c->param[0] = param[0];
c->param[1] = param[1];
}else{
......@@ -2062,32 +2062,32 @@ SwsContext *sws_getContext(int srcW, int srcH, int srcFormat, int dstW, int dstH
sws_setColorspaceDetails(c, Inverse_Table_6_9[SWS_CS_DEFAULT], srcRange, Inverse_Table_6_9[SWS_CS_DEFAULT] /* FIXME*/, dstRange, 0, 1<<16, 1<<16);
/* unscaled special Cases */
if(unscaled && !usesHFilter && !usesVFilter)
if (unscaled && !usesHFilter && !usesVFilter)
{
/* yv12_to_nv12 */
if(srcFormat == PIX_FMT_YUV420P && (dstFormat == PIX_FMT_NV12 || dstFormat == PIX_FMT_NV21))
if (srcFormat == PIX_FMT_YUV420P && (dstFormat == PIX_FMT_NV12 || dstFormat == PIX_FMT_NV21))
{
c->swScale= PlanarToNV12Wrapper;
}
#ifdef CONFIG_GPL
/* yuv2bgr */
if((srcFormat==PIX_FMT_YUV420P || srcFormat==PIX_FMT_YUV422P) && (isBGR(dstFormat) || isRGB(dstFormat)))
if ((srcFormat==PIX_FMT_YUV420P || srcFormat==PIX_FMT_YUV422P) && (isBGR(dstFormat) || isRGB(dstFormat)))
{
c->swScale= yuv2rgb_get_func_ptr(c);
}
#endif
if( srcFormat==PIX_FMT_YUV410P && dstFormat==PIX_FMT_YUV420P )
if ( srcFormat==PIX_FMT_YUV410P && dstFormat==PIX_FMT_YUV420P )
{
c->swScale= yvu9toyv12Wrapper;
}
/* bgr24toYV12 */
if(srcFormat==PIX_FMT_BGR24 && dstFormat==PIX_FMT_YUV420P)
if (srcFormat==PIX_FMT_BGR24 && dstFormat==PIX_FMT_YUV420P)
c->swScale= bgr24toyv12Wrapper;
/* rgb/bgr -> rgb/bgr (no dither needed forms) */
if( (isBGR(srcFormat) || isRGB(srcFormat))
if ( (isBGR(srcFormat) || isRGB(srcFormat))
&& (isBGR(dstFormat) || isRGB(dstFormat))
&& srcFormat != PIX_FMT_BGR8 && dstFormat != PIX_FMT_BGR8
&& srcFormat != PIX_FMT_RGB8 && dstFormat != PIX_FMT_RGB8
......@@ -2100,15 +2100,15 @@ SwsContext *sws_getContext(int srcW, int srcH, int srcFormat, int dstW, int dstH
c->swScale= rgb2rgbWrapper;
/* LQ converters if -sws 0 or -sws 4*/
if(c->flags&(SWS_FAST_BILINEAR|SWS_POINT)){
if (c->flags&(SWS_FAST_BILINEAR|SWS_POINT)){
/* rgb/bgr -> rgb/bgr (dither needed forms) */
if( (isBGR(srcFormat) || isRGB(srcFormat))
if ( (isBGR(srcFormat) || isRGB(srcFormat))
&& (isBGR(dstFormat) || isRGB(dstFormat))
&& needsDither)
c->swScale= rgb2rgbWrapper;
/* yv12_to_yuy2 */
if(srcFormat == PIX_FMT_YUV420P &&
if (srcFormat == PIX_FMT_YUV420P &&
(dstFormat == PIX_FMT_YUYV422 || dstFormat == PIX_FMT_UYVY422))
{
if (dstFormat == PIX_FMT_YUYV422)
......@@ -2131,45 +2131,44 @@ SwsContext *sws_getContext(int srcW, int srcH, int srcFormat, int dstW, int dstH
#endif
/* simple copy */
if( srcFormat == dstFormat
if ( srcFormat == dstFormat
|| (isPlanarYUV(srcFormat) && isGray(dstFormat))
|| (isPlanarYUV(dstFormat) && isGray(srcFormat))
)
|| (isPlanarYUV(dstFormat) && isGray(srcFormat)) )
{
c->swScale= simpleCopy;
}
/* gray16{le,be} conversions */
if(isGray16(srcFormat) && (isPlanarYUV(dstFormat) || (dstFormat == PIX_FMT_GRAY8)))
if (isGray16(srcFormat) && (isPlanarYUV(dstFormat) || (dstFormat == PIX_FMT_GRAY8)))
{
c->swScale= gray16togray;
}
if((isPlanarYUV(srcFormat) || (srcFormat == PIX_FMT_GRAY8)) && isGray16(dstFormat))
if ((isPlanarYUV(srcFormat) || (srcFormat == PIX_FMT_GRAY8)) && isGray16(dstFormat))
{
c->swScale= graytogray16;
}
if(srcFormat != dstFormat && isGray16(srcFormat) && isGray16(dstFormat))
if (srcFormat != dstFormat && isGray16(srcFormat) && isGray16(dstFormat))
{
c->swScale= gray16swap;
}
if(c->swScale){
if(flags&SWS_PRINT_INFO)
if (c->swScale){
if (flags&SWS_PRINT_INFO)
av_log(c, AV_LOG_INFO, "SwScaler: using unscaled %s -> %s special converter\n",
sws_format_name(srcFormat), sws_format_name(dstFormat));
return c;
}
}
if(flags & SWS_CPU_CAPS_MMX2)
if (flags & SWS_CPU_CAPS_MMX2)
{
c->canMMX2BeUsed= (dstW >=srcW && (dstW&31)==0 && (srcW&15)==0) ? 1 : 0;
if(!c->canMMX2BeUsed && dstW >=srcW && (srcW&15)==0 && (flags&SWS_FAST_BILINEAR))
if (!c->canMMX2BeUsed && dstW >=srcW && (srcW&15)==0 && (flags&SWS_FAST_BILINEAR))
{
if(flags&SWS_PRINT_INFO)
if (flags&SWS_PRINT_INFO)
av_log(c, AV_LOG_INFO, "SwScaler: output Width is not a multiple of 32 -> no MMX2 scaler\n");
}
if(usesHFilter) c->canMMX2BeUsed=0;
if (usesHFilter) c->canMMX2BeUsed=0;
}
else
c->canMMX2BeUsed=0;
......@@ -2183,15 +2182,15 @@ SwsContext *sws_getContext(int srcW, int srcH, int srcFormat, int dstW, int dstH
// this is not perfect, but noone shuld notice the difference, the more correct variant
// would be like the vertical one, but that would require some special code for the
// first and last pixel
if(flags&SWS_FAST_BILINEAR)
if (flags&SWS_FAST_BILINEAR)
{
if(c->canMMX2BeUsed)
if (c->canMMX2BeUsed)
{
c->lumXInc+= 20;
c->chrXInc+= 20;
}
//we don't use the x86asm scaler if mmx is available
else if(flags & SWS_CPU_CAPS_MMX)
else if (flags & SWS_CPU_CAPS_MMX)
{
c->lumXInc = ((srcW-2)<<16)/(dstW-2) - 20;
c->chrXInc = ((c->chrSrcW-2)<<16)/(c->chrDstW-2) - 20;
......@@ -2217,7 +2216,7 @@ SwsContext *sws_getContext(int srcW, int srcH, int srcFormat, int dstW, int dstH
#define MAX_FUNNY_CODE_SIZE 10000
#if defined(COMPILE_MMX2)
// can't downscale !!!
if(c->canMMX2BeUsed && (flags & SWS_FAST_BILINEAR))
if (c->canMMX2BeUsed && (flags & SWS_FAST_BILINEAR))
{
#ifdef MAP_ANONYMOUS
c->funnyYCode = (uint8_t*)mmap(NULL, MAX_FUNNY_CODE_SIZE, PROT_EXEC | PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
......@@ -2279,7 +2278,7 @@ SwsContext *sws_getContext(int srcW, int srcH, int srcFormat, int dstW, int dstH
// Calculate Buffer Sizes so that they won't run out while handling these damn slices
c->vLumBufSize= c->vLumFilterSize;
c->vChrBufSize= c->vChrFilterSize;
for(i=0; i<dstH; i++)
for (i=0; i<dstH; i++)
{
int chrI= i*c->chrDstH / dstH;
int nextSlice= FFMAX(c->vLumFilterPos[i ] + c->vLumFilterSize - 1,
......@@ -2287,9 +2286,9 @@ SwsContext *sws_getContext(int srcW, int srcH, int srcFormat, int dstW, int dstH
nextSlice>>= c->chrSrcVSubSample;
nextSlice<<= c->chrSrcVSubSample;
if(c->vLumFilterPos[i ] + c->vLumBufSize < nextSlice)
if (c->vLumFilterPos[i ] + c->vLumBufSize < nextSlice)
c->vLumBufSize= nextSlice - c->vLumFilterPos[i ];
if(c->vChrFilterPos[chrI] + c->vChrBufSize < (nextSlice>>c->chrSrcVSubSample))
if (c->vChrFilterPos[chrI] + c->vChrBufSize < (nextSlice>>c->chrSrcVSubSample))
c->vChrBufSize= (nextSlice>>c->chrSrcVSubSample) - c->vChrFilterPos[chrI];
}
......@@ -2298,85 +2297,85 @@ SwsContext *sws_getContext(int srcW, int srcH, int srcFormat, int dstW, int dstH
c->chrPixBuf= av_malloc(c->vChrBufSize*2*sizeof(int16_t*));
//Note we need at least one pixel more at the end because of the mmx code (just in case someone wanna replace the 4000/8000)
/* align at 16 bytes for AltiVec */
for(i=0; i<c->vLumBufSize; i++)
for (i=0; i<c->vLumBufSize; i++)
c->lumPixBuf[i]= c->lumPixBuf[i+c->vLumBufSize]= av_mallocz(4000);
for(i=0; i<c->vChrBufSize; i++)
for (i=0; i<c->vChrBufSize; i++)
c->chrPixBuf[i]= c->chrPixBuf[i+c->vChrBufSize]= av_malloc(8000);
//try to avoid drawing green stuff between the right end and the stride end
for(i=0; i<c->vChrBufSize; i++) memset(c->chrPixBuf[i], 64, 8000);
for (i=0; i<c->vChrBufSize; i++) memset(c->chrPixBuf[i], 64, 8000);
ASSERT(c->chrDstH <= dstH)
if(flags&SWS_PRINT_INFO)
if (flags&SWS_PRINT_INFO)
{
#ifdef DITHER1XBPP
char *dither= " dithered";
#else
char *dither= "";
#endif
if(flags&SWS_FAST_BILINEAR)
if (flags&SWS_FAST_BILINEAR)
av_log(c, AV_LOG_INFO, "SwScaler: FAST_BILINEAR scaler, ");
else if(flags&SWS_BILINEAR)
else if (flags&SWS_BILINEAR)
av_log(c, AV_LOG_INFO, "SwScaler: BILINEAR scaler, ");
else if(flags&SWS_BICUBIC)
else if (flags&SWS_BICUBIC)
av_log(c, AV_LOG_INFO, "SwScaler: BICUBIC scaler, ");
else if(flags&SWS_X)
else if (flags&SWS_X)
av_log(c, AV_LOG_INFO, "SwScaler: Experimental scaler, ");
else if(flags&SWS_POINT)
else if (flags&SWS_POINT)
av_log(c, AV_LOG_INFO, "SwScaler: Nearest Neighbor / POINT scaler, ");
else if(flags&SWS_AREA)
else if (flags&SWS_AREA)
av_log(c, AV_LOG_INFO, "SwScaler: Area Averageing scaler, ");
else if(flags&SWS_BICUBLIN)
else if (flags&SWS_BICUBLIN)
av_log(c, AV_LOG_INFO, "SwScaler: luma BICUBIC / chroma BILINEAR scaler, ");
else if(flags&SWS_GAUSS)
else if (flags&SWS_GAUSS)
av_log(c, AV_LOG_INFO, "SwScaler: Gaussian scaler, ");
else if(flags&SWS_SINC)
else if (flags&SWS_SINC)
av_log(c, AV_LOG_INFO, "SwScaler: Sinc scaler, ");
else if(flags&SWS_LANCZOS)
else if (flags&SWS_LANCZOS)
av_log(c, AV_LOG_INFO, "SwScaler: Lanczos scaler, ");
else if(flags&SWS_SPLINE)
else if (flags&SWS_SPLINE)
av_log(c, AV_LOG_INFO, "SwScaler: Bicubic spline scaler, ");
else
av_log(c, AV_LOG_INFO, "SwScaler: ehh flags invalid?! ");
if(dstFormat==PIX_FMT_BGR555 || dstFormat==PIX_FMT_BGR565)
if (dstFormat==PIX_FMT_BGR555 || dstFormat==PIX_FMT_BGR565)
av_log(c, AV_LOG_INFO, "from %s to%s %s ",
sws_format_name(srcFormat), dither, sws_format_name(dstFormat));
else
av_log(c, AV_LOG_INFO, "from %s to %s ",
sws_format_name(srcFormat), sws_format_name(dstFormat));
if(flags & SWS_CPU_CAPS_MMX2)
if (flags & SWS_CPU_CAPS_MMX2)
av_log(c, AV_LOG_INFO, "using MMX2\n");
else if(flags & SWS_CPU_CAPS_3DNOW)
else if (flags & SWS_CPU_CAPS_3DNOW)
av_log(c, AV_LOG_INFO, "using 3DNOW\n");
else if(flags & SWS_CPU_CAPS_MMX)
else if (flags & SWS_CPU_CAPS_MMX)
av_log(c, AV_LOG_INFO, "using MMX\n");
else if(flags & SWS_CPU_CAPS_ALTIVEC)
else if (flags & SWS_CPU_CAPS_ALTIVEC)
av_log(c, AV_LOG_INFO, "using AltiVec\n");
else
av_log(c, AV_LOG_INFO, "using C\n");
}
if(flags & SWS_PRINT_INFO)
if (flags & SWS_PRINT_INFO)
{
if(flags & SWS_CPU_CAPS_MMX)
if (flags & SWS_CPU_CAPS_MMX)
{
if(c->canMMX2BeUsed && (flags&SWS_FAST_BILINEAR))
if (c->canMMX2BeUsed && (flags&SWS_FAST_BILINEAR))
av_log(c, AV_LOG_VERBOSE, "SwScaler: using FAST_BILINEAR MMX2 scaler for horizontal scaling\n");
else
{
if(c->hLumFilterSize==4)
if (c->hLumFilterSize==4)
av_log(c, AV_LOG_VERBOSE, "SwScaler: using 4-tap MMX scaler for horizontal luminance scaling\n");
else if(c->hLumFilterSize==8)
else if (c->hLumFilterSize==8)
av_log(c, AV_LOG_VERBOSE, "SwScaler: using 8-tap MMX scaler for horizontal luminance scaling\n");
else
av_log(c, AV_LOG_VERBOSE, "SwScaler: using n-tap MMX scaler for horizontal luminance scaling\n");
if(c->hChrFilterSize==4)
if (c->hChrFilterSize==4)
av_log(c, AV_LOG_VERBOSE, "SwScaler: using 4-tap MMX scaler for horizontal chrominance scaling\n");
else if(c->hChrFilterSize==8)
else if (c->hChrFilterSize==8)
av_log(c, AV_LOG_VERBOSE, "SwScaler: using 8-tap MMX scaler for horizontal chrominance scaling\n");
else
av_log(c, AV_LOG_VERBOSE, "SwScaler: using n-tap MMX scaler for horizontal chrominance scaling\n");
......@@ -2387,43 +2386,43 @@ SwsContext *sws_getContext(int srcW, int srcH, int srcFormat, int dstW, int dstH
#if defined(ARCH_X86)
av_log(c, AV_LOG_VERBOSE, "SwScaler: using X86-Asm scaler for horizontal scaling\n");
#else
if(flags & SWS_FAST_BILINEAR)
if (flags & SWS_FAST_BILINEAR)
av_log(c, AV_LOG_VERBOSE, "SwScaler: using FAST_BILINEAR C scaler for horizontal scaling\n");
else
av_log(c, AV_LOG_VERBOSE, "SwScaler: using C scaler for horizontal scaling\n");
#endif
}
if(isPlanarYUV(dstFormat))
if (isPlanarYUV(dstFormat))
{
if(c->vLumFilterSize==1)
if (c->vLumFilterSize==1)
av_log(c, AV_LOG_VERBOSE, "SwScaler: using 1-tap %s \"scaler\" for vertical scaling (YV12 like)\n", (flags & SWS_CPU_CAPS_MMX) ? "MMX" : "C");
else
av_log(c, AV_LOG_VERBOSE, "SwScaler: using n-tap %s scaler for vertical scaling (YV12 like)\n", (flags & SWS_CPU_CAPS_MMX) ? "MMX" : "C");
}
else
{
if(c->vLumFilterSize==1 && c->vChrFilterSize==2)
if (c->vLumFilterSize==1 && c->vChrFilterSize==2)
av_log(c, AV_LOG_VERBOSE, "SwScaler: using 1-tap %s \"scaler\" for vertical luminance scaling (BGR)\n"
"SwScaler: 2-tap scaler for vertical chrominance scaling (BGR)\n",(flags & SWS_CPU_CAPS_MMX) ? "MMX" : "C");
else if(c->vLumFilterSize==2 && c->vChrFilterSize==2)
else if (c->vLumFilterSize==2 && c->vChrFilterSize==2)
av_log(c, AV_LOG_VERBOSE, "SwScaler: using 2-tap linear %s scaler for vertical scaling (BGR)\n", (flags & SWS_CPU_CAPS_MMX) ? "MMX" : "C");
else
av_log(c, AV_LOG_VERBOSE, "SwScaler: using n-tap %s scaler for vertical scaling (BGR)\n", (flags & SWS_CPU_CAPS_MMX) ? "MMX" : "C");
}
if(dstFormat==PIX_FMT_BGR24)
if (dstFormat==PIX_FMT_BGR24)
av_log(c, AV_LOG_VERBOSE, "SwScaler: using %s YV12->BGR24 Converter\n",
(flags & SWS_CPU_CAPS_MMX2) ? "MMX2" : ((flags & SWS_CPU_CAPS_MMX) ? "MMX" : "C"));
else if(dstFormat==PIX_FMT_RGB32)
else if (dstFormat==PIX_FMT_RGB32)
av_log(c, AV_LOG_VERBOSE, "SwScaler: using %s YV12->BGR32 Converter\n", (flags & SWS_CPU_CAPS_MMX) ? "MMX" : "C");
else if(dstFormat==PIX_FMT_BGR565)
else if (dstFormat==PIX_FMT_BGR565)
av_log(c, AV_LOG_VERBOSE, "SwScaler: using %s YV12->BGR16 Converter\n", (flags & SWS_CPU_CAPS_MMX) ? "MMX" : "C");
else if(dstFormat==PIX_FMT_BGR555)
else if (dstFormat==PIX_FMT_BGR555)
av_log(c, AV_LOG_VERBOSE, "SwScaler: using %s YV12->BGR15 Converter\n", (flags & SWS_CPU_CAPS_MMX) ? "MMX" : "C");
av_log(c, AV_LOG_VERBOSE, "SwScaler: %dx%d -> %dx%d\n", srcW, srcH, dstW, dstH);
}
if(flags & SWS_PRINT_INFO)
if (flags & SWS_PRINT_INFO)
{
av_log(c, AV_LOG_DEBUG, "SwScaler:Lum srcW=%d srcH=%d dstW=%d dstH=%d xInc=%d yInc=%d\n",
c->srcW, c->srcH, c->dstW, c->dstH, c->lumXInc, c->lumYInc);
......@@ -2452,8 +2451,8 @@ int sws_scale(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,
if (srcSliceY == 0) c->sliceDir = 1; else c->sliceDir = -1;
}
if(c->srcFormat == PIX_FMT_PAL8){
for(i=0; i<256; i++){
if (c->srcFormat == PIX_FMT_PAL8){
for (i=0; i<256; i++){
int p= ((uint32_t*)(src[1]))[i];
int r= (p>>16)&0xFF;
int g= (p>> 8)&0xFF;
......@@ -2481,7 +2480,7 @@ int sws_scale(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,
int dstStride2[4]= {-dstStride[0], -dstStride[1], -dstStride[2]};
src2[0] += (srcSliceH-1)*srcStride[0];
if(c->srcFormat != PIX_FMT_PAL8)
if (c->srcFormat != PIX_FMT_PAL8)
src2[1] += ((srcSliceH>>c->chrSrcVSubSample)-1)*srcStride[1];
src2[2] += ((srcSliceH>>c->chrSrcVSubSample)-1)*srcStride[2];
......@@ -2504,7 +2503,7 @@ SwsFilter *sws_getDefaultFilter(float lumaGBlur, float chromaGBlur,
{
SwsFilter *filter= av_malloc(sizeof(SwsFilter));
if(lumaGBlur!=0.0){
if (lumaGBlur!=0.0){
filter->lumH= sws_getGaussianVec(lumaGBlur, 3.0);
filter->lumV= sws_getGaussianVec(lumaGBlur, 3.0);
}else{
......@@ -2512,7 +2511,7 @@ SwsFilter *sws_getDefaultFilter(float lumaGBlur, float chromaGBlur,
filter->lumV= sws_getIdentityVec();
}
if(chromaGBlur!=0.0){
if (chromaGBlur!=0.0){
filter->chrH= sws_getGaussianVec(chromaGBlur, 3.0);
filter->chrV= sws_getGaussianVec(chromaGBlur, 3.0);
}else{
......@@ -2520,7 +2519,7 @@ SwsFilter *sws_getDefaultFilter(float lumaGBlur, float chromaGBlur,
filter->chrV= sws_getIdentityVec();
}
if(chromaSharpen!=0.0){
if (chromaSharpen!=0.0){
SwsVector *id= sws_getIdentityVec();
sws_scaleVec(filter->chrH, -chromaSharpen);
sws_scaleVec(filter->chrV, -chromaSharpen);
......@@ -2529,7 +2528,7 @@ SwsFilter *sws_getDefaultFilter(float lumaGBlur, float chromaGBlur,
sws_freeVec(id);
}
if(lumaSharpen!=0.0){
if (lumaSharpen!=0.0){
SwsVector *id= sws_getIdentityVec();
sws_scaleVec(filter->lumH, -lumaSharpen);
sws_scaleVec(filter->lumV, -lumaSharpen);
......@@ -2538,10 +2537,10 @@ SwsFilter *sws_getDefaultFilter(float lumaGBlur, float chromaGBlur,
sws_freeVec(id);
}
if(chromaHShift != 0.0)
if (chromaHShift != 0.0)
sws_shiftVec(filter->chrH, (int)(chromaHShift+0.5));
if(chromaVShift != 0.0)
if (chromaVShift != 0.0)
sws_shiftVec(filter->chrV, (int)(chromaVShift+0.5));
sws_normalizeVec(filter->chrH, 1.0);
......@@ -2549,8 +2548,8 @@ SwsFilter *sws_getDefaultFilter(float lumaGBlur, float chromaGBlur,
sws_normalizeVec(filter->lumH, 1.0);
sws_normalizeVec(filter->lumV, 1.0);
if(verbose) sws_printVec(filter->chrH);
if(verbose) sws_printVec(filter->lumH);
if (verbose) sws_printVec(filter->chrH);
if (verbose) sws_printVec(filter->lumH);
return filter;
}
......@@ -2569,7 +2568,7 @@ SwsVector *sws_getGaussianVec(double variance, double quality){
vec->coeff= coeff;
vec->length= length;
for(i=0; i<length; i++)
for (i=0; i<length; i++)
{
double dist= i-middle;
coeff[i]= exp( -dist*dist/(2*variance*variance) ) / sqrt(2*variance*PI);
......@@ -2588,7 +2587,7 @@ SwsVector *sws_getConstVec(double c, int length){
vec->coeff= coeff;
vec->length= length;
for(i=0; i<length; i++)
for (i=0; i<length; i++)
coeff[i]= c;
return vec;
......@@ -2603,7 +2602,7 @@ double sws_dcVec(SwsVector *a){
int i;
double sum=0;
for(i=0; i<a->length; i++)
for (i=0; i<a->length; i++)
sum+= a->coeff[i];
return sum;
......@@ -2612,7 +2611,7 @@ double sws_dcVec(SwsVector *a){
void sws_scaleVec(SwsVector *a, double scalar){
int i;
for(i=0; i<a->length; i++)
for (i=0; i<a->length; i++)
a->coeff[i]*= scalar;
}
......@@ -2629,11 +2628,11 @@ static SwsVector *sws_getConvVec(SwsVector *a, SwsVector *b){
vec->coeff= coeff;
vec->length= length;
for(i=0; i<length; i++) coeff[i]= 0.0;
for (i=0; i<length; i++) coeff[i]= 0.0;
for(i=0; i<a->length; i++)
for (i=0; i<a->length; i++)
{
for(j=0; j<b->length; j++)
for (j=0; j<b->length; j++)
{
coeff[i+j]+= a->coeff[i]*b->coeff[j];
}
......@@ -2651,10 +2650,10 @@ static SwsVector *sws_sumVec(SwsVector *a, SwsVector *b){
vec->coeff= coeff;
vec->length= length;
for(i=0; i<length; i++) coeff[i]= 0.0;
for (i=0; i<length; i++) coeff[i]= 0.0;
for(i=0; i<a->length; i++) coeff[i + (length-1)/2 - (a->length-1)/2]+= a->coeff[i];
for(i=0; i<b->length; i++) coeff[i + (length-1)/2 - (b->length-1)/2]+= b->coeff[i];
for (i=0; i<a->length; i++) coeff[i + (length-1)/2 - (a->length-1)/2]+= a->coeff[i];
for (i=0; i<b->length; i++) coeff[i + (length-1)/2 - (b->length-1)/2]+= b->coeff[i];
return vec;
}
......@@ -2668,10 +2667,10 @@ static SwsVector *sws_diffVec(SwsVector *a, SwsVector *b){
vec->coeff= coeff;
vec->length= length;
for(i=0; i<length; i++) coeff[i]= 0.0;
for (i=0; i<length; i++) coeff[i]= 0.0;
for(i=0; i<a->length; i++) coeff[i + (length-1)/2 - (a->length-1)/2]+= a->coeff[i];
for(i=0; i<b->length; i++) coeff[i + (length-1)/2 - (b->length-1)/2]-= b->coeff[i];
for (i=0; i<a->length; i++) coeff[i + (length-1)/2 - (a->length-1)/2]+= a->coeff[i];
for (i=0; i<b->length; i++) coeff[i + (length-1)/2 - (b->length-1)/2]-= b->coeff[i];
return vec;
}
......@@ -2686,9 +2685,9 @@ static SwsVector *sws_getShiftedVec(SwsVector *a, int shift){
vec->coeff= coeff;
vec->length= length;
for(i=0; i<length; i++) coeff[i]= 0.0;
for (i=0; i<length; i++) coeff[i]= 0.0;
for(i=0; i<a->length; i++)
for (i=0; i<a->length; i++)
{
coeff[i + (length-1)/2 - (a->length-1)/2 - shift]= a->coeff[i];
}
......@@ -2736,7 +2735,7 @@ SwsVector *sws_cloneVec(SwsVector *a){
vec->coeff= coeff;
vec->length= a->length;
for(i=0; i<a->length; i++) coeff[i]= a->coeff[i];
for (i=0; i<a->length; i++) coeff[i]= a->coeff[i];
return vec;
}
......@@ -2747,25 +2746,25 @@ void sws_printVec(SwsVector *a){
double min=0;
double range;
for(i=0; i<a->length; i++)
if(a->coeff[i]>max) max= a->coeff[i];
for (i=0; i<a->length; i++)
if (a->coeff[i]>max) max= a->coeff[i];
for(i=0; i<a->length; i++)
if(a->coeff[i]<min) min= a->coeff[i];
for (i=0; i<a->length; i++)
if (a->coeff[i]<min) min= a->coeff[i];
range= max - min;
for(i=0; i<a->length; i++)
for (i=0; i<a->length; i++)
{
int x= (int)((a->coeff[i]-min)*60.0/range +0.5);
av_log(NULL, AV_LOG_DEBUG, "%1.3f ", a->coeff[i]);
for(;x>0; x--) av_log(NULL, AV_LOG_DEBUG, " ");
for (;x>0; x--) av_log(NULL, AV_LOG_DEBUG, " ");
av_log(NULL, AV_LOG_DEBUG, "|\n");
}
}
void sws_freeVec(SwsVector *a){
if(!a) return;
if (!a) return;
av_free(a->coeff);
a->coeff=NULL;
a->length=0;
......@@ -2773,23 +2772,23 @@ void sws_freeVec(SwsVector *a){
}
void sws_freeFilter(SwsFilter *filter){
if(!filter) return;
if (!filter) return;
if(filter->lumH) sws_freeVec(filter->lumH);
if(filter->lumV) sws_freeVec(filter->lumV);
if(filter->chrH) sws_freeVec(filter->chrH);
if(filter->chrV) sws_freeVec(filter->chrV);
if (filter->lumH) sws_freeVec(filter->lumH);
if (filter->lumV) sws_freeVec(filter->lumV);
if (filter->chrH) sws_freeVec(filter->chrH);
if (filter->chrV) sws_freeVec(filter->chrV);
av_free(filter);
}
void sws_freeContext(SwsContext *c){
int i;
if(!c) return;
if (!c) return;
if(c->lumPixBuf)
if (c->lumPixBuf)
{
for(i=0; i<c->vLumBufSize; i++)
for (i=0; i<c->vLumBufSize; i++)
{
av_free(c->lumPixBuf[i]);
c->lumPixBuf[i]=NULL;
......@@ -2798,9 +2797,9 @@ void sws_freeContext(SwsContext *c){
c->lumPixBuf=NULL;
}
if(c->chrPixBuf)
if (c->chrPixBuf)
{
for(i=0; i<c->vChrBufSize; i++)
for (i=0; i<c->vChrBufSize; i++)
{
av_free(c->chrPixBuf[i]);
c->chrPixBuf[i]=NULL;
......@@ -2835,8 +2834,8 @@ void sws_freeContext(SwsContext *c){
#if defined(ARCH_X86) && defined(CONFIG_GPL)
#ifdef MAP_ANONYMOUS
if(c->funnyYCode) munmap(c->funnyYCode, MAX_FUNNY_CODE_SIZE);
if(c->funnyUVCode) munmap(c->funnyUVCode, MAX_FUNNY_CODE_SIZE);
if (c->funnyYCode) munmap(c->funnyYCode, MAX_FUNNY_CODE_SIZE);
if (c->funnyUVCode) munmap(c->funnyUVCode, MAX_FUNNY_CODE_SIZE);
#else
av_free(c->funnyYCode);
av_free(c->funnyUVCode);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment