mirror of
https://gitee.com/openharmony/third_party_ffmpeg
synced 2024-11-27 21:20:41 +00:00
avutil/buffer: factor buffer_replace() out
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
parent
ecd39520b8
commit
b4f5da2651
@ -103,14 +103,17 @@ AVBufferRef *av_buffer_ref(AVBufferRef *buf)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void av_buffer_unref(AVBufferRef **buf)
|
static void buffer_replace(AVBufferRef **dst, AVBufferRef **src)
|
||||||
{
|
{
|
||||||
AVBuffer *b;
|
AVBuffer *b;
|
||||||
|
|
||||||
if (!buf || !*buf)
|
b = (*dst)->buffer;
|
||||||
return;
|
|
||||||
b = (*buf)->buffer;
|
if (src) {
|
||||||
av_freep(buf);
|
**dst = **src;
|
||||||
|
av_freep(src);
|
||||||
|
} else
|
||||||
|
av_freep(dst);
|
||||||
|
|
||||||
if (!avpriv_atomic_int_add_and_fetch(&b->refcount, -1)) {
|
if (!avpriv_atomic_int_add_and_fetch(&b->refcount, -1)) {
|
||||||
b->free(b->opaque, b->data);
|
b->free(b->opaque, b->data);
|
||||||
@ -118,6 +121,14 @@ void av_buffer_unref(AVBufferRef **buf)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void av_buffer_unref(AVBufferRef **buf)
|
||||||
|
{
|
||||||
|
if (!buf || !*buf)
|
||||||
|
return;
|
||||||
|
|
||||||
|
buffer_replace(buf, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
int av_buffer_is_writable(const AVBufferRef *buf)
|
int av_buffer_is_writable(const AVBufferRef *buf)
|
||||||
{
|
{
|
||||||
if (buf->buffer->flags & AV_BUFFER_FLAG_READONLY)
|
if (buf->buffer->flags & AV_BUFFER_FLAG_READONLY)
|
||||||
|
Loading…
Reference in New Issue
Block a user