summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
Diffstat (limited to 'video')
-rw-r--r--video/mp_image.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/video/mp_image.c b/video/mp_image.c
index ecf4be7768..3511246b5b 100644
--- a/video/mp_image.c
+++ b/video/mp_image.c
@@ -300,14 +300,13 @@ void mp_image_unref_data(struct mp_image *img)
}
}
-static bool ref_buffer(AVBufferRef **dst)
+static void ref_buffer(bool *ok, AVBufferRef **dst)
{
if (*dst) {
*dst = av_buffer_ref(*dst);
if (!*dst)
- return false;
+ ok = false;
}
- return true;
}
// Return a new reference to img. The returned reference is owned by the caller,
@@ -324,20 +323,20 @@ struct mp_image *mp_image_new_ref(struct mp_image *img)
talloc_set_destructor(new, mp_image_destructor);
*new = *img;
- bool fail = false;
+ bool ok = true;
for (int p = 0; p < MP_MAX_PLANES; p++)
- fail |= !ref_buffer(&new->bufs[p]);
+ ref_buffer(&ok, &new->bufs[p]);
- fail |= !ref_buffer(&new->hwctx);
- fail |= !ref_buffer(&new->icc_profile);
- fail |= !ref_buffer(&new->a53_cc);
+ ref_buffer(&ok, &new->hwctx);
+ ref_buffer(&ok, &new->icc_profile);
+ ref_buffer(&ok, &new->a53_cc);
new->ff_side_data = talloc_memdup(NULL, new->ff_side_data,
new->num_ff_side_data * sizeof(new->ff_side_data[0]));
for (int n = 0; n < new->num_ff_side_data; n++)
- fail |= !ref_buffer(&new->ff_side_data[n].buf);
+ ref_buffer(&ok, &new->ff_side_data[n].buf);
- if (!fail)
+ if (ok)
return new;
// Do this after _all_ bufs were changed; we don't want it to free bufs