Mercurial > libavutil.hg
diff fifo.c @ 492:75f096258d14 libavutil
Add a generic write function to av_fifo.
Patch by Bj«Órn Axelsson: bjorn axelsson intinor se
Original thread: [FFmpeg-devel] [RFC][PATCH] av_fifo_write_from_bytestream()
Date: 04/03/2008 12:14 PM
author | benoit |
---|---|
date | Wed, 09 Apr 2008 11:35:16 +0000 |
parents | 4c85ac99ab37 |
children | 97dd9756349c |
line wrap: on
line diff
--- a/fifo.c Mon Apr 07 21:16:31 2008 +0000 +++ b/fifo.c Wed Apr 09 11:35:16 2008 +0000 @@ -73,15 +73,27 @@ void av_fifo_write(AVFifoBuffer *f, const uint8_t *buf, int size) { + av_fifo_generic_write(f, (void *)buf, size, NULL); +} + +int av_fifo_generic_write(AVFifoBuffer *f, void *buf, int size, int (*func)(void*, void*, int)) +{ + int total = size; do { int len = FFMIN(f->end - f->wptr, size); + if(func) { + if(func(buf, f->wptr, len) <= 0) + break; + } else { memcpy(f->wptr, buf, len); + buf = (uint8_t*)buf + len; + } f->wptr += len; if (f->wptr >= f->end) f->wptr = f->buffer; - buf += len; size -= len; } while (size > 0); + return total - size; }