You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-10 06:10:52 +02:00
avutil/fifo: Use av_fifo_generic_peek_at() for av_fifo_generic_peek()
Avoids code duplication. It furthermore properly checks for buf_size to be > 0 before doing anything. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
@@ -194,26 +194,7 @@ int av_fifo_generic_peek_at(AVFifoBuffer *f, void *dest, int offset, int buf_siz
|
|||||||
int av_fifo_generic_peek(AVFifoBuffer *f, void *dest, int buf_size,
|
int av_fifo_generic_peek(AVFifoBuffer *f, void *dest, int buf_size,
|
||||||
void (*func)(void *, void *, int))
|
void (*func)(void *, void *, int))
|
||||||
{
|
{
|
||||||
uint8_t *rptr = f->rptr;
|
return av_fifo_generic_peek_at(f, dest, 0, buf_size, func);
|
||||||
|
|
||||||
if (buf_size > av_fifo_size(f))
|
|
||||||
return AVERROR(EINVAL);
|
|
||||||
|
|
||||||
do {
|
|
||||||
int len = FFMIN(f->end - rptr, buf_size);
|
|
||||||
if (func)
|
|
||||||
func(dest, rptr, len);
|
|
||||||
else {
|
|
||||||
memcpy(dest, rptr, len);
|
|
||||||
dest = (uint8_t *)dest + len;
|
|
||||||
}
|
|
||||||
rptr += len;
|
|
||||||
if (rptr >= f->end)
|
|
||||||
rptr -= f->end - f->buffer;
|
|
||||||
buf_size -= len;
|
|
||||||
} while (buf_size > 0);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int av_fifo_generic_read(AVFifoBuffer *f, void *dest, int buf_size,
|
int av_fifo_generic_read(AVFifoBuffer *f, void *dest, int buf_size,
|
||||||
|
Reference in New Issue
Block a user