static int build_filter(ResampleContext *c, void *filter, double factor, int tap_count, int alloc, int phase_count, int scale,

                        int filter_type, double kaiser_beta){

    int ph, i;

    double x, y, w, t, s;

    double *tab = av_malloc_array(tap_count+1,  sizeof(*tab));

    double *sin_lut = av_malloc_array(phase_count / 2 + 1, sizeof(*sin_lut));

    const int center= (tap_count-1)/2;



    if (!tab || !sin_lut)

        goto fail;



    /* if upsampling, only need to interpolate, no filter */

    if (factor > 1.0)

        factor = 1.0;



    av_assert0(phase_count == 1 || phase_count % 2 == 0);



    if (factor == 1.0) {

        for (ph = 0; ph <= phase_count / 2; ph++)

            sin_lut[ph] = sin(M_PI * ph / phase_count);

    }

    for(ph = 0; ph <= phase_count / 2; ph++) {

        double norm = 0;

        s = sin_lut[ph];

        for(i=0;i<=tap_count;i++) {

            x = M_PI * ((double)(i - center) - (double)ph / phase_count) * factor;

            if (x == 0) y = 1.0;

            else if (factor == 1.0)

                y = s / x;

            else

                y = sin(x) / x;

            switch(filter_type){

            case SWR_FILTER_TYPE_CUBIC:{

                const float d= -0.5; //first order derivative = -0.5

                x = fabs(((double)(i - center) - (double)ph / phase_count) * factor);

                if(x<1.0) y= 1 - 3*x*x + 2*x*x*x + d*(            -x*x + x*x*x);

                else      y=                       d*(-4 + 8*x - 5*x*x + x*x*x);

                break;}

            case SWR_FILTER_TYPE_BLACKMAN_NUTTALL:

                w = 2.0*x / (factor*tap_count);

                t = -cos(w);

                y *= 0.3635819 - 0.4891775 * t + 0.1365995 * (2*t*t-1) - 0.0106411 * (4*t*t*t - 3*t);

                break;

            case SWR_FILTER_TYPE_KAISER:

                w = 2.0*x / (factor*tap_count*M_PI);

                y *= bessel(kaiser_beta*sqrt(FFMAX(1-w*w, 0)));

                break;

            default:

                av_assert0(0);

            }



            tab[i] = y;

            s = -s;

            if (i < tap_count)

                norm += y;

        }



        /* normalize so that an uniform color remains the same */

        switch(c->format){

        case AV_SAMPLE_FMT_S16P:

            for(i=0;i<tap_count;i++)

                ((int16_t*)filter)[ph * alloc + i] = av_clip_int16(lrintf(tab[i] * scale / norm));

            if (tap_count % 2 == 0) {

                for (i = 0; i < tap_count; i++)

                    ((int16_t*)filter)[(phase_count-ph) * alloc + tap_count-1-i] = ((int16_t*)filter)[ph * alloc + i];

            }

            else {

                for (i = 1; i <= tap_count; i++)

                    ((int16_t*)filter)[(phase_count-ph) * alloc + tap_count-i] =

                        av_clip_int16(lrintf(tab[i] * scale / (norm - tab[0] + tab[tap_count])));

            }

            break;

        case AV_SAMPLE_FMT_S32P:

            for(i=0;i<tap_count;i++)

                ((int32_t*)filter)[ph * alloc + i] = av_clipl_int32(llrint(tab[i] * scale / norm));

            if (tap_count % 2 == 0) {

                for (i = 0; i < tap_count; i++)

                    ((int32_t*)filter)[(phase_count-ph) * alloc + tap_count-1-i] = ((int32_t*)filter)[ph * alloc + i];

            }

            else {

                for (i = 1; i <= tap_count; i++)

                    ((int32_t*)filter)[(phase_count-ph) * alloc + tap_count-i] =

                        av_clipl_int32(llrint(tab[i] * scale / (norm - tab[0] + tab[tap_count])));

            }

            break;

        case AV_SAMPLE_FMT_FLTP:

            for(i=0;i<tap_count;i++)

                ((float*)filter)[ph * alloc + i] = tab[i] * scale / norm;

            if (tap_count % 2 == 0) {

                for (i = 0; i < tap_count; i++)

                    ((float*)filter)[(phase_count-ph) * alloc + tap_count-1-i] = ((float*)filter)[ph * alloc + i];

            }

            else {

                for (i = 1; i <= tap_count; i++)

                    ((float*)filter)[(phase_count-ph) * alloc + tap_count-i] = tab[i] * scale / (norm - tab[0] + tab[tap_count]);

            }

            break;

        case AV_SAMPLE_FMT_DBLP:

            for(i=0;i<tap_count;i++)

                ((double*)filter)[ph * alloc + i] = tab[i] * scale / norm;

            if (tap_count % 2 == 0) {

                for (i = 0; i < tap_count; i++)

                    ((double*)filter)[(phase_count-ph) * alloc + tap_count-1-i] = ((double*)filter)[ph * alloc + i];

            }

            else {

                for (i = 1; i <= tap_count; i++)

                    ((double*)filter)[(phase_count-ph) * alloc + tap_count-i] = tab[i] * scale / (norm - tab[0] + tab[tap_count]);

            }

            break;

        }

    }

#if 0

    {

#define LEN 1024

        int j,k;

        double sine[LEN + tap_count];

        double filtered[LEN];

        double maxff=-2, minff=2, maxsf=-2, minsf=2;

        for(i=0; i<LEN; i++){

            double ss=0, sf=0, ff=0;

            for(j=0; j<LEN+tap_count; j++)

                sine[j]= cos(i*j*M_PI/LEN);

            for(j=0; j<LEN; j++){

                double sum=0;

                ph=0;

                for(k=0; k<tap_count; k++)

                    sum += filter[ph * tap_count + k] * sine[k+j];

                filtered[j]= sum / (1<<FILTER_SHIFT);

                ss+= sine[j + center] * sine[j + center];

                ff+= filtered[j] * filtered[j];

                sf+= sine[j + center] * filtered[j];

            }

            ss= sqrt(2*ss/LEN);

            ff= sqrt(2*ff/LEN);

            sf= 2*sf/LEN;

            maxff= FFMAX(maxff, ff);

            minff= FFMIN(minff, ff);

            maxsf= FFMAX(maxsf, sf);

            minsf= FFMIN(minsf, sf);

            if(i%11==0){

                av_log(NULL, AV_LOG_ERROR, "i:%4d ss:%f ff:%13.6e-%13.6e sf:%13.6e-%13.6e\n", i, ss, maxff, minff, maxsf, minsf);

                minff=minsf= 2;

                maxff=maxsf= -2;

            }

        }

    }

#endif



fail:

    av_free(tab);

    av_free(sin_lut);

    return 0;

}

static int build_filter(ResampleContext *c, void *filter, double factor, int tap_count, int alloc, int phase_count, int scale,

                        int filter_type, double kaiser_beta){

    int ph, i;

    double x, y, w, t, s;

    double *tab = av_malloc_array(tap_count+1,  sizeof(*tab));

    double *sin_lut = av_malloc_array(phase_count / 2 + 1, sizeof(*sin_lut));

    const int center= (tap_count-1)/2;



    if (!tab || !sin_lut)

        goto fail;



    

    if (factor > 1.0)

        factor = 1.0;



    av_assert0(phase_count == 1 || phase_count % 2 == 0);



    if (factor == 1.0) {

        for (ph = 0; ph <= phase_count / 2; ph++)

            sin_lut[ph] = sin(M_PI * ph / phase_count);

    }

    for(ph = 0; ph <= phase_count / 2; ph++) {

        double norm = 0;

        s = sin_lut[ph];

        for(i=0;i<=tap_count;i++) {

            x = M_PI * ((double)(i - center) - (double)ph / phase_count) * factor;

            if (x == 0) y = 1.0;

            else if (factor == 1.0)

                y = s / x;

            else

                y = sin(x) / x;

            switch(filter_type){

            case SWR_FILTER_TYPE_CUBIC:{

                const float d= -0.5; 

                x = fabs(((double)(i - center) - (double)ph / phase_count) * factor);

                if(x<1.0) y= 1 - 3*x*x + 2*x*x*x + d*(            -x*x + x*x*x);

                else      y=                       d*(-4 + 8*x - 5*x*x + x*x*x);

                break;}

            case SWR_FILTER_TYPE_BLACKMAN_NUTTALL:

                w = 2.0*x / (factor*tap_count);

                t = -cos(w);

                y *= 0.3635819 - 0.4891775 * t + 0.1365995 * (2*t*t-1) - 0.0106411 * (4*t*t*t - 3*t);

                break;

            case SWR_FILTER_TYPE_KAISER:

                w = 2.0*x / (factor*tap_count*M_PI);

                y *= bessel(kaiser_beta*sqrt(FFMAX(1-w*w, 0)));

                break;

            default:

                av_assert0(0);

            }



            tab[i] = y;

            s = -s;

            if (i < tap_count)

                norm += y;

        }



        

        switch(c->format){

        case AV_SAMPLE_FMT_S16P:

            for(i=0;i<tap_count;i++)

                ((int16_t*)filter)[ph * alloc + i] = av_clip_int16(lrintf(tab[i] * scale / norm));

            if (tap_count % 2 == 0) {

                for (i = 0; i < tap_count; i++)

                    ((int16_t*)filter)[(phase_count-ph) * alloc + tap_count-1-i] = ((int16_t*)filter)[ph * alloc + i];

            }

            else {

                for (i = 1; i <= tap_count; i++)

                    ((int16_t*)filter)[(phase_count-ph) * alloc + tap_count-i] =

                        av_clip_int16(lrintf(tab[i] * scale / (norm - tab[0] + tab[tap_count])));

            }

            break;

        case AV_SAMPLE_FMT_S32P:

            for(i=0;i<tap_count;i++)

                ((int32_t*)filter)[ph * alloc + i] = av_clipl_int32(llrint(tab[i] * scale / norm));

            if (tap_count % 2 == 0) {

                for (i = 0; i < tap_count; i++)

                    ((int32_t*)filter)[(phase_count-ph) * alloc + tap_count-1-i] = ((int32_t*)filter)[ph * alloc + i];

            }

            else {

                for (i = 1; i <= tap_count; i++)

                    ((int32_t*)filter)[(phase_count-ph) * alloc + tap_count-i] =

                        av_clipl_int32(llrint(tab[i] * scale / (norm - tab[0] + tab[tap_count])));

            }

            break;

        case AV_SAMPLE_FMT_FLTP:

            for(i=0;i<tap_count;i++)

                ((float*)filter)[ph * alloc + i] = tab[i] * scale / norm;

            if (tap_count % 2 == 0) {

                for (i = 0; i < tap_count; i++)

                    ((float*)filter)[(phase_count-ph) * alloc + tap_count-1-i] = ((float*)filter)[ph * alloc + i];

            }

            else {

                for (i = 1; i <= tap_count; i++)

                    ((float*)filter)[(phase_count-ph) * alloc + tap_count-i] = tab[i] * scale / (norm - tab[0] + tab[tap_count]);

            }

            break;

        case AV_SAMPLE_FMT_DBLP:

            for(i=0;i<tap_count;i++)

                ((double*)filter)[ph * alloc + i] = tab[i] * scale / norm;

            if (tap_count % 2 == 0) {

                for (i = 0; i < tap_count; i++)

                    ((double*)filter)[(phase_count-ph) * alloc + tap_count-1-i] = ((double*)filter)[ph * alloc + i];

            }

            else {

                for (i = 1; i <= tap_count; i++)

                    ((double*)filter)[(phase_count-ph) * alloc + tap_count-i] = tab[i] * scale / (norm - tab[0] + tab[tap_count]);

            }

            break;

        }

    }

#if 0

    {

#define LEN 1024

        int j,k;

        double sine[LEN + tap_count];

        double filtered[LEN];

        double maxff=-2, minff=2, maxsf=-2, minsf=2;

        for(i=0; i<LEN; i++){

            double ss=0, sf=0, ff=0;

            for(j=0; j<LEN+tap_count; j++)

                sine[j]= cos(i*j*M_PI/LEN);

            for(j=0; j<LEN; j++){

                double sum=0;

                ph=0;

                for(k=0; k<tap_count; k++)

                    sum += filter[ph * tap_count + k] * sine[k+j];

                filtered[j]= sum / (1<<FILTER_SHIFT);

                ss+= sine[j + center] * sine[j + center];

                ff+= filtered[j] * filtered[j];

                sf+= sine[j + center] * filtered[j];

            }

            ss= sqrt(2*ss/LEN);

            ff= sqrt(2*ff/LEN);

            sf= 2*sf/LEN;

            maxff= FFMAX(maxff, ff);

            minff= FFMIN(minff, ff);

            maxsf= FFMAX(maxsf, sf);

            minsf= FFMIN(minsf, sf);

            if(i%11==0){

                av_log(NULL, AV_LOG_ERROR, "i:%4d ss:%f ff:%13.6e-%13.6e sf:%13.6e-%13.6e\n", i, ss, maxff, minff, maxsf, minsf);

                minff=minsf= 2;

                maxff=maxsf= -2;

            }

        }

    }

#endif



fail:

    av_free(tab);

    av_free(sin_lut);

    return 0;

}

            if (tap_count % 2 == 0) {             if (tap_count % 2 == 0) {             if (tap_count % 2 == 0) {             if (tap_count % 2 == 0) {
static int FUNC_0(ResampleContext *VAR_0, void *VAR_1, double VAR_2, int VAR_3, int VAR_4, int VAR_5, int VAR_6,

                        int VAR_7, double VAR_8){

    int VAR_9, VAR_10;

    double VAR_11, VAR_12, VAR_13, VAR_14, VAR_15;

    double *VAR_16 = av_malloc_array(VAR_3+1,  sizeof(*VAR_16));

    double *VAR_17 = av_malloc_array(VAR_5 / 2 + 1, sizeof(*VAR_17));

    const int VAR_18= (VAR_3-1)/2;



    if (!VAR_16 || !VAR_17)

        goto fail;



    

    if (VAR_2 > 1.0)

        VAR_2 = 1.0;



    av_assert0(VAR_5 == 1 || VAR_5 % 2 == 0);



    if (VAR_2 == 1.0) {

        for (VAR_9 = 0; VAR_9 <= VAR_5 / 2; VAR_9++)

            VAR_17[VAR_9] = sin(M_PI * VAR_9 / VAR_5);

    }

    for(VAR_9 = 0; VAR_9 <= VAR_5 / 2; VAR_9++) {

        double VAR_19 = 0;

        VAR_15 = VAR_17[VAR_9];

        for(VAR_10=0;VAR_10<=VAR_3;VAR_10++) {

            VAR_11 = M_PI * ((double)(VAR_10 - VAR_18) - (double)VAR_9 / VAR_5) * VAR_2;

            if (VAR_11 == 0) VAR_12 = 1.0;

            else if (VAR_2 == 1.0)

                VAR_12 = VAR_15 / VAR_11;

            else

                VAR_12 = sin(VAR_11) / VAR_11;

            switch(VAR_7){

            case SWR_FILTER_TYPE_CUBIC:{

                const float VAR_20= -0.5; 

                VAR_11 = fabs(((double)(VAR_10 - VAR_18) - (double)VAR_9 / VAR_5) * VAR_2);

                if(VAR_11<1.0) VAR_12= 1 - 3*VAR_11*VAR_11 + 2*VAR_11*VAR_11*VAR_11 + VAR_20*(            -VAR_11*VAR_11 + VAR_11*VAR_11*VAR_11);

                else      VAR_12=                       VAR_20*(-4 + 8*VAR_11 - 5*VAR_11*VAR_11 + VAR_11*VAR_11*VAR_11);

                break;}

            case SWR_FILTER_TYPE_BLACKMAN_NUTTALL:

                VAR_13 = 2.0*VAR_11 / (VAR_2*VAR_3);

                VAR_14 = -cos(VAR_13);

                VAR_12 *= 0.3635819 - 0.4891775 * VAR_14 + 0.1365995 * (2*VAR_14*VAR_14-1) - 0.0106411 * (4*VAR_14*VAR_14*VAR_14 - 3*VAR_14);

                break;

            case SWR_FILTER_TYPE_KAISER:

                VAR_13 = 2.0*VAR_11 / (VAR_2*VAR_3*M_PI);

                VAR_12 *= bessel(VAR_8*sqrt(FFMAX(1-VAR_13*VAR_13, 0)));

                break;

            default:

                av_assert0(0);

            }



            VAR_16[VAR_10] = VAR_12;

            VAR_15 = -VAR_15;

            if (VAR_10 < VAR_3)

                VAR_19 += VAR_12;

        }



        

        switch(VAR_0->format){

        case AV_SAMPLE_FMT_S16P:

            for(VAR_10=0;VAR_10<VAR_3;VAR_10++)

                ((int16_t*)VAR_1)[VAR_9 * VAR_4 + VAR_10] = av_clip_int16(lrintf(VAR_16[VAR_10] * VAR_6 / VAR_19));

            if (VAR_3 % 2 == 0) {

                for (VAR_10 = 0; VAR_10 < VAR_3; VAR_10++)

                    ((int16_t*)VAR_1)[(VAR_5-VAR_9) * VAR_4 + VAR_3-1-VAR_10] = ((int16_t*)VAR_1)[VAR_9 * VAR_4 + VAR_10];

            }

            else {

                for (VAR_10 = 1; VAR_10 <= VAR_3; VAR_10++)

                    ((int16_t*)VAR_1)[(VAR_5-VAR_9) * VAR_4 + VAR_3-VAR_10] =

                        av_clip_int16(lrintf(VAR_16[VAR_10] * VAR_6 / (VAR_19 - VAR_16[0] + VAR_16[VAR_3])));

            }

            break;

        case AV_SAMPLE_FMT_S32P:

            for(VAR_10=0;VAR_10<VAR_3;VAR_10++)

                ((int32_t*)VAR_1)[VAR_9 * VAR_4 + VAR_10] = av_clipl_int32(llrint(VAR_16[VAR_10] * VAR_6 / VAR_19));

            if (VAR_3 % 2 == 0) {

                for (VAR_10 = 0; VAR_10 < VAR_3; VAR_10++)

                    ((int32_t*)VAR_1)[(VAR_5-VAR_9) * VAR_4 + VAR_3-1-VAR_10] = ((int32_t*)VAR_1)[VAR_9 * VAR_4 + VAR_10];

            }

            else {

                for (VAR_10 = 1; VAR_10 <= VAR_3; VAR_10++)

                    ((int32_t*)VAR_1)[(VAR_5-VAR_9) * VAR_4 + VAR_3-VAR_10] =

                        av_clipl_int32(llrint(VAR_16[VAR_10] * VAR_6 / (VAR_19 - VAR_16[0] + VAR_16[VAR_3])));

            }

            break;

        case AV_SAMPLE_FMT_FLTP:

            for(VAR_10=0;VAR_10<VAR_3;VAR_10++)

                ((float*)VAR_1)[VAR_9 * VAR_4 + VAR_10] = VAR_16[VAR_10] * VAR_6 / VAR_19;

            if (VAR_3 % 2 == 0) {

                for (VAR_10 = 0; VAR_10 < VAR_3; VAR_10++)

                    ((float*)VAR_1)[(VAR_5-VAR_9) * VAR_4 + VAR_3-1-VAR_10] = ((float*)VAR_1)[VAR_9 * VAR_4 + VAR_10];

            }

            else {

                for (VAR_10 = 1; VAR_10 <= VAR_3; VAR_10++)

                    ((float*)VAR_1)[(VAR_5-VAR_9) * VAR_4 + VAR_3-VAR_10] = VAR_16[VAR_10] * VAR_6 / (VAR_19 - VAR_16[0] + VAR_16[VAR_3]);

            }

            break;

        case AV_SAMPLE_FMT_DBLP:

            for(VAR_10=0;VAR_10<VAR_3;VAR_10++)

                ((double*)VAR_1)[VAR_9 * VAR_4 + VAR_10] = VAR_16[VAR_10] * VAR_6 / VAR_19;

            if (VAR_3 % 2 == 0) {

                for (VAR_10 = 0; VAR_10 < VAR_3; VAR_10++)

                    ((double*)VAR_1)[(VAR_5-VAR_9) * VAR_4 + VAR_3-1-VAR_10] = ((double*)VAR_1)[VAR_9 * VAR_4 + VAR_10];

            }

            else {

                for (VAR_10 = 1; VAR_10 <= VAR_3; VAR_10++)

                    ((double*)VAR_1)[(VAR_5-VAR_9) * VAR_4 + VAR_3-VAR_10] = VAR_16[VAR_10] * VAR_6 / (VAR_19 - VAR_16[0] + VAR_16[VAR_3]);

            }

            break;

        }

    }

#if 0

    {

#define LEN 1024

        int j,k;

        double sine[LEN + VAR_3];

        double filtered[LEN];

        double maxff=-2, minff=2, maxsf=-2, minsf=2;

        for(VAR_10=0; VAR_10<LEN; VAR_10++){

            double ss=0, sf=0, ff=0;

            for(j=0; j<LEN+VAR_3; j++)

                sine[j]= cos(VAR_10*j*M_PI/LEN);

            for(j=0; j<LEN; j++){

                double sum=0;

                VAR_9=0;

                for(k=0; k<VAR_3; k++)

                    sum += VAR_1[VAR_9 * VAR_3 + k] * sine[k+j];

                filtered[j]= sum / (1<<FILTER_SHIFT);

                ss+= sine[j + VAR_18] * sine[j + VAR_18];

                ff+= filtered[j] * filtered[j];

                sf+= sine[j + VAR_18] * filtered[j];

            }

            ss= sqrt(2*ss/LEN);

            ff= sqrt(2*ff/LEN);

            sf= 2*sf/LEN;

            maxff= FFMAX(maxff, ff);

            minff= FFMIN(minff, ff);

            maxsf= FFMAX(maxsf, sf);

            minsf= FFMIN(minsf, sf);

            if(VAR_10%11==0){

                av_log(NULL, AV_LOG_ERROR, "VAR_10:%4d ss:%f ff:%13.6e-%13.6e sf:%13.6e-%13.6e\n", VAR_10, ss, maxff, minff, maxsf, minsf);

                minff=minsf= 2;

                maxff=maxsf= -2;

            }

        }

    }

#endif



fail:

    av_free(VAR_16);

    av_free(VAR_17);

    return 0;

}

static int FUNC_0(ResampleContext *VAR_0, void *VAR_1, double VAR_2, int VAR_3, int VAR_4, int VAR_5, int VAR_6,
int VAR_7, double VAR_8){ int VAR_9, VAR_10; double VAR_11, VAR_12, VAR_13, VAR_14, VAR_15; double *VAR_16 = av_malloc_array(VAR_3+1,  sizeof(*VAR_16)); double *VAR_17 = av_malloc_array(VAR_5 / 2 + 1, sizeof(*VAR_17)); const int VAR_18= (VAR_3-1)/2; if (!VAR_16 || !VAR_17)
goto fail; if (VAR_2 > 1.0)
VAR_2 = 1.0; av_assert0(VAR_5 == 1 || VAR_5 % 2 == 0); if (VAR_2 == 1.0) { for (VAR_9 = 0; VAR_9 <= VAR_5 / 2; VAR_9++) VAR_17[VAR_9] = sin(M_PI * VAR_9 / VAR_5); } for(VAR_9 = 0; VAR_9 <= VAR_5 / 2; VAR_9++) { double VAR_19 = 0; VAR_15 = VAR_17[VAR_9]; for(VAR_10=0;VAR_10<=VAR_3;VAR_10++) { VAR_11 = M_PI * ((double)(VAR_10 - VAR_18) - (double)VAR_9 / VAR_5) * VAR_2; if (VAR_11 == 0) VAR_12 = 1.0; else if (VAR_2 == 1.0)
VAR_12 = VAR_15 / VAR_11; else
VAR_12 = sin(VAR_11) / VAR_11; switch(VAR_7){ case SWR_FILTER_TYPE_CUBIC:{ const float VAR_20= -0.5; VAR_11 = fabs(((double)(VAR_10 - VAR_18) - (double)VAR_9 / VAR_5) * VAR_2); if(VAR_11<1.0) VAR_12= 1 - 3*VAR_11*VAR_11 + 2*VAR_11*VAR_11*VAR_11 + VAR_20*(            -VAR_11*VAR_11 + VAR_11*VAR_11*VAR_11); else      VAR_12=                       VAR_20*(-4 + 8*VAR_11 - 5*VAR_11*VAR_11 + VAR_11*VAR_11*VAR_11); break;} case SWR_FILTER_TYPE_BLACKMAN_NUTTALL:
VAR_13 = 2.0*VAR_11 / (VAR_2*VAR_3); VAR_14 = -cos(VAR_13); VAR_12 *= 0.3635819 - 0.4891775 * VAR_14 + 0.1365995 * (2*VAR_14*VAR_14-1) - 0.0106411 * (4*VAR_14*VAR_14*VAR_14 - 3*VAR_14); break; case SWR_FILTER_TYPE_KAISER:
VAR_13 = 2.0*VAR_11 / (VAR_2*VAR_3*M_PI); VAR_12 *= bessel(VAR_8*sqrt(FFMAX(1-VAR_13*VAR_13, 0))); break; default:
av_assert0(0); } VAR_16[VAR_10] = VAR_12; VAR_15 = -VAR_15; if (VAR_10 < VAR_3)
VAR_19 += VAR_12; } switch(VAR_0->format){ case AV_SAMPLE_FMT_S16P:
for(VAR_10=0;VAR_10<VAR_3;VAR_10++) ((int16_t*)VAR_1)[VAR_9 * VAR_4 + VAR_10] = av_clip_int16(lrintf(VAR_16[VAR_10] * VAR_6 / VAR_19)); if (VAR_3 % 2 == 0) { for (VAR_10 = 0; VAR_10 < VAR_3; VAR_10++) ((int16_t*)VAR_1)[(VAR_5-VAR_9) * VAR_4 + VAR_3-1-VAR_10] = ((int16_t*)VAR_1)[VAR_9 * VAR_4 + VAR_10]; } else { for (VAR_10 = 1; VAR_10 <= VAR_3; VAR_10++) ((int16_t*)VAR_1)[(VAR_5-VAR_9) * VAR_4 + VAR_3-VAR_10] =
av_clip_int16(lrintf(VAR_16[VAR_10] * VAR_6 / (VAR_19 - VAR_16[0] + VAR_16[VAR_3]))); } break; case AV_SAMPLE_FMT_S32P:
for(VAR_10=0;VAR_10<VAR_3;VAR_10++) ((int32_t*)VAR_1)[VAR_9 * VAR_4 + VAR_10] = av_clipl_int32(llrint(VAR_16[VAR_10] * VAR_6 / VAR_19)); if (VAR_3 % 2 == 0) { for (VAR_10 = 0; VAR_10 < VAR_3; VAR_10++) ((int32_t*)VAR_1)[(VAR_5-VAR_9) * VAR_4 + VAR_3-1-VAR_10] = ((int32_t*)VAR_1)[VAR_9 * VAR_4 + VAR_10]; } else { for (VAR_10 = 1; VAR_10 <= VAR_3; VAR_10++) ((int32_t*)VAR_1)[(VAR_5-VAR_9) * VAR_4 + VAR_3-VAR_10] =
av_clipl_int32(llrint(VAR_16[VAR_10] * VAR_6 / (VAR_19 - VAR_16[0] + VAR_16[VAR_3]))); } break; case AV_SAMPLE_FMT_FLTP:
for(VAR_10=0;VAR_10<VAR_3;VAR_10++) ((float*)VAR_1)[VAR_9 * VAR_4 + VAR_10] = VAR_16[VAR_10] * VAR_6 / VAR_19; if (VAR_3 % 2 == 0) { for (VAR_10 = 0; VAR_10 < VAR_3; VAR_10++) ((float*)VAR_1)[(VAR_5-VAR_9) * VAR_4 + VAR_3-1-VAR_10] = ((float*)VAR_1)[VAR_9 * VAR_4 + VAR_10]; } else { for (VAR_10 = 1; VAR_10 <= VAR_3; VAR_10++) ((float*)VAR_1)[(VAR_5-VAR_9) * VAR_4 + VAR_3-VAR_10] = VAR_16[VAR_10] * VAR_6 / (VAR_19 - VAR_16[0] + VAR_16[VAR_3]); } break; case AV_SAMPLE_FMT_DBLP:
for(VAR_10=0;VAR_10<VAR_3;VAR_10++) ((double*)VAR_1)[VAR_9 * VAR_4 + VAR_10] = VAR_16[VAR_10] * VAR_6 / VAR_19; if (VAR_3 % 2 == 0) { for (VAR_10 = 0; VAR_10 < VAR_3; VAR_10++) ((double*)VAR_1)[(VAR_5-VAR_9) * VAR_4 + VAR_3-1-VAR_10] = ((double*)VAR_1)[VAR_9 * VAR_4 + VAR_10]; } else { for (VAR_10 = 1; VAR_10 <= VAR_3; VAR_10++) ((double*)VAR_1)[(VAR_5-VAR_9) * VAR_4 + VAR_3-VAR_10] = VAR_16[VAR_10] * VAR_6 / (VAR_19 - VAR_16[0] + VAR_16[VAR_3]); } break; } } #if 0
{ #define LEN 1024
int j,k; double sine[LEN + VAR_3]; double filtered[LEN]; double maxff=-2, minff=2, maxsf=-2, minsf=2; for(VAR_10=0; VAR_10<LEN; VAR_10++){ double ss=0, sf=0, ff=0; for(j=0; j<LEN+VAR_3; j++) sine[j]= cos(VAR_10*j*M_PI/LEN); for(j=0; j<LEN; j++){ double sum=0; VAR_9=0; for(k=0; k<VAR_3; k++) sum += VAR_1[VAR_9 * VAR_3 + k] * sine[k+j]; filtered[j]= sum / (1<<FILTER_SHIFT); ss+= sine[j + VAR_18] * sine[j + VAR_18]; ff+= filtered[j] * filtered[j]; sf+= sine[j + VAR_18] * filtered[j]; } ss= sqrt(2*ss/LEN); ff= sqrt(2*ff/LEN); sf= 2*sf/LEN; maxff= FFMAX(maxff, ff); minff= FFMIN(minff, ff); maxsf= FFMAX(maxsf, sf); minsf= FFMIN(minsf, sf); if(VAR_10%11==0){ av_log(NULL, AV_LOG_ERROR, "VAR_10:%4d ss:%f ff:%13.6e-%13.6e sf:%13.6e-%13.6e\n", VAR_10, ss, maxff, minff, maxsf, minsf); minff=minsf= 2; maxff=maxsf= -2; } } } #endif
fail:
av_free(VAR_16); av_free(VAR_17); return 0; }