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

{

    AVFilterContext *ctx = inlink->dst;

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

    ShowWavesContext *showwaves = ctx->priv;

    const int nb_samples = insamples->audio->nb_samples;

    AVFilterBufferRef *outpicref = showwaves->outpicref;

    int linesize = outpicref ? outpicref->linesize[0] : 0;

    int16_t *p = (int16_t *)insamples->data[0];

    int nb_channels = av_get_channel_layout_nb_channels(insamples->audio->channel_layout);

    int i, j, h;

    const int n = showwaves->n;

    const int x = 255 / (nb_channels * n); /* multiplication factor, pre-computed to avoid in-loop divisions */



    /* draw data in the buffer */

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

        if (!outpicref) {

            showwaves->outpicref = outpicref =

                ff_get_video_buffer(outlink, AV_PERM_WRITE|AV_PERM_ALIGN,

                                    outlink->w, outlink->h);

            if (!outpicref)

                return AVERROR(ENOMEM);

            outpicref->video->w = outlink->w;

            outpicref->video->h = outlink->h;

            outpicref->pts = insamples->pts +

                             av_rescale_q((p - (int16_t *)insamples->data[0]) / nb_channels,

                                          (AVRational){ 1, inlink->sample_rate },

                                          outlink->time_base);

            linesize = outpicref->linesize[0];

            memset(outpicref->data[0], 0, showwaves->h*linesize);

        }

        for (j = 0; j < nb_channels; j++) {

            h = showwaves->h/2 - av_rescale(*p++, showwaves->h/2, MAX_INT16);

            if (h >= 0 && h < outlink->h)

                *(outpicref->data[0] + showwaves->buf_idx + h * linesize) += x;

        }

        showwaves->sample_count_mod++;

        if (showwaves->sample_count_mod == n) {

            showwaves->sample_count_mod = 0;

            showwaves->buf_idx++;

        }

        if (showwaves->buf_idx == showwaves->w)

            push_frame(outlink);

        outpicref = showwaves->outpicref;

    }



    avfilter_unref_buffer(insamples);

    return 0;

}

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

{

    AVFilterContext *ctx = inlink->dst;

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

    ShowWavesContext *showwaves = ctx->priv;

    const int nb_samples = insamples->audio->nb_samples;

    AVFilterBufferRef *outpicref = showwaves->outpicref;

    int linesize = outpicref ? outpicref->linesize[0] : 0;

    int16_t *p = (int16_t *)insamples->data[0];

    int nb_channels = av_get_channel_layout_nb_channels(insamples->audio->channel_layout);

    int i, j, h;

    const int n = showwaves->n;

    const int x = 255 / (nb_channels * n); 



    

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

        if (!outpicref) {

            showwaves->outpicref = outpicref =

                ff_get_video_buffer(outlink, AV_PERM_WRITE|AV_PERM_ALIGN,

                                    outlink->w, outlink->h);

            if (!outpicref)

                return AVERROR(ENOMEM);

            outpicref->video->w = outlink->w;

            outpicref->video->h = outlink->h;

            outpicref->pts = insamples->pts +

                             av_rescale_q((p - (int16_t *)insamples->data[0]) / nb_channels,

                                          (AVRational){ 1, inlink->sample_rate },

                                          outlink->time_base);

            linesize = outpicref->linesize[0];

            memset(outpicref->data[0], 0, showwaves->h*linesize);

        }

        for (j = 0; j < nb_channels; j++) {

            h = showwaves->h/2 - av_rescale(*p++, showwaves->h/2, MAX_INT16);

            if (h >= 0 && h < outlink->h)

                *(outpicref->data[0] + showwaves->buf_idx + h * linesize) += x;

        }

        showwaves->sample_count_mod++;

        if (showwaves->sample_count_mod == n) {

            showwaves->sample_count_mod = 0;

            showwaves->buf_idx++;

        }

        if (showwaves->buf_idx == showwaves->w)

            push_frame(outlink);

        outpicref = showwaves->outpicref;

    }



    avfilter_unref_buffer(insamples);

    return 0;

}

static int FUNC_0(AVFilterLink *VAR_0, AVFilterBufferRef *VAR_1)

{

    AVFilterContext *ctx = VAR_0->dst;

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

    ShowWavesContext *showwaves = ctx->priv;

    const int VAR_2 = VAR_1->audio->VAR_2;

    AVFilterBufferRef *outpicref = showwaves->outpicref;

    int VAR_3 = outpicref ? outpicref->VAR_3[0] : 0;

    int16_t *p = (int16_t *)VAR_1->data[0];

    int VAR_4 = av_get_channel_layout_nb_channels(VAR_1->audio->channel_layout);

    int VAR_5, VAR_6, VAR_7;

    const int VAR_8 = showwaves->VAR_8;

    const int VAR_9 = 255 / (VAR_4 * VAR_8); 



    

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

        if (!outpicref) {

            showwaves->outpicref = outpicref =

                ff_get_video_buffer(outlink, AV_PERM_WRITE|AV_PERM_ALIGN,

                                    outlink->w, outlink->VAR_7);

            if (!outpicref)

                return AVERROR(ENOMEM);

            outpicref->video->w = outlink->w;

            outpicref->video->VAR_7 = outlink->VAR_7;

            outpicref->pts = VAR_1->pts +

                             av_rescale_q((p - (int16_t *)VAR_1->data[0]) / VAR_4,

                                          (AVRational){ 1, VAR_0->sample_rate },

                                          outlink->time_base);

            VAR_3 = outpicref->VAR_3[0];

            memset(outpicref->data[0], 0, showwaves->VAR_7*VAR_3);

        }

        for (VAR_6 = 0; VAR_6 < VAR_4; VAR_6++) {

            VAR_7 = showwaves->VAR_7/2 - av_rescale(*p++, showwaves->VAR_7/2, MAX_INT16);

            if (VAR_7 >= 0 && VAR_7 < outlink->VAR_7)

                *(outpicref->data[0] + showwaves->buf_idx + VAR_7 * VAR_3) += VAR_9;

        }

        showwaves->sample_count_mod++;

        if (showwaves->sample_count_mod == VAR_8) {

            showwaves->sample_count_mod = 0;

            showwaves->buf_idx++;

        }

        if (showwaves->buf_idx == showwaves->w)

            push_frame(outlink);

        outpicref = showwaves->outpicref;

    }



    avfilter_unref_buffer(VAR_1);

    return 0;

}

static int FUNC_0(AVFilterLink *VAR_0, AVFilterBufferRef *VAR_1)
{ AVFilterContext *ctx = VAR_0->dst; AVFilterLink *outlink = ctx->outputs[0]; ShowWavesContext *showwaves = ctx->priv; const int VAR_2 = VAR_1->audio->VAR_2; AVFilterBufferRef *outpicref = showwaves->outpicref; int VAR_3 = outpicref ? outpicref->VAR_3[0] : 0; int16_t *p = (int16_t *)VAR_1->data[0]; int VAR_4 = av_get_channel_layout_nb_channels(VAR_1->audio->channel_layout); int VAR_5, VAR_6, VAR_7; const int VAR_8 = showwaves->VAR_8; const int VAR_9 = 255 / (VAR_4 * VAR_8); for (VAR_5 = 0; VAR_5 < VAR_2; VAR_5++) { if (!outpicref) { showwaves->outpicref = outpicref =
ff_get_video_buffer(outlink, AV_PERM_WRITE|AV_PERM_ALIGN,
outlink->w, outlink->VAR_7); if (!outpicref)
return AVERROR(ENOMEM); outpicref->video->w = outlink->w; outpicref->video->VAR_7 = outlink->VAR_7; outpicref->pts = VAR_1->pts +
av_rescale_q((p - (int16_t *)VAR_1->data[0]) / VAR_4,
(AVRational){ 1, VAR_0->sample_rate }, outlink->time_base); VAR_3 = outpicref->VAR_3[0]; memset(outpicref->data[0], 0, showwaves->VAR_7*VAR_3); } for (VAR_6 = 0; VAR_6 < VAR_4; VAR_6++) { VAR_7 = showwaves->VAR_7/2 - av_rescale(*p++, showwaves->VAR_7/2, MAX_INT16); if (VAR_7 >= 0 && VAR_7 < outlink->VAR_7)
*(outpicref->data[0] + showwaves->buf_idx + VAR_7 * VAR_3) += VAR_9; } showwaves->sample_count_mod++; if (showwaves->sample_count_mod == VAR_8) { showwaves->sample_count_mod = 0; showwaves->buf_idx++; } if (showwaves->buf_idx == showwaves->w)
push_frame(outlink); outpicref = showwaves->outpicref; } avfilter_unref_buffer(VAR_1); return 0; }