[FFmpeg-devel] [PATCH 2/3] lavfi: add a generic API for buffer queues.
Stefano Sabatini
stefasab at gmail.com
Wed May 9 03:00:06 CEST 2012
On date Friday 2012-04-27 17:38:41 +0200, Nicolas George encoded:
>
> Signed-off-by: Nicolas George <nicolas.george at normalesup.org>
> ---
> libavfilter/bufferqueue.h | 73 +++++++++++++++++++++++++++++++++++++++++++++
> 1 files changed, 73 insertions(+), 0 deletions(-)
> create mode 100644 libavfilter/bufferqueue.h
>
> diff --git a/libavfilter/bufferqueue.h b/libavfilter/bufferqueue.h
> new file mode 100644
> index 0000000..6ad00ee
> --- /dev/null
> +++ b/libavfilter/bufferqueue.h
> @@ -0,0 +1,73 @@
> +/*
> + * Generic buffer queue
Nit: Generic AVFilterBufferRef queue
this could stay in /** @file doxy */
> + * Copyright (c) 2012 Nicolas George
> + *
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * FFmpeg is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with FFmpeg; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
> + */
> +
> +#ifndef AVFILTER_BUFFERQUEUE_H
> +#define AVFILTER_BUFFERQUEUE_H
> +
> +#ifndef FF_BUFQUEUE_SIZE
> +#define FF_BUFQUEUE_SIZE 32
> +#endif
> +
> +#include "avfilter.h"
> +#include "libavutil/avassert.h"
> +
> +struct ff_bufqueue {
> + AVFilterBufferRef *queue[FF_BUFQUEUE_SIZE];
> + unsigned short head;
> + unsigned short available;
nb_available_bufs?
> +};
> +
> +#define BUCKET(i) queue->queue[(queue->head + (i)) % FF_BUFQUEUE_SIZE]
> +
> +static inline void ff_bufqueue_add(void *log, struct ff_bufqueue *queue,
> + AVFilterBufferRef *buf)
> +{
> + if (queue->available == FF_BUFQUEUE_SIZE) {
> + av_log(log, AV_LOG_WARNING, "Buffer queue overflow, dropping.\n");
> + avfilter_unref_buffer(BUCKET(--queue->available));
> + }
> + BUCKET(queue->available++) = buf;
> +}
> +
> +static inline AVFilterBufferRef *ff_bufqueue_get(struct ff_bufqueue *queue,
> + unsigned index)
"get" is quite confusing, "peek" seems less ambiguous and should be
consistent with the lavu/fifo and lavfi/buffersink API.
> +{
> + return index < queue->available ? BUCKET(index) : NULL;
> +}
> +
> +static inline AVFilterBufferRef *ff_bufqueue_take(struct ff_bufqueue *queue)
take->get? Consistent with buffersink/src.
[...]
--
FFmpeg = Funny & Fancy Mastering Powerful Embarassing Goblin
More information about the ffmpeg-devel
mailing list