static int swri_resample(ResampleContext *c,

                         uint8_t *dst, const uint8_t *src, int *consumed,

                         int src_size, int dst_size, int update_ctx)

{

    int fn_idx = c->format - AV_SAMPLE_FMT_S16P;



    if (c->filter_length == 1 && c->phase_shift == 0) {

        int index= c->index;

        int frac= c->frac;

        int64_t index2= (1LL<<32)*c->frac/c->src_incr + (1LL<<32)*index;

        int64_t incr= (1LL<<32) * c->dst_incr / c->src_incr;

        int new_size = (src_size * (int64_t)c->src_incr - frac + c->dst_incr - 1) / c->dst_incr;



        dst_size= FFMIN(dst_size, new_size);

        c->dsp.resample_one[fn_idx](dst, src, dst_size, index2, incr);



        index += dst_size * c->dst_incr_div;

        index += (frac + dst_size * (int64_t)c->dst_incr_mod) / c->src_incr;

        av_assert2(index >= 0);

        *consumed= index;

        if (update_ctx) {

            c->frac   = (frac + dst_size * (int64_t)c->dst_incr_mod) % c->src_incr;

            c->index = 0;

        }

    } else {

        int64_t end_index = (1LL + src_size - c->filter_length) << c->phase_shift;

        int64_t delta_frac = (end_index - c->index) * c->src_incr - c->frac;

        int delta_n = (delta_frac + c->dst_incr - 1) / c->dst_incr;



        dst_size = FFMIN(dst_size, delta_n);

        if (dst_size > 0) {

            if (!c->linear) {

                *consumed = c->dsp.resample_common[fn_idx](c, dst, src, dst_size, update_ctx);

            } else {

                *consumed = c->dsp.resample_linear[fn_idx](c, dst, src, dst_size, update_ctx);

            }

        } else {

            *consumed = 0;

        }

    }



    return dst_size;

}

static int swri_resample(ResampleContext *c,

                         uint8_t *dst, const uint8_t *src, int *consumed,

                         int src_size, int dst_size, int update_ctx)

{

    int fn_idx = c->format - AV_SAMPLE_FMT_S16P;



    if (c->filter_length == 1 && c->phase_shift == 0) {

        int index= c->index;

        int frac= c->frac;

        int64_t index2= (1LL<<32)*c->frac/c->src_incr + (1LL<<32)*index;

        int64_t incr= (1LL<<32) * c->dst_incr / c->src_incr;

        int new_size = (src_size * (int64_t)c->src_incr - frac + c->dst_incr - 1) / c->dst_incr;



        dst_size= FFMIN(dst_size, new_size);

        c->dsp.resample_one[fn_idx](dst, src, dst_size, index2, incr);



        index += dst_size * c->dst_incr_div;

        index += (frac + dst_size * (int64_t)c->dst_incr_mod) / c->src_incr;

        av_assert2(index >= 0);

        *consumed= index;

        if (update_ctx) {

            c->frac   = (frac + dst_size * (int64_t)c->dst_incr_mod) % c->src_incr;

            c->index = 0;

        }

    } else {

        int64_t end_index = (1LL + src_size - c->filter_length) << c->phase_shift;

        int64_t delta_frac = (end_index - c->index) * c->src_incr - c->frac;

        int delta_n = (delta_frac + c->dst_incr - 1) / c->dst_incr;



        dst_size = FFMIN(dst_size, delta_n);

        if (dst_size > 0) {

            if (!c->linear) {

                *consumed = c->dsp.resample_common[fn_idx](c, dst, src, dst_size, update_ctx);

            } else {

                *consumed = c->dsp.resample_linear[fn_idx](c, dst, src, dst_size, update_ctx);

            }

        } else {

            *consumed = 0;

        }

    }



    return dst_size;

}

static int FUNC_0(ResampleContext *VAR_0,

                         uint8_t *VAR_1, const uint8_t *VAR_2, int *VAR_3,

                         int VAR_4, int VAR_5, int VAR_6)

{

    int VAR_7 = VAR_0->format - AV_SAMPLE_FMT_S16P;



    if (VAR_0->filter_length == 1 && VAR_0->phase_shift == 0) {

        int VAR_8= VAR_0->VAR_8;

        int VAR_9= VAR_0->VAR_9;

        int64_t index2= (1LL<<32)*VAR_0->VAR_9/VAR_0->src_incr + (1LL<<32)*VAR_8;

        int64_t incr= (1LL<<32) * VAR_0->dst_incr / VAR_0->src_incr;

        int VAR_10 = (VAR_4 * (int64_t)VAR_0->src_incr - VAR_9 + VAR_0->dst_incr - 1) / VAR_0->dst_incr;



        VAR_5= FFMIN(VAR_5, VAR_10);

        VAR_0->dsp.resample_one[VAR_7](VAR_1, VAR_2, VAR_5, index2, incr);



        VAR_8 += VAR_5 * VAR_0->dst_incr_div;

        VAR_8 += (VAR_9 + VAR_5 * (int64_t)VAR_0->dst_incr_mod) / VAR_0->src_incr;

        av_assert2(VAR_8 >= 0);

        *VAR_3= VAR_8;

        if (VAR_6) {

            VAR_0->VAR_9   = (VAR_9 + VAR_5 * (int64_t)VAR_0->dst_incr_mod) % VAR_0->src_incr;

            VAR_0->VAR_8 = 0;

        }

    } else {

        int64_t end_index = (1LL + VAR_4 - VAR_0->filter_length) << VAR_0->phase_shift;

        int64_t delta_frac = (end_index - VAR_0->VAR_8) * VAR_0->src_incr - VAR_0->VAR_9;

        int VAR_11 = (delta_frac + VAR_0->dst_incr - 1) / VAR_0->dst_incr;



        VAR_5 = FFMIN(VAR_5, VAR_11);

        if (VAR_5 > 0) {

            if (!VAR_0->linear) {

                *VAR_3 = VAR_0->dsp.resample_common[VAR_7](VAR_0, VAR_1, VAR_2, VAR_5, VAR_6);

            } else {

                *VAR_3 = VAR_0->dsp.resample_linear[VAR_7](VAR_0, VAR_1, VAR_2, VAR_5, VAR_6);

            }

        } else {

            *VAR_3 = 0;

        }

    }



    return VAR_5;

}

static int FUNC_0(ResampleContext *VAR_0,
uint8_t *VAR_1, const uint8_t *VAR_2, int *VAR_3,
int VAR_4, int VAR_5, int VAR_6)
{ int VAR_7 = VAR_0->format - AV_SAMPLE_FMT_S16P; if (VAR_0->filter_length == 1 && VAR_0->phase_shift == 0) { int VAR_8= VAR_0->VAR_8; int VAR_9= VAR_0->VAR_9; int64_t index2= (1LL<<32)*VAR_0->VAR_9/VAR_0->src_incr + (1LL<<32)*VAR_8; int64_t incr= (1LL<<32) * VAR_0->dst_incr / VAR_0->src_incr; int VAR_10 = (VAR_4 * (int64_t)VAR_0->src_incr - VAR_9 + VAR_0->dst_incr - 1) / VAR_0->dst_incr; VAR_5= FFMIN(VAR_5, VAR_10); VAR_0->dsp.resample_one[VAR_7](VAR_1, VAR_2, VAR_5, index2, incr); VAR_8 += VAR_5 * VAR_0->dst_incr_div; VAR_8 += (VAR_9 + VAR_5 * (int64_t)VAR_0->dst_incr_mod) / VAR_0->src_incr; av_assert2(VAR_8 >= 0); *VAR_3= VAR_8; if (VAR_6) { VAR_0->VAR_9   = (VAR_9 + VAR_5 * (int64_t)VAR_0->dst_incr_mod) % VAR_0->src_incr; VAR_0->VAR_8 = 0; } } else { int64_t end_index = (1LL + VAR_4 - VAR_0->filter_length) << VAR_0->phase_shift; int64_t delta_frac = (end_index - VAR_0->VAR_8) * VAR_0->src_incr - VAR_0->VAR_9; int VAR_11 = (delta_frac + VAR_0->dst_incr - 1) / VAR_0->dst_incr; VAR_5 = FFMIN(VAR_5, VAR_11); if (VAR_5 > 0) { if (!VAR_0->linear) { *VAR_3 = VAR_0->dsp.resample_common[VAR_7](VAR_0, VAR_1, VAR_2, VAR_5, VAR_6); } else { *VAR_3 = VAR_0->dsp.resample_linear[VAR_7](VAR_0, VAR_1, VAR_2, VAR_5, VAR_6); } } else { *VAR_3 = 0; } } return VAR_5; }