summaryrefslogtreecommitdiff
path: root/libavutil/fifo.c
diff options
context:
space:
mode:
authorBjörn Axelsson <gecko@acc.umu.se>2008-04-09 11:35:16 +0000
committerBenoit Fouet <benoit.fouet@free.fr>2008-04-09 11:35:16 +0000
commit49cec1998af4c8806f4981d12daa28091ccb0425 (patch)
tree557a347c0c4964b8b9f4c2349b154062f84d6f9e /libavutil/fifo.c
parent96275520a383464ce9552ed727bd38dcb91d70fb (diff)
downloadffmpeg-49cec1998af4c8806f4981d12daa28091ccb0425.tar.gz
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 Originally committed as revision 12773 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavutil/fifo.c')
-rw-r--r--libavutil/fifo.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/libavutil/fifo.c b/libavutil/fifo.c
index 8ac3a0cb55..08b5977a1a 100644
--- a/libavutil/fifo.c
+++ b/libavutil/fifo.c
@@ -73,15 +73,27 @@ void av_fifo_realloc(AVFifoBuffer *f, unsigned int new_size) {
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;
}