mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-01-13 21:28:01 +02:00
avcodec/v4l2_buffers: split out v4l2_buf_increase_ref helper
Signed-off-by: Aman Gupta <aman@tmm1.net>
This commit is contained in:
parent
d620b1f9de
commit
40a433e34b
@ -228,10 +228,30 @@ static void v4l2_free_buffer(void *opaque, uint8_t *unused)
|
||||
}
|
||||
}
|
||||
|
||||
static int v4l2_buf_to_bufref(V4L2Buffer *in, int plane, AVBufferRef **buf)
|
||||
static int v4l2_buf_increase_ref(V4L2Buffer *in)
|
||||
{
|
||||
V4L2m2mContext *s = buf_to_m2mctx(in);
|
||||
|
||||
if (in->context_ref)
|
||||
atomic_fetch_add(&in->context_refcount, 1);
|
||||
else {
|
||||
in->context_ref = av_buffer_ref(s->self_ref);
|
||||
if (!in->context_ref)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
in->context_refcount = 1;
|
||||
}
|
||||
|
||||
in->status = V4L2BUF_RET_USER;
|
||||
atomic_fetch_add_explicit(&s->refcount, 1, memory_order_relaxed);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int v4l2_buf_to_bufref(V4L2Buffer *in, int plane, AVBufferRef **buf)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (plane >= in->num_planes)
|
||||
return AVERROR(EINVAL);
|
||||
|
||||
@ -241,21 +261,11 @@ static int v4l2_buf_to_bufref(V4L2Buffer *in, int plane, AVBufferRef **buf)
|
||||
if (!*buf)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
if (in->context_ref)
|
||||
atomic_fetch_add(&in->context_refcount, 1);
|
||||
else {
|
||||
in->context_ref = av_buffer_ref(s->self_ref);
|
||||
if (!in->context_ref) {
|
||||
ret = v4l2_buf_increase_ref(in);
|
||||
if (ret)
|
||||
av_buffer_unref(buf);
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
in->context_refcount = 1;
|
||||
}
|
||||
|
||||
in->status = V4L2BUF_RET_USER;
|
||||
atomic_fetch_add_explicit(&s->refcount, 1, memory_order_relaxed);
|
||||
|
||||
return 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int v4l2_bufref_to_buf(V4L2Buffer *out, int plane, const uint8_t* data, int size, int offset, AVBufferRef* bref)
|
||||
|
Loading…
Reference in New Issue
Block a user