int swr_convert_frame(SwrContext *s,

                      AVFrame *out, const AVFrame *in)

{

    int ret, setup = 0;



    if (!swr_is_initialized(s)) {

        if ((ret = swr_config_frame(s, out, in)) < 0)

            return ret;

        if ((ret = swr_init(s)) < 0)

            return ret;

        setup = 1;

    } else {

        // return as is or reconfigure for input changes?

        if ((ret = config_changed(s, out, in)))

            return ret;

    }



    if (out) {

        if (!out->linesize[0]) {

            out->nb_samples =   swr_get_delay(s, s->out_sample_rate)

                              + in->nb_samples*(int64_t)s->out_sample_rate / s->in_sample_rate

                              + 3;

            if ((ret = av_frame_get_buffer(out, 0)) < 0) {

                if (setup)

                    swr_close(s);

                return ret;

            }

        } else {

            if (!out->nb_samples)

                out->nb_samples = available_samples(out);

        }

    }



    return convert_frame(s, out, in);

}

int swr_convert_frame(SwrContext *s,

                      AVFrame *out, const AVFrame *in)

{

    int ret, setup = 0;



    if (!swr_is_initialized(s)) {

        if ((ret = swr_config_frame(s, out, in)) < 0)

            return ret;

        if ((ret = swr_init(s)) < 0)

            return ret;

        setup = 1;

    } else {

        

        if ((ret = config_changed(s, out, in)))

            return ret;

    }



    if (out) {

        if (!out->linesize[0]) {

            out->nb_samples =   swr_get_delay(s, s->out_sample_rate)

                              + in->nb_samples*(int64_t)s->out_sample_rate / s->in_sample_rate

                              + 3;

            if ((ret = av_frame_get_buffer(out, 0)) < 0) {

                if (setup)

                    swr_close(s);

                return ret;

            }

        } else {

            if (!out->nb_samples)

                out->nb_samples = available_samples(out);

        }

    }



    return convert_frame(s, out, in);

}

            out->nb_samples =   swr_get_delay(s, s->out_sample_rate)                               + in->nb_samples*(int64_t)s->out_sample_rate / s->in_sample_rate                               + 3;
int FUNC_0(SwrContext *VAR_0,

                      AVFrame *VAR_1, const AVFrame *VAR_2)

{

    int VAR_3, VAR_4 = 0;



    if (!swr_is_initialized(VAR_0)) {

        if ((VAR_3 = swr_config_frame(VAR_0, VAR_1, VAR_2)) < 0)

            return VAR_3;

        if ((VAR_3 = swr_init(VAR_0)) < 0)

            return VAR_3;

        VAR_4 = 1;

    } else {

        

        if ((VAR_3 = config_changed(VAR_0, VAR_1, VAR_2)))

            return VAR_3;

    }



    if (VAR_1) {

        if (!VAR_1->linesize[0]) {

            VAR_1->nb_samples =   swr_get_delay(VAR_0, VAR_0->out_sample_rate)

                              + VAR_2->nb_samples*(int64_t)VAR_0->out_sample_rate / VAR_0->in_sample_rate

                              + 3;

            if ((VAR_3 = av_frame_get_buffer(VAR_1, 0)) < 0) {

                if (VAR_4)

                    swr_close(VAR_0);

                return VAR_3;

            }

        } else {

            if (!VAR_1->nb_samples)

                VAR_1->nb_samples = available_samples(VAR_1);

        }

    }



    return convert_frame(VAR_0, VAR_1, VAR_2);

}

int FUNC_0(SwrContext *VAR_0,
AVFrame *VAR_1, const AVFrame *VAR_2)
{ int VAR_3, VAR_4 = 0; if (!swr_is_initialized(VAR_0)) { if ((VAR_3 = swr_config_frame(VAR_0, VAR_1, VAR_2)) < 0)
return VAR_3; if ((VAR_3 = swr_init(VAR_0)) < 0)
return VAR_3; VAR_4 = 1; } else { if ((VAR_3 = config_changed(VAR_0, VAR_1, VAR_2)))
return VAR_3; } if (VAR_1) { if (!VAR_1->linesize[0]) { VAR_1->nb_samples =   swr_get_delay(VAR_0, VAR_0->out_sample_rate)
+ VAR_2->nb_samples*(int64_t)VAR_0->out_sample_rate / VAR_0->in_sample_rate
+ 3; if ((VAR_3 = av_frame_get_buffer(VAR_1, 0)) < 0) { if (VAR_4)
swr_close(VAR_0); return VAR_3; } } else { if (!VAR_1->nb_samples)
VAR_1->nb_samples = available_samples(VAR_1); } } return convert_frame(VAR_0, VAR_1, VAR_2); }