Commit 1e0f3468 authored by Reimar Döffinger's avatar Reimar Döffinger

Add a av_alloc_put_byte function.

The name is in analogy to init_put_byte, but I would not mind it
being changed to something better.

Originally committed as revision 11305 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent 4159db8c
......@@ -181,6 +181,14 @@ int init_put_byte(ByteIOContext *s,
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 *av_alloc_put_byte(
unsigned char *buffer,
int buffer_size,
int write_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);
......
......@@ -60,6 +60,20 @@ int init_put_byte(ByteIOContext *s,
return 0;
}
ByteIOContext *av_alloc_put_byte(
unsigned char *buffer,
int buffer_size,
int write_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);
return s;
}
static void flush_buffer(ByteIOContext *s)
{
if (s->buf_ptr > s->buffer) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment