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

{

    AVFilterContext *ctx = inlink->dst;

    VolumeContext *vol    = inlink->dst->priv;

    AVFilterLink *outlink = inlink->dst->outputs[0];

    int nb_samples        = buf->nb_samples;

    AVFrame *out_buf;

    int64_t pos;

    AVFrameSideData *sd = av_frame_get_side_data(buf, AV_FRAME_DATA_REPLAYGAIN);

    int ret;



    if (sd && vol->replaygain != REPLAYGAIN_IGNORE) {

        if (vol->replaygain != REPLAYGAIN_DROP) {

            AVReplayGain *replaygain = (AVReplayGain*)sd->data;

            int32_t gain  = 100000;

            uint32_t peak = 100000;

            float g, p;



            if (vol->replaygain == REPLAYGAIN_TRACK &&

                replaygain->track_gain != INT32_MIN) {

                gain = replaygain->track_gain;



                if (replaygain->track_peak != 0)

                    peak = replaygain->track_peak;

            } else if (replaygain->album_gain != INT32_MIN) {

                gain = replaygain->album_gain;



                if (replaygain->album_peak != 0)

                    peak = replaygain->album_peak;

            } else {

                av_log(inlink->dst, AV_LOG_WARNING, "Both ReplayGain gain "

                       "values are unknown.\n");

            }

            g = gain / 100000.0f;

            p = peak / 100000.0f;



            av_log(inlink->dst, AV_LOG_VERBOSE,

                   "Using gain %f dB from replaygain side data.\n", g);



            vol->volume   = ff_exp10((g + vol->replaygain_preamp) / 20);

            if (vol->replaygain_noclip)

                vol->volume = FFMIN(vol->volume, 1.0 / p);

            vol->volume_i = (int)(vol->volume * 256 + 0.5);



            volume_init(vol);

        }

        av_frame_remove_side_data(buf, AV_FRAME_DATA_REPLAYGAIN);

    }



    if (isnan(vol->var_values[VAR_STARTPTS])) {

        vol->var_values[VAR_STARTPTS] = TS2D(buf->pts);

        vol->var_values[VAR_STARTT  ] = TS2T(buf->pts, inlink->time_base);

    }

    vol->var_values[VAR_PTS] = TS2D(buf->pts);

    vol->var_values[VAR_T  ] = TS2T(buf->pts, inlink->time_base);

    vol->var_values[VAR_N  ] = inlink->frame_count_out;



    pos = buf->pkt_pos;

    vol->var_values[VAR_POS] = pos == -1 ? NAN : pos;

    if (vol->eval_mode == EVAL_MODE_FRAME)

        set_volume(ctx);



    if (vol->volume == 1.0 || vol->volume_i == 256) {

        out_buf = buf;

        goto end;

    }



    /* do volume scaling in-place if input buffer is writable */

    if (av_frame_is_writable(buf)

            && (vol->precision != PRECISION_FIXED || vol->volume_i > 0)) {

        out_buf = buf;

    } else {

        out_buf = ff_get_audio_buffer(inlink, nb_samples);

        if (!out_buf)

            return AVERROR(ENOMEM);

        ret = av_frame_copy_props(out_buf, buf);

        if (ret < 0) {

            av_frame_free(&out_buf);

            av_frame_free(&buf);

            return ret;

        }

    }



    if (vol->precision != PRECISION_FIXED || vol->volume_i > 0) {

        int p, plane_samples;



        if (av_sample_fmt_is_planar(buf->format))

            plane_samples = FFALIGN(nb_samples, vol->samples_align);

        else

            plane_samples = FFALIGN(nb_samples * vol->channels, vol->samples_align);



        if (vol->precision == PRECISION_FIXED) {

            for (p = 0; p < vol->planes; p++) {

                vol->scale_samples(out_buf->extended_data[p],

                                   buf->extended_data[p], plane_samples,

                                   vol->volume_i);

            }

        } else if (av_get_packed_sample_fmt(vol->sample_fmt) == AV_SAMPLE_FMT_FLT) {

            for (p = 0; p < vol->planes; p++) {

                vol->fdsp->vector_fmul_scalar((float *)out_buf->extended_data[p],

                                             (const float *)buf->extended_data[p],

                                             vol->volume, plane_samples);

            }

        } else {

            for (p = 0; p < vol->planes; p++) {

                vol->fdsp->vector_dmul_scalar((double *)out_buf->extended_data[p],

                                             (const double *)buf->extended_data[p],

                                             vol->volume, plane_samples);

            }

        }

    }



    emms_c();



    if (buf != out_buf)

        av_frame_free(&buf);



end:

    vol->var_values[VAR_NB_CONSUMED_SAMPLES] += out_buf->nb_samples;

    return ff_filter_frame(outlink, out_buf);

}

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

{

    AVFilterContext *ctx = inlink->dst;

    VolumeContext *vol    = inlink->dst->priv;

    AVFilterLink *outlink = inlink->dst->outputs[0];

    int nb_samples        = buf->nb_samples;

    AVFrame *out_buf;

    int64_t pos;

    AVFrameSideData *sd = av_frame_get_side_data(buf, AV_FRAME_DATA_REPLAYGAIN);

    int ret;



    if (sd && vol->replaygain != REPLAYGAIN_IGNORE) {

        if (vol->replaygain != REPLAYGAIN_DROP) {

            AVReplayGain *replaygain = (AVReplayGain*)sd->data;

            int32_t gain  = 100000;

            uint32_t peak = 100000;

            float g, p;



            if (vol->replaygain == REPLAYGAIN_TRACK &&

                replaygain->track_gain != INT32_MIN) {

                gain = replaygain->track_gain;



                if (replaygain->track_peak != 0)

                    peak = replaygain->track_peak;

            } else if (replaygain->album_gain != INT32_MIN) {

                gain = replaygain->album_gain;



                if (replaygain->album_peak != 0)

                    peak = replaygain->album_peak;

            } else {

                av_log(inlink->dst, AV_LOG_WARNING, "Both ReplayGain gain "

                       "values are unknown.\n");

            }

            g = gain / 100000.0f;

            p = peak / 100000.0f;



            av_log(inlink->dst, AV_LOG_VERBOSE,

                   "Using gain %f dB from replaygain side data.\n", g);



            vol->volume   = ff_exp10((g + vol->replaygain_preamp) / 20);

            if (vol->replaygain_noclip)

                vol->volume = FFMIN(vol->volume, 1.0 / p);

            vol->volume_i = (int)(vol->volume * 256 + 0.5);



            volume_init(vol);

        }

        av_frame_remove_side_data(buf, AV_FRAME_DATA_REPLAYGAIN);

    }



    if (isnan(vol->var_values[VAR_STARTPTS])) {

        vol->var_values[VAR_STARTPTS] = TS2D(buf->pts);

        vol->var_values[VAR_STARTT  ] = TS2T(buf->pts, inlink->time_base);

    }

    vol->var_values[VAR_PTS] = TS2D(buf->pts);

    vol->var_values[VAR_T  ] = TS2T(buf->pts, inlink->time_base);

    vol->var_values[VAR_N  ] = inlink->frame_count_out;



    pos = buf->pkt_pos;

    vol->var_values[VAR_POS] = pos == -1 ? NAN : pos;

    if (vol->eval_mode == EVAL_MODE_FRAME)

        set_volume(ctx);



    if (vol->volume == 1.0 || vol->volume_i == 256) {

        out_buf = buf;

        goto end;

    }



    

    if (av_frame_is_writable(buf)

            && (vol->precision != PRECISION_FIXED || vol->volume_i > 0)) {

        out_buf = buf;

    } else {

        out_buf = ff_get_audio_buffer(inlink, nb_samples);

        if (!out_buf)

            return AVERROR(ENOMEM);

        ret = av_frame_copy_props(out_buf, buf);

        if (ret < 0) {

            av_frame_free(&out_buf);

            av_frame_free(&buf);

            return ret;

        }

    }



    if (vol->precision != PRECISION_FIXED || vol->volume_i > 0) {

        int p, plane_samples;



        if (av_sample_fmt_is_planar(buf->format))

            plane_samples = FFALIGN(nb_samples, vol->samples_align);

        else

            plane_samples = FFALIGN(nb_samples * vol->channels, vol->samples_align);



        if (vol->precision == PRECISION_FIXED) {

            for (p = 0; p < vol->planes; p++) {

                vol->scale_samples(out_buf->extended_data[p],

                                   buf->extended_data[p], plane_samples,

                                   vol->volume_i);

            }

        } else if (av_get_packed_sample_fmt(vol->sample_fmt) == AV_SAMPLE_FMT_FLT) {

            for (p = 0; p < vol->planes; p++) {

                vol->fdsp->vector_fmul_scalar((float *)out_buf->extended_data[p],

                                             (const float *)buf->extended_data[p],

                                             vol->volume, plane_samples);

            }

        } else {

            for (p = 0; p < vol->planes; p++) {

                vol->fdsp->vector_dmul_scalar((double *)out_buf->extended_data[p],

                                             (const double *)buf->extended_data[p],

                                             vol->volume, plane_samples);

            }

        }

    }



    emms_c();



    if (buf != out_buf)

        av_frame_free(&buf);



end:

    vol->var_values[VAR_NB_CONSUMED_SAMPLES] += out_buf->nb_samples;

    return ff_filter_frame(outlink, out_buf);

}

        if (!out_buf)
static int FUNC_0(AVFilterLink *VAR_0, AVFrame *VAR_1)

{

    AVFilterContext *ctx = VAR_0->dst;

    VolumeContext *vol    = VAR_0->dst->priv;

    AVFilterLink *outlink = VAR_0->dst->outputs[0];

    int VAR_2        = VAR_1->VAR_2;

    AVFrame *out_buf;

    int64_t pos;

    AVFrameSideData *sd = av_frame_get_side_data(VAR_1, AV_FRAME_DATA_REPLAYGAIN);

    int VAR_3;



    if (sd && vol->replaygain != REPLAYGAIN_IGNORE) {

        if (vol->replaygain != REPLAYGAIN_DROP) {

            AVReplayGain *replaygain = (AVReplayGain*)sd->data;

            int32_t gain  = 100000;

            uint32_t peak = 100000;

            float VAR_4, VAR_6;



            if (vol->replaygain == REPLAYGAIN_TRACK &&

                replaygain->track_gain != INT32_MIN) {

                gain = replaygain->track_gain;



                if (replaygain->track_peak != 0)

                    peak = replaygain->track_peak;

            } else if (replaygain->album_gain != INT32_MIN) {

                gain = replaygain->album_gain;



                if (replaygain->album_peak != 0)

                    peak = replaygain->album_peak;

            } else {

                av_log(VAR_0->dst, AV_LOG_WARNING, "Both ReplayGain gain "

                       "values are unknown.\n");

            }

            VAR_4 = gain / 100000.0f;

            VAR_6 = peak / 100000.0f;



            av_log(VAR_0->dst, AV_LOG_VERBOSE,

                   "Using gain %f dB from replaygain side data.\n", VAR_4);



            vol->volume   = ff_exp10((VAR_4 + vol->replaygain_preamp) / 20);

            if (vol->replaygain_noclip)

                vol->volume = FFMIN(vol->volume, 1.0 / VAR_6);

            vol->volume_i = (int)(vol->volume * 256 + 0.5);



            volume_init(vol);

        }

        av_frame_remove_side_data(VAR_1, AV_FRAME_DATA_REPLAYGAIN);

    }



    if (isnan(vol->var_values[VAR_STARTPTS])) {

        vol->var_values[VAR_STARTPTS] = TS2D(VAR_1->pts);

        vol->var_values[VAR_STARTT  ] = TS2T(VAR_1->pts, VAR_0->time_base);

    }

    vol->var_values[VAR_PTS] = TS2D(VAR_1->pts);

    vol->var_values[VAR_T  ] = TS2T(VAR_1->pts, VAR_0->time_base);

    vol->var_values[VAR_N  ] = VAR_0->frame_count_out;



    pos = VAR_1->pkt_pos;

    vol->var_values[VAR_POS] = pos == -1 ? NAN : pos;

    if (vol->eval_mode == EVAL_MODE_FRAME)

        set_volume(ctx);



    if (vol->volume == 1.0 || vol->volume_i == 256) {

        out_buf = VAR_1;

        goto end;

    }



    

    if (av_frame_is_writable(VAR_1)

            && (vol->precision != PRECISION_FIXED || vol->volume_i > 0)) {

        out_buf = VAR_1;

    } else {

        out_buf = ff_get_audio_buffer(VAR_0, VAR_2);

        if (!out_buf)

            return AVERROR(ENOMEM);

        VAR_3 = av_frame_copy_props(out_buf, VAR_1);

        if (VAR_3 < 0) {

            av_frame_free(&out_buf);

            av_frame_free(&VAR_1);

            return VAR_3;

        }

    }



    if (vol->precision != PRECISION_FIXED || vol->volume_i > 0) {

        int VAR_6, VAR_6;



        if (av_sample_fmt_is_planar(VAR_1->format))

            VAR_6 = FFALIGN(VAR_2, vol->samples_align);

        else

            VAR_6 = FFALIGN(VAR_2 * vol->channels, vol->samples_align);



        if (vol->precision == PRECISION_FIXED) {

            for (VAR_6 = 0; VAR_6 < vol->planes; VAR_6++) {

                vol->scale_samples(out_buf->extended_data[VAR_6],

                                   VAR_1->extended_data[VAR_6], VAR_6,

                                   vol->volume_i);

            }

        } else if (av_get_packed_sample_fmt(vol->sample_fmt) == AV_SAMPLE_FMT_FLT) {

            for (VAR_6 = 0; VAR_6 < vol->planes; VAR_6++) {

                vol->fdsp->vector_fmul_scalar((float *)out_buf->extended_data[VAR_6],

                                             (const float *)VAR_1->extended_data[VAR_6],

                                             vol->volume, VAR_6);

            }

        } else {

            for (VAR_6 = 0; VAR_6 < vol->planes; VAR_6++) {

                vol->fdsp->vector_dmul_scalar((double *)out_buf->extended_data[VAR_6],

                                             (const double *)VAR_1->extended_data[VAR_6],

                                             vol->volume, VAR_6);

            }

        }

    }



    emms_c();



    if (VAR_1 != out_buf)

        av_frame_free(&VAR_1);



end:

    vol->var_values[VAR_NB_CONSUMED_SAMPLES] += out_buf->VAR_2;

    return ff_filter_frame(outlink, out_buf);

}

static int FUNC_0(AVFilterLink *VAR_0, AVFrame *VAR_1)
{ AVFilterContext *ctx = VAR_0->dst; VolumeContext *vol    = VAR_0->dst->priv; AVFilterLink *outlink = VAR_0->dst->outputs[0]; int VAR_2        = VAR_1->VAR_2; AVFrame *out_buf; int64_t pos; AVFrameSideData *sd = av_frame_get_side_data(VAR_1, AV_FRAME_DATA_REPLAYGAIN); int VAR_3; if (sd && vol->replaygain != REPLAYGAIN_IGNORE) { if (vol->replaygain != REPLAYGAIN_DROP) { AVReplayGain *replaygain = (AVReplayGain*)sd->data; int32_t gain  = 100000; uint32_t peak = 100000; float VAR_4, VAR_6; if (vol->replaygain == REPLAYGAIN_TRACK &&
replaygain->track_gain != INT32_MIN) { gain = replaygain->track_gain; if (replaygain->track_peak != 0)
peak = replaygain->track_peak; } else if (replaygain->album_gain != INT32_MIN) { gain = replaygain->album_gain; if (replaygain->album_peak != 0)
peak = replaygain->album_peak; } else { av_log(VAR_0->dst, AV_LOG_WARNING, "Both ReplayGain gain "
"values are unknown.\n"); } VAR_4 = gain / 100000.0f; VAR_6 = peak / 100000.0f; av_log(VAR_0->dst, AV_LOG_VERBOSE,
"Using gain %f dB from replaygain side data.\n", VAR_4); vol->volume   = ff_exp10((VAR_4 + vol->replaygain_preamp) / 20); if (vol->replaygain_noclip)
vol->volume = FFMIN(vol->volume, 1.0 / VAR_6); vol->volume_i = (int)(vol->volume * 256 + 0.5); volume_init(vol); } av_frame_remove_side_data(VAR_1, AV_FRAME_DATA_REPLAYGAIN); } if (isnan(vol->var_values[VAR_STARTPTS])) { vol->var_values[VAR_STARTPTS] = TS2D(VAR_1->pts); vol->var_values[VAR_STARTT  ] = TS2T(VAR_1->pts, VAR_0->time_base); } vol->var_values[VAR_PTS] = TS2D(VAR_1->pts); vol->var_values[VAR_T  ] = TS2T(VAR_1->pts, VAR_0->time_base); vol->var_values[VAR_N  ] = VAR_0->frame_count_out; pos = VAR_1->pkt_pos; vol->var_values[VAR_POS] = pos == -1 ? NAN : pos; if (vol->eval_mode == EVAL_MODE_FRAME)
set_volume(ctx); if (vol->volume == 1.0 || vol->volume_i == 256) { out_buf = VAR_1; goto end; } if (av_frame_is_writable(VAR_1)
&& (vol->precision != PRECISION_FIXED || vol->volume_i > 0)) { out_buf = VAR_1; } else { out_buf = ff_get_audio_buffer(VAR_0, VAR_2); if (!out_buf)
return AVERROR(ENOMEM); VAR_3 = av_frame_copy_props(out_buf, VAR_1); if (VAR_3 < 0) { av_frame_free(&out_buf); av_frame_free(&VAR_1); return VAR_3; } } if (vol->precision != PRECISION_FIXED || vol->volume_i > 0) { int VAR_6, VAR_6; if (av_sample_fmt_is_planar(VAR_1->format))
VAR_6 = FFALIGN(VAR_2, vol->samples_align); else
VAR_6 = FFALIGN(VAR_2 * vol->channels, vol->samples_align); if (vol->precision == PRECISION_FIXED) { for (VAR_6 = 0; VAR_6 < vol->planes; VAR_6++) { vol->scale_samples(out_buf->extended_data[VAR_6],
VAR_1->extended_data[VAR_6], VAR_6,
vol->volume_i); } } else if (av_get_packed_sample_fmt(vol->sample_fmt) == AV_SAMPLE_FMT_FLT) { for (VAR_6 = 0; VAR_6 < vol->planes; VAR_6++) { vol->fdsp->vector_fmul_scalar((float *)out_buf->extended_data[VAR_6],
(const float *)VAR_1->extended_data[VAR_6],
vol->volume, VAR_6); } } else { for (VAR_6 = 0; VAR_6 < vol->planes; VAR_6++) { vol->fdsp->vector_dmul_scalar((double *)out_buf->extended_data[VAR_6],
(const double *)VAR_1->extended_data[VAR_6],
vol->volume, VAR_6); } } } emms_c(); if (VAR_1 != out_buf)
av_frame_free(&VAR_1); end:
vol->var_values[VAR_NB_CONSUMED_SAMPLES] += out_buf->VAR_2; return ff_filter_frame(outlink, out_buf); }