[FFmpeg-devel] [PATCH 1/2] avutil/fifo: add function av_fifo_generic_peek_at()
Michael Niedermayer
michael at niedermayer.cc
Tue Oct 13 18:34:00 CEST 2015
On Tue, Oct 13, 2015 at 06:30:46PM +0800, Zhang Rui wrote:
> ---
> libavutil/fifo.c | 37 +++++++++++++++++++++++++++++++++++++
> libavutil/fifo.h | 11 +++++++++++
> tests/ref/fate/fifo | 14 ++++++++++++++
> 3 files changed, 62 insertions(+)
>
> diff --git a/libavutil/fifo.c b/libavutil/fifo.c
> index 07fb4ec..cabb009 100644
> --- a/libavutil/fifo.c
> +++ b/libavutil/fifo.c
> @@ -148,6 +148,35 @@ int av_fifo_generic_write(AVFifoBuffer *f, void *src, int size,
> return total - size;
> }
>
> +int av_fifo_generic_peek_at(AVFifoBuffer *f, void *dest, int offset, int buf_size, void (*func)(void*, void*, int))
> +{
> + uint8_t *rptr = f->rptr + offset;
> + uint32_t rndx = f->rndx + offset;
> +
> + av_assert2(offset >= 0);
> + while (buf_size > 0) {
> + int len;
> +
> + if (rptr >= f->end)
> + rptr -= f->end - f->buffer;
> +
> + av_assert2(rndx < f->wndx);
*ndx are indexes modulo 2^32, they are intended to overflow so this
condition will become false at some point around 4gb
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Dictatorship naturally arises out of democracy, and the most aggravated
form of tyranny and slavery out of the most extreme liberty. -- Plato
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20151013/b69e1b62/attachment.sig>
More information about the ffmpeg-devel
mailing list