[FFmpeg-devel] [PATCH] avfilter: add tremolo filter

Clément Bœsch u at pkh.me
Sun Sep 20 11:52:25 CEST 2015


On Sat, Sep 19, 2015 at 11:28:15PM -0500, Kyle Swanson wrote:
[...]
> +static int filter_frame(AVFilterLink *inlink, AVFrame *in)
> +{
> +    AVFilterContext *ctx = inlink->dst;
> +    AVFilterLink *outlink = ctx->outputs[0];
> +    AVFrame *out;
> +
> +    if (av_frame_is_writable(in)) {
> +        out = in;
> +    } else {
> +        out = ff_get_audio_buffer(inlink, in->nb_samples);
> +        if (!out) {
> +            av_frame_free(&in);
> +            return AVERROR(ENOMEM);
> +        }
> +        av_frame_copy_props(out, in);
> +    }
> +
> +    int channels = inlink->channels;
> +    int nb_samples = in->nb_samples;
> +    double *dst = (double *)out->data[0];
> +    int n, c;
> +
> +    for (n = 0; n < nb_samples; n++) {
> +        float env = trem_env(ctx);
> +        for (c = 0; c < channels; c++) {

> +            dst[c] *= env;

Doesn't this code only works in the case of inplace?

You may play with perms filters to check if you get the same results, but
I'm pretty sure it doesn't give you the same results in both paths.

> +        }
> +        dst += channels;
> +    }
> +
> +    if (in != out)
> +        av_frame_free(&in);
> +
> +    return ff_filter_frame(outlink, out);
> +}
[...]

-- 
Clément B.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20150920/8e4dda08/attachment.sig>


More information about the ffmpeg-devel mailing list