diff options
author | James Almer <jamrial@gmail.com> | 2020-06-01 11:22:01 -0300 |
---|---|---|
committer | James Almer <jamrial@gmail.com> | 2020-06-05 10:07:05 -0300 |
commit | b6c8444e2387d9a75b24d5ec1d8308fe6e37645b (patch) | |
tree | b53b4c3f9597e45319f23775f0f9958f2ccd2325 /libavutil/buffer.c | |
parent | f2ad89beff2720b9659cee5d79667f6136f6b47a (diff) |
avutil/buffer: separate public and internal flags inside AVBuffers
It's better to not mix user provided flags and internal flags set by
AVBufferRef helper functions.
Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavutil/buffer.c')
-rw-r--r-- | libavutil/buffer.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/libavutil/buffer.c b/libavutil/buffer.c index b43cd179d7..38a554208a 100644 --- a/libavutil/buffer.c +++ b/libavutil/buffer.c @@ -44,8 +44,7 @@ AVBufferRef *av_buffer_create(uint8_t *data, int size, atomic_init(&buf->refcount, 1); - if (flags & AV_BUFFER_FLAG_READONLY) - buf->flags |= BUFFER_FLAG_READONLY; + buf->flags = flags; ref = av_mallocz(sizeof(*ref)); if (!ref) { @@ -185,14 +184,14 @@ int av_buffer_realloc(AVBufferRef **pbuf, int size) return AVERROR(ENOMEM); } - buf->buffer->flags |= BUFFER_FLAG_REALLOCATABLE; + buf->buffer->flags_internal |= BUFFER_FLAG_REALLOCATABLE; *pbuf = buf; return 0; } else if (buf->size == size) return 0; - if (!(buf->buffer->flags & BUFFER_FLAG_REALLOCATABLE) || + if (!(buf->buffer->flags_internal & BUFFER_FLAG_REALLOCATABLE) || !av_buffer_is_writable(buf) || buf->data != buf->buffer->data) { /* cannot realloc, allocate a new reallocable buffer and copy data */ AVBufferRef *new = NULL; |