static int output_frame(AVFilterLink *outlink, int need_request)

{

    AVFilterContext *ctx = outlink->src;

    MixContext      *s = ctx->priv;

    AVFrame *out_buf, *in_buf;

    int nb_samples, ns, ret, i;



    ret = calc_active_inputs(s);

    if (ret < 0)

        return ret;



    if (s->input_state[0] & INPUT_ON) {

        /* first input live: use the corresponding frame size */

        nb_samples = frame_list_next_frame_size(s->frame_list);

        for (i = 1; i < s->nb_inputs; i++) {

            if (s->input_state[i] & INPUT_ON) {

                ns = av_audio_fifo_size(s->fifos[i]);

                if (ns < nb_samples) {

                    if (!(s->input_state[i] & INPUT_EOF))

                        /* unclosed input with not enough samples */

                        return need_request ? ff_request_frame(ctx->inputs[i]) : 0;

                    /* closed input to drain */

                    nb_samples = ns;

                }

            }

        }

    } else {

        /* first input closed: use the available samples */

        nb_samples = INT_MAX;

        for (i = 1; i < s->nb_inputs; i++) {

            if (s->input_state[i] & INPUT_ON) {

                ns = av_audio_fifo_size(s->fifos[i]);

                nb_samples = FFMIN(nb_samples, ns);

            }

        }

        if (nb_samples == INT_MAX)

            return AVERROR_EOF;

    }



    s->next_pts = frame_list_next_pts(s->frame_list);

    frame_list_remove_samples(s->frame_list, nb_samples);



    calculate_scales(s, nb_samples);



    if (nb_samples == 0)

        return 0;



    out_buf = ff_get_audio_buffer(outlink, nb_samples);

    if (!out_buf)

        return AVERROR(ENOMEM);



    in_buf = ff_get_audio_buffer(outlink, nb_samples);

    if (!in_buf) {

        av_frame_free(&out_buf);

        return AVERROR(ENOMEM);

    }



    for (i = 0; i < s->nb_inputs; i++) {

        if (s->input_state[i] & INPUT_ON) {

            int planes, plane_size, p;



            av_audio_fifo_read(s->fifos[i], (void **)in_buf->extended_data,

                               nb_samples);



            planes     = s->planar ? s->nb_channels : 1;

            plane_size = nb_samples * (s->planar ? 1 : s->nb_channels);

            plane_size = FFALIGN(plane_size, 16);



            if (out_buf->format == AV_SAMPLE_FMT_FLT ||

                out_buf->format == AV_SAMPLE_FMT_FLTP) {

                for (p = 0; p < planes; p++) {

                    s->fdsp->vector_fmac_scalar((float *)out_buf->extended_data[p],

                                                (float *) in_buf->extended_data[p],

                                                s->input_scale[i], plane_size);

                }

            } else {

                for (p = 0; p < planes; p++) {

                    s->fdsp->vector_dmac_scalar((double *)out_buf->extended_data[p],

                                                (double *) in_buf->extended_data[p],

                                                s->input_scale[i], plane_size);

                }

            }

        }

    }

    av_frame_free(&in_buf);



    out_buf->pts = s->next_pts;

    if (s->next_pts != AV_NOPTS_VALUE)

        s->next_pts += nb_samples;



    return ff_filter_frame(outlink, out_buf);

}

static int output_frame(AVFilterLink *outlink, int need_request)

{

    AVFilterContext *ctx = outlink->src;

    MixContext      *s = ctx->priv;

    AVFrame *out_buf, *in_buf;

    int nb_samples, ns, ret, i;



    ret = calc_active_inputs(s);

    if (ret < 0)

        return ret;



    if (s->input_state[0] & INPUT_ON) {

        

        nb_samples = frame_list_next_frame_size(s->frame_list);

        for (i = 1; i < s->nb_inputs; i++) {

            if (s->input_state[i] & INPUT_ON) {

                ns = av_audio_fifo_size(s->fifos[i]);

                if (ns < nb_samples) {

                    if (!(s->input_state[i] & INPUT_EOF))

                        

                        return need_request ? ff_request_frame(ctx->inputs[i]) : 0;

                    

                    nb_samples = ns;

                }

            }

        }

    } else {

        

        nb_samples = INT_MAX;

        for (i = 1; i < s->nb_inputs; i++) {

            if (s->input_state[i] & INPUT_ON) {

                ns = av_audio_fifo_size(s->fifos[i]);

                nb_samples = FFMIN(nb_samples, ns);

            }

        }

        if (nb_samples == INT_MAX)

            return AVERROR_EOF;

    }



    s->next_pts = frame_list_next_pts(s->frame_list);

    frame_list_remove_samples(s->frame_list, nb_samples);



    calculate_scales(s, nb_samples);



    if (nb_samples == 0)

        return 0;



    out_buf = ff_get_audio_buffer(outlink, nb_samples);

    if (!out_buf)

        return AVERROR(ENOMEM);



    in_buf = ff_get_audio_buffer(outlink, nb_samples);

    if (!in_buf) {

        av_frame_free(&out_buf);

        return AVERROR(ENOMEM);

    }



    for (i = 0; i < s->nb_inputs; i++) {

        if (s->input_state[i] & INPUT_ON) {

            int planes, plane_size, p;



            av_audio_fifo_read(s->fifos[i], (void **)in_buf->extended_data,

                               nb_samples);



            planes     = s->planar ? s->nb_channels : 1;

            plane_size = nb_samples * (s->planar ? 1 : s->nb_channels);

            plane_size = FFALIGN(plane_size, 16);



            if (out_buf->format == AV_SAMPLE_FMT_FLT ||

                out_buf->format == AV_SAMPLE_FMT_FLTP) {

                for (p = 0; p < planes; p++) {

                    s->fdsp->vector_fmac_scalar((float *)out_buf->extended_data[p],

                                                (float *) in_buf->extended_data[p],

                                                s->input_scale[i], plane_size);

                }

            } else {

                for (p = 0; p < planes; p++) {

                    s->fdsp->vector_dmac_scalar((double *)out_buf->extended_data[p],

                                                (double *) in_buf->extended_data[p],

                                                s->input_scale[i], plane_size);

                }

            }

        }

    }

    av_frame_free(&in_buf);



    out_buf->pts = s->next_pts;

    if (s->next_pts != AV_NOPTS_VALUE)

        s->next_pts += nb_samples;



    return ff_filter_frame(outlink, out_buf);

}

static int FUNC_0(AVFilterLink *VAR_0, int VAR_1)

{

    AVFilterContext *ctx = VAR_0->src;

    MixContext      *s = ctx->priv;

    AVFrame *out_buf, *in_buf;

    int VAR_2, VAR_3, VAR_4, VAR_5;



    VAR_4 = calc_active_inputs(s);

    if (VAR_4 < 0)

        return VAR_4;



    if (s->input_state[0] & INPUT_ON) {

        

        VAR_2 = frame_list_next_frame_size(s->frame_list);

        for (VAR_5 = 1; VAR_5 < s->nb_inputs; VAR_5++) {

            if (s->input_state[VAR_5] & INPUT_ON) {

                VAR_3 = av_audio_fifo_size(s->fifos[VAR_5]);

                if (VAR_3 < VAR_2) {

                    if (!(s->input_state[VAR_5] & INPUT_EOF))

                        

                        return VAR_1 ? ff_request_frame(ctx->inputs[VAR_5]) : 0;

                    

                    VAR_2 = VAR_3;

                }

            }

        }

    } else {

        

        VAR_2 = INT_MAX;

        for (VAR_5 = 1; VAR_5 < s->nb_inputs; VAR_5++) {

            if (s->input_state[VAR_5] & INPUT_ON) {

                VAR_3 = av_audio_fifo_size(s->fifos[VAR_5]);

                VAR_2 = FFMIN(VAR_2, VAR_3);

            }

        }

        if (VAR_2 == INT_MAX)

            return AVERROR_EOF;

    }



    s->next_pts = frame_list_next_pts(s->frame_list);

    frame_list_remove_samples(s->frame_list, VAR_2);



    calculate_scales(s, VAR_2);



    if (VAR_2 == 0)

        return 0;



    out_buf = ff_get_audio_buffer(VAR_0, VAR_2);

    if (!out_buf)

        return AVERROR(ENOMEM);



    in_buf = ff_get_audio_buffer(VAR_0, VAR_2);

    if (!in_buf) {

        av_frame_free(&out_buf);

        return AVERROR(ENOMEM);

    }



    for (VAR_5 = 0; VAR_5 < s->nb_inputs; VAR_5++) {

        if (s->input_state[VAR_5] & INPUT_ON) {

            int planes, plane_size, p;



            av_audio_fifo_read(s->fifos[VAR_5], (void **)in_buf->extended_data,

                               VAR_2);



            planes     = s->planar ? s->nb_channels : 1;

            plane_size = VAR_2 * (s->planar ? 1 : s->nb_channels);

            plane_size = FFALIGN(plane_size, 16);



            if (out_buf->format == AV_SAMPLE_FMT_FLT ||

                out_buf->format == AV_SAMPLE_FMT_FLTP) {

                for (p = 0; p < planes; p++) {

                    s->fdsp->vector_fmac_scalar((float *)out_buf->extended_data[p],

                                                (float *) in_buf->extended_data[p],

                                                s->input_scale[VAR_5], plane_size);

                }

            } else {

                for (p = 0; p < planes; p++) {

                    s->fdsp->vector_dmac_scalar((double *)out_buf->extended_data[p],

                                                (double *) in_buf->extended_data[p],

                                                s->input_scale[VAR_5], plane_size);

                }

            }

        }

    }

    av_frame_free(&in_buf);



    out_buf->pts = s->next_pts;

    if (s->next_pts != AV_NOPTS_VALUE)

        s->next_pts += VAR_2;



    return ff_filter_frame(VAR_0, out_buf);

}

static int FUNC_0(AVFilterLink *VAR_0, int VAR_1)
{ AVFilterContext *ctx = VAR_0->src; MixContext      *s = ctx->priv; AVFrame *out_buf, *in_buf; int VAR_2, VAR_3, VAR_4, VAR_5; VAR_4 = calc_active_inputs(s); if (VAR_4 < 0)
return VAR_4; if (s->input_state[0] & INPUT_ON) { VAR_2 = frame_list_next_frame_size(s->frame_list); for (VAR_5 = 1; VAR_5 < s->nb_inputs; VAR_5++) { if (s->input_state[VAR_5] & INPUT_ON) { VAR_3 = av_audio_fifo_size(s->fifos[VAR_5]); if (VAR_3 < VAR_2) { if (!(s->input_state[VAR_5] & INPUT_EOF))
return VAR_1 ? ff_request_frame(ctx->inputs[VAR_5]) : 0; VAR_2 = VAR_3; } } } } else { VAR_2 = INT_MAX; for (VAR_5 = 1; VAR_5 < s->nb_inputs; VAR_5++) { if (s->input_state[VAR_5] & INPUT_ON) { VAR_3 = av_audio_fifo_size(s->fifos[VAR_5]); VAR_2 = FFMIN(VAR_2, VAR_3); } } if (VAR_2 == INT_MAX)
return AVERROR_EOF; } s->next_pts = frame_list_next_pts(s->frame_list); frame_list_remove_samples(s->frame_list, VAR_2); calculate_scales(s, VAR_2); if (VAR_2 == 0)
return 0; out_buf = ff_get_audio_buffer(VAR_0, VAR_2); if (!out_buf)
return AVERROR(ENOMEM); in_buf = ff_get_audio_buffer(VAR_0, VAR_2); if (!in_buf) { av_frame_free(&out_buf); return AVERROR(ENOMEM); } for (VAR_5 = 0; VAR_5 < s->nb_inputs; VAR_5++) { if (s->input_state[VAR_5] & INPUT_ON) { int planes, plane_size, p; av_audio_fifo_read(s->fifos[VAR_5], (void **)in_buf->extended_data,
VAR_2); planes     = s->planar ? s->nb_channels : 1; plane_size = VAR_2 * (s->planar ? 1 : s->nb_channels); plane_size = FFALIGN(plane_size, 16); if (out_buf->format == AV_SAMPLE_FMT_FLT ||
out_buf->format == AV_SAMPLE_FMT_FLTP) { for (p = 0; p < planes; p++) { s->fdsp->vector_fmac_scalar((float *)out_buf->extended_data[p],
(float *) in_buf->extended_data[p],
s->input_scale[VAR_5], plane_size); } } else { for (p = 0; p < planes; p++) { s->fdsp->vector_dmac_scalar((double *)out_buf->extended_data[p],
(double *) in_buf->extended_data[p],
s->input_scale[VAR_5], plane_size); } } } } av_frame_free(&in_buf); out_buf->pts = s->next_pts; if (s->next_pts != AV_NOPTS_VALUE)
s->next_pts += VAR_2; return ff_filter_frame(VAR_0, out_buf); }