static int filter_frame(AVFilterLink *inlink, AVFrame *insamples)

{

    AVFilterContext *ctx = inlink->dst;

    AVFilterLink *outlink = ctx->outputs[0];

    ShowCQTContext *s = ctx->priv;

    int remaining, step, ret, x, i, j, m;

    float *audio_data;

    AVFrame *out = NULL;



    if (!insamples) {

        while (s->remaining_fill < s->fft_len / 2) {

            memset(&s->fft_data[s->fft_len - s->remaining_fill], 0, sizeof(*s->fft_data) * s->remaining_fill);

            ret = plot_cqt(ctx, &out);

            if (ret < 0)

                return ret;



            step = s->step + (s->step_frac.num + s->remaining_frac) / s->step_frac.den;

            s->remaining_frac = (s->step_frac.num + s->remaining_frac) % s->step_frac.den;

            for (x = 0; x < (s->fft_len-step); x++)

                s->fft_data[x] = s->fft_data[x+step];

            s->remaining_fill += step;



            if (out)

                return ff_filter_frame(outlink, out);

        }

        return AVERROR_EOF;

    }



    remaining = insamples->nb_samples;

    audio_data = (float*) insamples->data[0];



    while (remaining) {

        i = insamples->nb_samples - remaining;

        j = s->fft_len - s->remaining_fill;

        if (remaining >= s->remaining_fill) {

            for (m = 0; m < s->remaining_fill; m++) {

                s->fft_data[j+m].re = audio_data[2*(i+m)];

                s->fft_data[j+m].im = audio_data[2*(i+m)+1];

            }

            ret = plot_cqt(ctx, &out);

            if (ret < 0) {

                av_frame_free(&insamples);

                return ret;

            }

            remaining -= s->remaining_fill;

            if (out) {

                int64_t pts = av_rescale_q(insamples->pts, inlink->time_base, av_make_q(1, inlink->sample_rate));

                pts += insamples->nb_samples - remaining - s->fft_len/2;

                pts = av_rescale_q(pts, av_make_q(1, inlink->sample_rate), outlink->time_base);

                if (FFABS(pts - out->pts) > PTS_TOLERANCE) {

                    av_log(ctx, AV_LOG_DEBUG, "changing pts from %"PRId64" (%.3f) to %"PRId64" (%.3f).\n",

                           out->pts, out->pts * av_q2d(outlink->time_base),

                           pts, pts * av_q2d(outlink->time_base));

                    out->pts = pts;

                    s->next_pts = pts + PTS_STEP;

                }

                ret = ff_filter_frame(outlink, out);

                if (ret < 0) {

                    av_frame_free(&insamples);

                    return ret;

                }

                out = NULL;

            }

            step = s->step + (s->step_frac.num + s->remaining_frac) / s->step_frac.den;

            s->remaining_frac = (s->step_frac.num + s->remaining_frac) % s->step_frac.den;

            for (m = 0; m < s->fft_len-step; m++)

                s->fft_data[m] = s->fft_data[m+step];

            s->remaining_fill = step;

        } else {

            for (m = 0; m < remaining; m++) {

                s->fft_data[j+m].re = audio_data[2*(i+m)];

                s->fft_data[j+m].im = audio_data[2*(i+m)+1];

            }

            s->remaining_fill -= remaining;

            remaining = 0;

        }

    }

    av_frame_free(&insamples);

    return 0;

}

static int filter_frame(AVFilterLink *inlink, AVFrame *insamples)

{

    AVFilterContext *ctx = inlink->dst;

    AVFilterLink *outlink = ctx->outputs[0];

    ShowCQTContext *s = ctx->priv;

    int remaining, step, ret, x, i, j, m;

    float *audio_data;

    AVFrame *out = NULL;



    if (!insamples) {

        while (s->remaining_fill < s->fft_len / 2) {

            memset(&s->fft_data[s->fft_len - s->remaining_fill], 0, sizeof(*s->fft_data) * s->remaining_fill);

            ret = plot_cqt(ctx, &out);

            if (ret < 0)

                return ret;



            step = s->step + (s->step_frac.num + s->remaining_frac) / s->step_frac.den;

            s->remaining_frac = (s->step_frac.num + s->remaining_frac) % s->step_frac.den;

            for (x = 0; x < (s->fft_len-step); x++)

                s->fft_data[x] = s->fft_data[x+step];

            s->remaining_fill += step;



            if (out)

                return ff_filter_frame(outlink, out);

        }

        return AVERROR_EOF;

    }



    remaining = insamples->nb_samples;

    audio_data = (float*) insamples->data[0];



    while (remaining) {

        i = insamples->nb_samples - remaining;

        j = s->fft_len - s->remaining_fill;

        if (remaining >= s->remaining_fill) {

            for (m = 0; m < s->remaining_fill; m++) {

                s->fft_data[j+m].re = audio_data[2*(i+m)];

                s->fft_data[j+m].im = audio_data[2*(i+m)+1];

            }

            ret = plot_cqt(ctx, &out);

            if (ret < 0) {

                av_frame_free(&insamples);

                return ret;

            }

            remaining -= s->remaining_fill;

            if (out) {

                int64_t pts = av_rescale_q(insamples->pts, inlink->time_base, av_make_q(1, inlink->sample_rate));

                pts += insamples->nb_samples - remaining - s->fft_len/2;

                pts = av_rescale_q(pts, av_make_q(1, inlink->sample_rate), outlink->time_base);

                if (FFABS(pts - out->pts) > PTS_TOLERANCE) {

                    av_log(ctx, AV_LOG_DEBUG, "changing pts from %"PRId64" (%.3f) to %"PRId64" (%.3f).\n",

                           out->pts, out->pts * av_q2d(outlink->time_base),

                           pts, pts * av_q2d(outlink->time_base));

                    out->pts = pts;

                    s->next_pts = pts + PTS_STEP;

                }

                ret = ff_filter_frame(outlink, out);

                if (ret < 0) {

                    av_frame_free(&insamples);

                    return ret;

                }

                out = NULL;

            }

            step = s->step + (s->step_frac.num + s->remaining_frac) / s->step_frac.den;

            s->remaining_frac = (s->step_frac.num + s->remaining_frac) % s->step_frac.den;

            for (m = 0; m < s->fft_len-step; m++)

                s->fft_data[m] = s->fft_data[m+step];

            s->remaining_fill = step;

        } else {

            for (m = 0; m < remaining; m++) {

                s->fft_data[j+m].re = audio_data[2*(i+m)];

                s->fft_data[j+m].im = audio_data[2*(i+m)+1];

            }

            s->remaining_fill -= remaining;

            remaining = 0;

        }

    }

    av_frame_free(&insamples);

    return 0;

}

        while (s->remaining_fill < s->fft_len / 2) {             memset(&s->fft_data[s->fft_len - s->remaining_fill], 0, sizeof(*s->fft_data) * s->remaining_fill);             for (x = 0; x < (s->fft_len-step); x++)         j = s->fft_len - s->remaining_fill;                 pts += insamples->nb_samples - remaining - s->fft_len/2;             for (m = 0; m < s->fft_len-step; m++)
static int FUNC_0(AVFilterLink *VAR_0, AVFrame *VAR_1)

{

    AVFilterContext *ctx = VAR_0->dst;

    AVFilterLink *outlink = ctx->outputs[0];

    ShowCQTContext *s = ctx->priv;

    int VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8;

    float *VAR_9;

    AVFrame *out = NULL;



    if (!VAR_1) {

        while (s->remaining_fill < s->fft_len / 2) {

            memset(&s->fft_data[s->fft_len - s->remaining_fill], 0, sizeof(*s->fft_data) * s->remaining_fill);

            VAR_4 = plot_cqt(ctx, &out);

            if (VAR_4 < 0)

                return VAR_4;



            VAR_3 = s->VAR_3 + (s->step_frac.num + s->remaining_frac) / s->step_frac.den;

            s->remaining_frac = (s->step_frac.num + s->remaining_frac) % s->step_frac.den;

            for (VAR_5 = 0; VAR_5 < (s->fft_len-VAR_3); VAR_5++)

                s->fft_data[VAR_5] = s->fft_data[VAR_5+VAR_3];

            s->remaining_fill += VAR_3;



            if (out)

                return ff_filter_frame(outlink, out);

        }

        return AVERROR_EOF;

    }



    VAR_2 = VAR_1->nb_samples;

    VAR_9 = (float*) VAR_1->data[0];



    while (VAR_2) {

        VAR_6 = VAR_1->nb_samples - VAR_2;

        VAR_7 = s->fft_len - s->remaining_fill;

        if (VAR_2 >= s->remaining_fill) {

            for (VAR_8 = 0; VAR_8 < s->remaining_fill; VAR_8++) {

                s->fft_data[VAR_7+VAR_8].re = VAR_9[2*(VAR_6+VAR_8)];

                s->fft_data[VAR_7+VAR_8].im = VAR_9[2*(VAR_6+VAR_8)+1];

            }

            VAR_4 = plot_cqt(ctx, &out);

            if (VAR_4 < 0) {

                av_frame_free(&VAR_1);

                return VAR_4;

            }

            VAR_2 -= s->remaining_fill;

            if (out) {

                int64_t pts = av_rescale_q(VAR_1->pts, VAR_0->time_base, av_make_q(1, VAR_0->sample_rate));

                pts += VAR_1->nb_samples - VAR_2 - s->fft_len/2;

                pts = av_rescale_q(pts, av_make_q(1, VAR_0->sample_rate), outlink->time_base);

                if (FFABS(pts - out->pts) > PTS_TOLERANCE) {

                    av_log(ctx, AV_LOG_DEBUG, "changing pts from %"PRId64" (%.3f) to %"PRId64" (%.3f).\n",

                           out->pts, out->pts * av_q2d(outlink->time_base),

                           pts, pts * av_q2d(outlink->time_base));

                    out->pts = pts;

                    s->next_pts = pts + PTS_STEP;

                }

                VAR_4 = ff_filter_frame(outlink, out);

                if (VAR_4 < 0) {

                    av_frame_free(&VAR_1);

                    return VAR_4;

                }

                out = NULL;

            }

            VAR_3 = s->VAR_3 + (s->step_frac.num + s->remaining_frac) / s->step_frac.den;

            s->remaining_frac = (s->step_frac.num + s->remaining_frac) % s->step_frac.den;

            for (VAR_8 = 0; VAR_8 < s->fft_len-VAR_3; VAR_8++)

                s->fft_data[VAR_8] = s->fft_data[VAR_8+VAR_3];

            s->remaining_fill = VAR_3;

        } else {

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

                s->fft_data[VAR_7+VAR_8].re = VAR_9[2*(VAR_6+VAR_8)];

                s->fft_data[VAR_7+VAR_8].im = VAR_9[2*(VAR_6+VAR_8)+1];

            }

            s->remaining_fill -= VAR_2;

            VAR_2 = 0;

        }

    }

    av_frame_free(&VAR_1);

    return 0;

}

static int FUNC_0(AVFilterLink *VAR_0, AVFrame *VAR_1)
{ AVFilterContext *ctx = VAR_0->dst; AVFilterLink *outlink = ctx->outputs[0]; ShowCQTContext *s = ctx->priv; int VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8; float *VAR_9; AVFrame *out = NULL; if (!VAR_1) { while (s->remaining_fill < s->fft_len / 2) { memset(&s->fft_data[s->fft_len - s->remaining_fill], 0, sizeof(*s->fft_data) * s->remaining_fill); VAR_4 = plot_cqt(ctx, &out); if (VAR_4 < 0)
return VAR_4; VAR_3 = s->VAR_3 + (s->step_frac.num + s->remaining_frac) / s->step_frac.den; s->remaining_frac = (s->step_frac.num + s->remaining_frac) % s->step_frac.den; for (VAR_5 = 0; VAR_5 < (s->fft_len-VAR_3); VAR_5++) s->fft_data[VAR_5] = s->fft_data[VAR_5+VAR_3]; s->remaining_fill += VAR_3; if (out)
return ff_filter_frame(outlink, out); } return AVERROR_EOF; } VAR_2 = VAR_1->nb_samples; VAR_9 = (float*) VAR_1->data[0]; while (VAR_2) { VAR_6 = VAR_1->nb_samples - VAR_2; VAR_7 = s->fft_len - s->remaining_fill; if (VAR_2 >= s->remaining_fill) { for (VAR_8 = 0; VAR_8 < s->remaining_fill; VAR_8++) { s->fft_data[VAR_7+VAR_8].re = VAR_9[2*(VAR_6+VAR_8)]; s->fft_data[VAR_7+VAR_8].im = VAR_9[2*(VAR_6+VAR_8)+1]; } VAR_4 = plot_cqt(ctx, &out); if (VAR_4 < 0) { av_frame_free(&VAR_1); return VAR_4; } VAR_2 -= s->remaining_fill; if (out) { int64_t pts = av_rescale_q(VAR_1->pts, VAR_0->time_base, av_make_q(1, VAR_0->sample_rate)); pts += VAR_1->nb_samples - VAR_2 - s->fft_len/2; pts = av_rescale_q(pts, av_make_q(1, VAR_0->sample_rate), outlink->time_base); if (FFABS(pts - out->pts) > PTS_TOLERANCE) { av_log(ctx, AV_LOG_DEBUG, "changing pts from %"PRId64" (%.3f) to %"PRId64" (%.3f).\n",
out->pts, out->pts * av_q2d(outlink->time_base),
pts, pts * av_q2d(outlink->time_base)); out->pts = pts; s->next_pts = pts + PTS_STEP; } VAR_4 = ff_filter_frame(outlink, out); if (VAR_4 < 0) { av_frame_free(&VAR_1); return VAR_4; } out = NULL; } VAR_3 = s->VAR_3 + (s->step_frac.num + s->remaining_frac) / s->step_frac.den; s->remaining_frac = (s->step_frac.num + s->remaining_frac) % s->step_frac.den; for (VAR_8 = 0; VAR_8 < s->fft_len-VAR_3; VAR_8++) s->fft_data[VAR_8] = s->fft_data[VAR_8+VAR_3]; s->remaining_fill = VAR_3; } else { for (VAR_8 = 0; VAR_8 < VAR_2; VAR_8++) { s->fft_data[VAR_7+VAR_8].re = VAR_9[2*(VAR_6+VAR_8)]; s->fft_data[VAR_7+VAR_8].im = VAR_9[2*(VAR_6+VAR_8)+1]; } s->remaining_fill -= VAR_2; VAR_2 = 0; } } av_frame_free(&VAR_1); return 0; }