# HG changeset patch # User ramiro # Date 1250645526 0 # Node ID 335da85c454cebaefd778959d11048b3db852b8f # Parent 869c68891fde02258a94b7f2c6b9605c1cc047b0 Reuse sws_getConstVec() where possible. diff -r 869c68891fde -r 335da85c454c libswscale/swscale.c --- a/libswscale/swscale.c Tue Aug 18 22:25:58 2009 +0000 +++ b/libswscale/swscale.c Wed Aug 19 01:32:06 2009 +0000 @@ -3309,18 +3309,12 @@ static SwsVector *sws_getConvVec(SwsVector *a, SwsVector *b) { int length= a->length + b->length - 1; - double *coeff= av_malloc(length*sizeof(double)); int i, j; - SwsVector *vec= av_malloc(sizeof(SwsVector)); - - vec->coeff= coeff; - vec->length= length; - - for (i=0; ilength; i++) { for (j=0; jlength; j++) { - coeff[i+j]+= a->coeff[i]*b->coeff[j]; + vec->coeff[i+j]+= a->coeff[i]*b->coeff[j]; } } @@ -3330,17 +3324,11 @@ static SwsVector *sws_sumVec(SwsVector *a, SwsVector *b) { int length= FFMAX(a->length, b->length); - double *coeff= av_malloc(length*sizeof(double)); int i; - SwsVector *vec= av_malloc(sizeof(SwsVector)); - - vec->coeff= coeff; - vec->length= length; - - for (i=0; ilength; i++) coeff[i + (length-1)/2 - (a->length-1)/2]+= a->coeff[i]; - for (i=0; ilength; i++) coeff[i + (length-1)/2 - (b->length-1)/2]+= b->coeff[i]; + SwsVector *vec= sws_getConstVec(0.0, length); + + for (i=0; ilength; i++) vec->coeff[i + (length-1)/2 - (a->length-1)/2]+= a->coeff[i]; + for (i=0; ilength; i++) vec->coeff[i + (length-1)/2 - (b->length-1)/2]+= b->coeff[i]; return vec; } @@ -3348,17 +3336,11 @@ static SwsVector *sws_diffVec(SwsVector *a, SwsVector *b) { int length= FFMAX(a->length, b->length); - double *coeff= av_malloc(length*sizeof(double)); int i; - SwsVector *vec= av_malloc(sizeof(SwsVector)); - - vec->coeff= coeff; - vec->length= length; - - for (i=0; ilength; i++) coeff[i + (length-1)/2 - (a->length-1)/2]+= a->coeff[i]; - for (i=0; ilength; i++) coeff[i + (length-1)/2 - (b->length-1)/2]-= b->coeff[i]; + SwsVector *vec= sws_getConstVec(0.0, length); + + for (i=0; ilength; i++) vec->coeff[i + (length-1)/2 - (a->length-1)/2]+= a->coeff[i]; + for (i=0; ilength; i++) vec->coeff[i + (length-1)/2 - (b->length-1)/2]-= b->coeff[i]; return vec; } @@ -3367,17 +3349,11 @@ static SwsVector *sws_getShiftedVec(SwsVector *a, int shift) { int length= a->length + FFABS(shift)*2; - double *coeff= av_malloc(length*sizeof(double)); int i; - SwsVector *vec= av_malloc(sizeof(SwsVector)); - - vec->coeff= coeff; - vec->length= length; - - for (i=0; ilength; i++) { - coeff[i + (length-1)/2 - (a->length-1)/2 - shift]= a->coeff[i]; + vec->coeff[i + (length-1)/2 - (a->length-1)/2 - shift]= a->coeff[i]; } return vec;