[FFmpeg-devel] [PATCH] lavfi: add amerge audio filter.

Stefano Sabatini stefasab at gmail.com
Sat Dec 31 16:14:19 CET 2011


On date Thursday 2011-12-29 13:16:43 +0100, Nicolas George encoded:
> 
> Signed-off-by: Nicolas George <nicolas.george at normalesup.org>
[...]
> +/**
> + * Copy samples from two input streams to one output stream
> + * @aram nb_in_ch  number of channels in each input stream.

nit+++: missing point and empty line after short description,
unnecessary point at the end of @param nb_in_ch

> + * @aram route     routing values;
> + *                 input channel i goes to output channel route[i];
> + *                 i <  nb_in_ch[0] are the channels from the first output;
> + *                 i >= nb_in_ch[0] are the channels from the second output
> + * @param ins      pointer to the samples of each inputs, in packed format;
> + *                 will be left at the end of the copied samples
> + * @param outs     pointer to the samples of the output, in packet format;
> + *                 must point to a buffer big enough;
> + *                 will be left at the end of the copied samples
> + * @param ns       number of samples to copy
> + * @param bps      bytes per sample
> + */
> +static inline void copy_samples(int nb_in_ch[2], int *route, uint8_t *ins[2],
> +                                uint8_t **outs, int ns, int bps)
> +{
> +    int *route_cur;
> +    int i, c;
> +
> +    while (ns--) {
> +        route_cur = route;
> +        for (i = 0; i < 2; i++) {
> +            for (c = 0; c < nb_in_ch[i]; c++) {
> +                memcpy((*outs) + bps * *(route_cur++), ins[i], bps);
> +                ins[i] += bps;
> +            }
> +        }
> +        *outs += (nb_in_ch[0] + nb_in_ch[1]) * bps;
> +    }
> +}
> +

> +static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamples)
> +{
> +    AVFilterContext *ctx = inlink->dst;
> +    AMergeContext *am = ctx->priv;
> +    int input_number = inlink == ctx->inputs[1];

> +    struct amerge_queue *iq = &am->queue[input_number];

nit++: inq

> +    int nb_samples, ns, i;
> +    AVFilterBufferRef *outbuf, **inbuf[2];
> +    uint8_t *ins[2], *outs;
> +

> +    if (iq->nb_buf == QUEUE_SIZE) {
> +        av_log(ctx, AV_LOG_ERROR, "Packet queue overflow; dropped\n");
> +        avfilter_unref_buffer(insamples);
> +        return;
> +    }

I wonder if we should make this queue size dynamic.

[...]

Looks good to me otherwise.
-- 
FFmpeg = Fascinating and Furious Mind-dumbing Plastic Easy Glue


More information about the ffmpeg-devel mailing list