[FFmpeg-devel] [PATCH 09/10] avio: add put_nbyte for putting a single byte multiple times

Anssi Hannula anssi.hannula
Wed Dec 29 06:06:42 CET 2010


---
Used by the next patch.

 libavformat/avio.h    |    1 +
 libavformat/aviobuf.c |   14 ++++++++++++++
 2 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/libavformat/avio.h b/libavformat/avio.h
index 28c7d58..e65f712 100644
--- a/libavformat/avio.h
+++ b/libavformat/avio.h
@@ -353,6 +353,7 @@ ByteIOContext *av_alloc_put_byte(
                   int64_t (*seek)(void *opaque, int64_t offset, int whence));
 
 void put_byte(ByteIOContext *s, int b);
+void put_nbyte(ByteIOContext *s, int b, int count);
 void put_buffer(ByteIOContext *s, const unsigned char *buf, int size);
 void put_le64(ByteIOContext *s, uint64_t val);
 void put_be64(ByteIOContext *s, uint64_t val);
diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index faae089..df76507 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -113,6 +113,20 @@ void put_byte(ByteIOContext *s, int b)
         flush_buffer(s);
 }
 
+void put_nbyte(ByteIOContext *s, int b, int count)
+{
+    while (count > 0) {
+        int len = FFMIN(s->buf_end - s->buf_ptr, count);
+        memset(s->buf_ptr, b, len);
+        s->buf_ptr += len;
+
+        if (s->buf_ptr >= s->buf_end)
+            flush_buffer(s);
+
+        count -= len;
+    }
+}
+
 void put_buffer(ByteIOContext *s, const unsigned char *buf, int size)
 {
     while (size > 0) {
-- 
1.7.3




More information about the ffmpeg-devel mailing list