void swri_get_dither(SwrContext *s, void *dst, int len, unsigned seed, enum AVSampleFormat noise_fmt) {

    double scale = s->dither.noise_scale;

#define TMP_EXTRA 2

    double *tmp = av_malloc_array(len + TMP_EXTRA, sizeof(double));

    int i;



    for(i=0; i<len + TMP_EXTRA; i++){

        double v;

        seed = seed* 1664525 + 1013904223;



        switch(s->dither.method){

            case SWR_DITHER_RECTANGULAR: v= ((double)seed) / UINT_MAX - 0.5; break;

            default:

                av_assert0(s->dither.method < SWR_DITHER_NB);

                v = ((double)seed) / UINT_MAX;

                seed = seed*1664525 + 1013904223;

                v-= ((double)seed) / UINT_MAX;

                break;

        }

        tmp[i] = v;

    }



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

        double v;



        switch(s->dither.method){

            default:

                av_assert0(s->dither.method < SWR_DITHER_NB);

                v = tmp[i];

                break;

            case SWR_DITHER_TRIANGULAR_HIGHPASS :

                v = (- tmp[i] + 2*tmp[i+1] - tmp[i+2]) / sqrt(6);

                break;

        }



        v*= scale;



        switch(noise_fmt){

            case AV_SAMPLE_FMT_S16P: ((int16_t*)dst)[i] = v; break;

            case AV_SAMPLE_FMT_S32P: ((int32_t*)dst)[i] = v; break;

            case AV_SAMPLE_FMT_FLTP: ((float  *)dst)[i] = v; break;

            case AV_SAMPLE_FMT_DBLP: ((double *)dst)[i] = v; break;

            default: av_assert0(0);

        }

    }



    av_free(tmp);

}

void swri_get_dither(SwrContext *s, void *dst, int len, unsigned seed, enum AVSampleFormat noise_fmt) {

    double scale = s->dither.noise_scale;

#define TMP_EXTRA 2

    double *tmp = av_malloc_array(len + TMP_EXTRA, sizeof(double));

    int i;



    for(i=0; i<len + TMP_EXTRA; i++){

        double v;

        seed = seed* 1664525 + 1013904223;



        switch(s->dither.method){

            case SWR_DITHER_RECTANGULAR: v= ((double)seed) / UINT_MAX - 0.5; break;

            default:

                av_assert0(s->dither.method < SWR_DITHER_NB);

                v = ((double)seed) / UINT_MAX;

                seed = seed*1664525 + 1013904223;

                v-= ((double)seed) / UINT_MAX;

                break;

        }

        tmp[i] = v;

    }



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

        double v;



        switch(s->dither.method){

            default:

                av_assert0(s->dither.method < SWR_DITHER_NB);

                v = tmp[i];

                break;

            case SWR_DITHER_TRIANGULAR_HIGHPASS :

                v = (- tmp[i] + 2*tmp[i+1] - tmp[i+2]) / sqrt(6);

                break;

        }



        v*= scale;



        switch(noise_fmt){

            case AV_SAMPLE_FMT_S16P: ((int16_t*)dst)[i] = v; break;

            case AV_SAMPLE_FMT_S32P: ((int32_t*)dst)[i] = v; break;

            case AV_SAMPLE_FMT_FLTP: ((float  *)dst)[i] = v; break;

            case AV_SAMPLE_FMT_DBLP: ((double *)dst)[i] = v; break;

            default: av_assert0(0);

        }

    }



    av_free(tmp);

}

void FUNC_0(SwrContext *VAR_0, void *VAR_1, int VAR_2, unsigned VAR_3, enum AVSampleFormat VAR_4) {

    double VAR_5 = VAR_0->dither.noise_scale;

#define TMP_EXTRA 2

    double *VAR_6 = av_malloc_array(VAR_2 + TMP_EXTRA, sizeof(double));

    int VAR_7;



    for(VAR_7=0; VAR_7<VAR_2 + TMP_EXTRA; VAR_7++){

        double VAR_9;

        VAR_3 = VAR_3* 1664525 + 1013904223;



        switch(VAR_0->dither.method){

            case SWR_DITHER_RECTANGULAR: VAR_9= ((double)VAR_3) / UINT_MAX - 0.5; break;

            default:

                av_assert0(VAR_0->dither.method < SWR_DITHER_NB);

                VAR_9 = ((double)VAR_3) / UINT_MAX;

                VAR_3 = VAR_3*1664525 + 1013904223;

                VAR_9-= ((double)VAR_3) / UINT_MAX;

                break;

        }

        VAR_6[VAR_7] = VAR_9;

    }



    for(VAR_7=0; VAR_7<VAR_2; VAR_7++){

        double VAR_9;



        switch(VAR_0->dither.method){

            default:

                av_assert0(VAR_0->dither.method < SWR_DITHER_NB);

                VAR_9 = VAR_6[VAR_7];

                break;

            case SWR_DITHER_TRIANGULAR_HIGHPASS :

                VAR_9 = (- VAR_6[VAR_7] + 2*VAR_6[VAR_7+1] - VAR_6[VAR_7+2]) / sqrt(6);

                break;

        }



        VAR_9*= VAR_5;



        switch(VAR_4){

            case AV_SAMPLE_FMT_S16P: ((int16_t*)VAR_1)[VAR_7] = VAR_9; break;

            case AV_SAMPLE_FMT_S32P: ((int32_t*)VAR_1)[VAR_7] = VAR_9; break;

            case AV_SAMPLE_FMT_FLTP: ((float  *)VAR_1)[VAR_7] = VAR_9; break;

            case AV_SAMPLE_FMT_DBLP: ((double *)VAR_1)[VAR_7] = VAR_9; break;

            default: av_assert0(0);

        }

    }



    av_free(VAR_6);

}

void FUNC_0(SwrContext *VAR_0, void *VAR_1, int VAR_2, unsigned VAR_3, enum AVSampleFormat VAR_4) { double VAR_5 = VAR_0->dither.noise_scale; #define TMP_EXTRA 2
double *VAR_6 = av_malloc_array(VAR_2 + TMP_EXTRA, sizeof(double)); int VAR_7; for(VAR_7=0; VAR_7<VAR_2 + TMP_EXTRA; VAR_7++){ double VAR_9; VAR_3 = VAR_3* 1664525 + 1013904223; switch(VAR_0->dither.method){ case SWR_DITHER_RECTANGULAR: VAR_9= ((double)VAR_3) / UINT_MAX - 0.5; break; default:
av_assert0(VAR_0->dither.method < SWR_DITHER_NB); VAR_9 = ((double)VAR_3) / UINT_MAX; VAR_3 = VAR_3*1664525 + 1013904223; VAR_9-= ((double)VAR_3) / UINT_MAX; break; } VAR_6[VAR_7] = VAR_9; } for(VAR_7=0; VAR_7<VAR_2; VAR_7++){ double VAR_9; switch(VAR_0->dither.method){ default:
av_assert0(VAR_0->dither.method < SWR_DITHER_NB); VAR_9 = VAR_6[VAR_7]; break; case SWR_DITHER_TRIANGULAR_HIGHPASS :
VAR_9 = (- VAR_6[VAR_7] + 2*VAR_6[VAR_7+1] - VAR_6[VAR_7+2]) / sqrt(6); break; } VAR_9*= VAR_5; switch(VAR_4){ case AV_SAMPLE_FMT_S16P: ((int16_t*)VAR_1)[VAR_7] = VAR_9; break; case AV_SAMPLE_FMT_S32P: ((int32_t*)VAR_1)[VAR_7] = VAR_9; break; case AV_SAMPLE_FMT_FLTP: ((float  *)VAR_1)[VAR_7] = VAR_9; break; case AV_SAMPLE_FMT_DBLP: ((double *)VAR_1)[VAR_7] = VAR_9; break; default: av_assert0(0); } } av_free(VAR_6); }