summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2019-10-25 22:36:19 +0200
committerwm4 <wm4@nowhere>2019-10-25 22:36:19 +0200
commit40b557db6a64f56916efc02f52e67f51f3eb5001 (patch)
treeaec65d22247a255b87d4e5ced25607efc75b1259 /video
parentc184e290b0f7bbf9eb8a87c9e87c9aa870ca2c3f (diff)
downloadmpv-40b557db6a64f56916efc02f52e67f51f3eb5001.tar.bz2
mpv-40b557db6a64f56916efc02f52e67f51f3eb5001.tar.xz
mp_image: move buffer ref assigning to a function
Mostly untested, for the next commit. There's another case of this in this file (ref_buffer()), but it's too weird, so ignore it.
Diffstat (limited to 'video')
-rw-r--r--video/mp_image.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/video/mp_image.c b/video/mp_image.c
index 3b8307573f..5d0caca977 100644
--- a/video/mp_image.c
+++ b/video/mp_image.c
@@ -493,6 +493,15 @@ static enum mp_csp mp_image_params_get_forced_csp(struct mp_image_params *params
return mp_imgfmt_get_forced_csp(imgfmt);
}
+static void assign_bufref(AVBufferRef **dst, AVBufferRef *new)
+{
+ av_buffer_unref(dst);
+ if (new) {
+ *dst = av_buffer_ref(new);
+ MP_HANDLE_OOM(*dst);
+ }
+}
+
void mp_image_copy_attributes(struct mp_image *dst, struct mp_image *src)
{
dst->pict_type = src->pict_type;
@@ -517,13 +526,7 @@ void mp_image_copy_attributes(struct mp_image *dst, struct mp_image *src)
memcpy(dst->planes[1], src->planes[1], AVPALETTE_SIZE);
}
}
- av_buffer_unref(&dst->icc_profile);
- dst->icc_profile = src->icc_profile;
- if (dst->icc_profile) {
- dst->icc_profile = av_buffer_ref(dst->icc_profile);
- if (!dst->icc_profile)
- abort();
- }
+ assign_bufref(&dst->icc_profile, src->icc_profile);
}
// Crop the given image to (x0, y0)-(x1, y1) (bottom/right border exclusive)