static int push_single_pic(AVFilterLink *outlink)
{
    AVFilterContext *ctx = outlink->src;
    AVFilterLink *inlink = ctx->inputs[0];
    ShowWavesContext *showwaves = ctx->priv;
    int64_t n = 0, max_samples = showwaves->total_samples / outlink->w;
    AVFrame *out = showwaves->outpicref;
    struct frame_node *node;
    const int nb_channels = inlink->channels;
    const int x = 255 / (showwaves->split_channels ? 1 : nb_channels);
    const int ch_height = showwaves->split_channels ? outlink->h / nb_channels : outlink->h;
    const int linesize = out->linesize[0];
    int col = 0;
    int64_t *sum = showwaves->sum;
    av_log(ctx, AV_LOG_DEBUG, "Create frame averaging %"PRId64" samples per column\n", max_samples);
    memset(sum, 0, nb_channels);
    for (node = showwaves->audio_frames; node; node = node->next) {
        int i;
        const AVFrame *frame = node->frame;
        const int16_t *p = (const int16_t *)frame->data[0];
        for (i = 0; i < frame->nb_samples; i++) {
            int ch;
            for (ch = 0; ch < nb_channels; ch++)
                sum[ch] += abs(p[ch + i*nb_channels]) << 1;
            if (n++ == max_samples) {
                for (ch = 0; ch < nb_channels; ch++) {
                    int16_t sample = sum[ch] / max_samples;
                    uint8_t *buf = out->data[0] + col;
                    if (showwaves->split_channels)
                        buf += ch*ch_height*linesize;
                    av_assert0(col < outlink->w);
                    showwaves->draw_sample(buf, ch_height, linesize, sample, &showwaves->buf_idy[ch], x);
                    sum[ch] = 0;
                col++;
                n = 0;
    return push_frame(outlink);
static int push_single_pic(AVFilterLink *outlink)
{
    AVFilterContext *ctx = outlink->src;
    AVFilterLink *inlink = ctx->inputs[0];
    ShowWavesContext *showwaves = ctx->priv;
    int64_t n = 0, max_samples = showwaves->total_samples / outlink->w;
    AVFrame *out = showwaves->outpicref;
    struct frame_node *node;
    const int nb_channels = inlink->channels;
    const int x = 255 / (showwaves->split_channels ? 1 : nb_channels);
    const int ch_height = showwaves->split_channels ? outlink->h / nb_channels : outlink->h;
    const int linesize = out->linesize[0];
    int col = 0;
    int64_t *sum = showwaves->sum;
    av_log(ctx, AV_LOG_DEBUG, "Create frame averaging %"PRId64" samples per column\n", max_samples);
    memset(sum, 0, nb_channels);
    for (node = showwaves->audio_frames; node; node = node->next) {
        int i;
        const AVFrame *frame = node->frame;
        const int16_t *p = (const int16_t *)frame->data[0];
        for (i = 0; i < frame->nb_samples; i++) {
            int ch;
            for (ch = 0; ch < nb_channels; ch++)
                sum[ch] += abs(p[ch + i*nb_channels]) << 1;
            if (n++ == max_samples) {
                for (ch = 0; ch < nb_channels; ch++) {
                    int16_t sample = sum[ch] / max_samples;
                    uint8_t *buf = out->data[0] + col;
                    if (showwaves->split_channels)
                        buf += ch*ch_height*linesize;
                    av_assert0(col < outlink->w);
                    showwaves->draw_sample(buf, ch_height, linesize, sample, &showwaves->buf_idy[ch], x);
                    sum[ch] = 0;
                col++;
                n = 0;
    return push_frame(outlink);
static int FUNC_0(AVFilterLink *VAR_0)
{
    AVFilterContext *ctx = VAR_0->src;
    AVFilterLink *inlink = ctx->inputs[0];
    ShowWavesContext *showwaves = ctx->priv;
    int64_t n = 0, max_samples = showwaves->total_samples / VAR_0->w;
    AVFrame *out = showwaves->outpicref;
    struct frame_node *VAR_1;
    const int VAR_2 = inlink->channels;
    const int VAR_3 = 255 / (showwaves->split_channels ? 1 : VAR_2);
    const int VAR_4 = showwaves->split_channels ? VAR_0->h / VAR_2 : VAR_0->h;
    const int VAR_5 = out->VAR_5[0];
    int VAR_6 = 0;
    int64_t *sum = showwaves->sum;
    av_log(ctx, AV_LOG_DEBUG, "Create VAR_8 averaging %"PRId64" samples per column\n", max_samples);
    memset(sum, 0, VAR_2);
    for (VAR_1 = showwaves->audio_frames; VAR_1; VAR_1 = VAR_1->next) {
        int VAR_7;
        const AVFrame *VAR_8 = VAR_1->VAR_8;
        const int16_t *VAR_9 = (const int16_t *)VAR_8->data[0];
        for (VAR_7 = 0; VAR_7 < VAR_8->nb_samples; VAR_7++) {
            int ch;
            for (ch = 0; ch < VAR_2; ch++)
                sum[ch] += abs(VAR_9[ch + VAR_7*VAR_2]) << 1;
            if (n++ == max_samples) {
                for (ch = 0; ch < VAR_2; ch++) {
                    int16_t sample = sum[ch] / max_samples;
                    uint8_t *buf = out->data[0] + VAR_6;
                    if (showwaves->split_channels)
                        buf += ch*VAR_4*VAR_5;
                    av_assert0(VAR_6 < VAR_0->w);
                    showwaves->draw_sample(buf, VAR_4, VAR_5, sample, &showwaves->buf_idy[ch], VAR_3);
                    sum[ch] = 0;
                VAR_6++;
                n = 0;
    return push_frame(VAR_0);
static int FUNC_0(AVFilterLink *VAR_0)
{ AVFilterContext *ctx = VAR_0->src; AVFilterLink *inlink = ctx->inputs[0]; ShowWavesContext *showwaves = ctx->priv; int64_t n = 0, max_samples = showwaves->total_samples / VAR_0->w; AVFrame *out = showwaves->outpicref; struct frame_node *VAR_1; const int VAR_2 = inlink->channels; const int VAR_3 = 255 / (showwaves->split_channels ? 1 : VAR_2); const int VAR_4 = showwaves->split_channels ? VAR_0->h / VAR_2 : VAR_0->h; const int VAR_5 = out->VAR_5[0]; int VAR_6 = 0; int64_t *sum = showwaves->sum; av_log(ctx, AV_LOG_DEBUG, "Create VAR_8 averaging %"PRId64" samples per column\n", max_samples); memset(sum, 0, VAR_2); for (VAR_1 = showwaves->audio_frames; VAR_1; VAR_1 = VAR_1->next) { int VAR_7; const AVFrame *VAR_8 = VAR_1->VAR_8; const int16_t *VAR_9 = (const int16_t *)VAR_8->data[0]; for (VAR_7 = 0; VAR_7 < VAR_8->nb_samples; VAR_7++) { int ch; for (ch = 0; ch < VAR_2; ch++) sum[ch] += abs(VAR_9[ch + VAR_7*VAR_2]) << 1; if (n++ == max_samples) { for (ch = 0; ch < VAR_2; ch++) { int16_t sample = sum[ch] / max_samples; uint8_t *buf = out->data[0] + VAR_6; if (showwaves->split_channels)
buf += ch*VAR_4*VAR_5; av_assert0(VAR_6 < VAR_0->w); showwaves->draw_sample(buf, VAR_4, VAR_5, sample, &showwaves->buf_idy[ch], VAR_3); sum[ch] = 0; VAR_6++; n = 0; return push_frame(VAR_0);