[vlc-devel] [PATCH v2 14/14] picture: always copy context when cloning
Steve Lhomme
robux4 at ycbcr.xyz
Fri Aug 14 14:01:49 CEST 2020
From: Alexandre Janniaux <ajanni at videolabs.io>
icture_Clone was copying the original picture context into the new
clone while picture_pool_Clone wasn't. As it is possible to create a
pool from existing pictures, it's quite handy to be able to associate
the graphical resources needed for each picture to their context so
that it can be retrieved after a call to picture_pool_Wait/Get.
The rationale is that because resources like pixels are shared between
the original picture and the clone, we should probably do the same with
picture_context and have a unified way for picture producer to
reference such resources.
This patch remove the special handling in picture_Clone and move it to
picture_InternalClone for that reason.
Signed-off-by: Steve Lhomme <robux4 at ycbcr.xyz>
---
src/misc/picture.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/misc/picture.c b/src/misc/picture.c
index 895ee3d0f13..e9787633dfe 100644
--- a/src/misc/picture.c
+++ b/src/misc/picture.c
@@ -431,6 +431,11 @@ picture_t *picture_InternalClone(picture_t *picture, picture_gc_t *pic_gc)
clone->picture.p[i].i_lines = picture->p[i].i_lines;
clone->picture.p[i].i_pitch = picture->p[i].i_pitch;
}
+
+ /* The picture context is responsible for potentially holding the
+ * video context attached to the picture if needed. */
+ if (picture->context != NULL)
+ clone->picture.context = picture->context->copy(picture->context);
picture_Hold(picture);
return &clone->picture;
}
@@ -438,12 +443,7 @@ picture_t *picture_InternalClone(picture_t *picture, picture_gc_t *pic_gc)
picture_t *picture_Clone(picture_t *picture)
{
picture_gc_t gc = { picture_DestroyClone, picture };
- picture_t *clone = picture_InternalClone(picture, &gc);
- if (likely(clone != NULL)) {
- if (picture->context != NULL)
- clone->context = picture->context->copy(picture->context);
- }
- return clone;
+ return picture_InternalClone(picture, &gc);
}
/*****************************************************************************
--
2.26.2
More information about the vlc-devel
mailing list