diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2014-04-13 02:05:50 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2014-04-13 02:06:47 +0200 |
commit | 31876ea620064b00c41ab87c3bb49cf9c6e098eb (patch) | |
tree | b61615c3685eb0bd76c14281254539ebdd61c680 | |
parent | d06a7530f7eaa3915845ffd0b95e558b45b5b062 (diff) | |
parent | 5748faf291fec297ef25d81962b52b3438f54278 (diff) | |
download | ffmpeg-31876ea620064b00c41ab87c3bb49cf9c6e098eb.tar.gz |
Merge commit '5748faf291fec297ef25d81962b52b3438f54278'
* commit '5748faf291fec297ef25d81962b52b3438f54278':
bytestream: add bytestream2_copy_buffer() functions
Merged-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r-- | libavcodec/bytestream.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/libavcodec/bytestream.h b/libavcodec/bytestream.h index f2458591cb..c2cb601806 100644 --- a/libavcodec/bytestream.h +++ b/libavcodec/bytestream.h @@ -328,6 +328,32 @@ static av_always_inline unsigned int bytestream2_get_eof(PutByteContext *p) return p->eof; } +static av_always_inline unsigned int bytestream2_copy_bufferu(PutByteContext *p, + GetByteContext *g, + unsigned int size) +{ + memcpy(p->buffer, g->buffer, size); + p->buffer += size; + g->buffer += size; + return size; +} + +static av_always_inline unsigned int bytestream2_copy_buffer(PutByteContext *p, + GetByteContext *g, + unsigned int size) +{ + int size2; + + if (p->eof) + return 0; + size = FFMIN(g->buffer_end - g->buffer, size); + size2 = FFMIN(p->buffer_end - p->buffer, size); + if (size2 != size) + p->eof = 1; + + return bytestream2_copy_bufferu(p, g, size2); +} + static av_always_inline unsigned int bytestream_get_buffer(const uint8_t **b, uint8_t *dst, unsigned int size) |