[FFmpeg-devel] [PATCH] add alloc_put_byte function

Reimar Döffinger Reimar.Doeffinger
Wed Dec 19 19:47:45 CET 2007


Hello,
since applications should not assume ByteIOContext to have a constant
size, attached patch adds a alloc_put_byte function.
It is almost the same as init_put_byte, but it also takes a
streamed_flag parameter - this seems the only missing option the user
has a reason to set and it's exactly what I need, so like this
the actual ByteIOContext struct can be removed from the public API.

Greetings,
Reimar D?ffinger
-------------- next part --------------
Index: libavformat/avio.h
===================================================================
--- libavformat/avio.h	(revision 11269)
+++ libavformat/avio.h	(working copy)
@@ -168,6 +168,15 @@
                   int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),
                   int (*write_packet)(void *opaque, uint8_t *buf, int buf_size),
                   offset_t (*seek)(void *opaque, offset_t offset, int whence));
+ByteIOContext *alloc_put_byte(
+                  unsigned char *buffer,
+                  int buffer_size,
+                  int write_flag,
+                  int streamed_flag,
+                  void *opaque,
+                  int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),
+                  int (*write_packet)(void *opaque, uint8_t *buf, int buf_size),
+                  offset_t (*seek)(void *opaque, offset_t offset, int whence));
 
 void put_byte(ByteIOContext *s, int b);
 void put_buffer(ByteIOContext *s, const unsigned char *buf, int size);
Index: libavformat/aviobuf.c
===================================================================
--- libavformat/aviobuf.c	(revision 11269)
+++ libavformat/aviobuf.c	(working copy)
@@ -61,6 +61,22 @@
     return 0;
 }
 
+ByteIOContext *alloc_put_byte(
+                  unsigned char *buffer,
+                  int buffer_size,
+                  int write_flag,
+                  int streamed_flag,
+                  void *opaque,
+                  int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),
+                  int (*write_packet)(void *opaque, uint8_t *buf, int buf_size),
+                  offset_t (*seek)(void *opaque, offset_t offset, int whence)) {
+    ByteIOContext *s = av_mallocz(sizeof(ByteIOContext));
+    init_put_byte(s, buffer, buffer_size, write_flag, opaque,
+                  read_packet, write_packet, seek);
+    s->is_streamed = streamed_flag;
+    return s;
+}
+
 static void flush_buffer(ByteIOContext *s)
 {
     if (s->buf_ptr > s->buffer) {



More information about the ffmpeg-devel mailing list