[vlc-devel] [PATCH 4/8] picture_pool: initialize with an external cancelable structure
Steve Lhomme
robux4 at ycbcr.xyz
Mon Jul 27 15:45:25 CEST 2020
---
include/vlc_picture_pool.h | 8 ++++++--
modules/codec/qsv.c | 2 +-
modules/hw/nvdec/nvdec.c | 2 +-
src/input/decoder.c | 3 ++-
src/misc/picture_pool.c | 15 +++++++++++----
src/test/picture_pool.c | 4 ++--
src/video_output/display.c | 2 +-
src/video_output/vout_wrapper.c | 3 ++-
8 files changed, 26 insertions(+), 13 deletions(-)
diff --git a/include/vlc_picture_pool.h b/include/vlc_picture_pool.h
index 70617aa660a..db9a74833ed 100644
--- a/include/vlc_picture_pool.h
+++ b/include/vlc_picture_pool.h
@@ -50,12 +50,14 @@ typedef struct picture_pool_t picture_pool_t;
*
* @param count number of pictures in the array
* @param tab array of pictures
+ * @param pool_cancel structure used to cancel the pool when it's waiting
*
* @return a pointer to the new pool on success, or NULL on error
* (pictures are <b>not</b> released on error)
*/
VLC_API picture_pool_t * picture_pool_New(unsigned count,
- picture_t *const *tab) VLC_USED;
+ picture_t *const *tab,
+ vlc_cancelable *pool_cancel) VLC_USED;
/**
* Allocates pictures from the heap and creates a picture pool with them.
@@ -64,11 +66,13 @@ VLC_API picture_pool_t * picture_pool_New(unsigned count,
*
* @param fmt video format of pictures to allocate from the heap
* @param count number of pictures to allocate
+ * @param pool_cancel structure used to cancel the pool when it's waiting
*
* @return a pointer to the new pool on success, NULL on error
*/
VLC_API picture_pool_t * picture_pool_NewFromFormat(const video_format_t *fmt,
- unsigned count) VLC_USED;
+ unsigned count,
+ vlc_cancelable *pool_cancel) VLC_USED;
/**
* Releases a pool created by picture_pool_New()
diff --git a/modules/codec/qsv.c b/modules/codec/qsv.c
index 8571b499dc9..b2a0e94d41f 100644
--- a/modules/codec/qsv.c
+++ b/modules/codec/qsv.c
@@ -559,7 +559,7 @@ static int Open(vlc_object_t *this)
video_format_t pool_fmt = enc->fmt_in.video;
pool_fmt.i_width = sys->params.mfx.FrameInfo.Width;
pool_fmt.i_height = sys->params.mfx.FrameInfo.Height;
- sys->input_pool = picture_pool_NewFromFormat( &pool_fmt, 18 );
+ sys->input_pool = picture_pool_NewFromFormat( &pool_fmt, 18, NULL );
if (sys->input_pool == NULL)
{
msg_Err(enc, "Failed to create the internal pool");
diff --git a/modules/hw/nvdec/nvdec.c b/modules/hw/nvdec/nvdec.c
index acf8e06a15d..54a9c849b50 100644
--- a/modules/hw/nvdec/nvdec.c
+++ b/modules/hw/nvdec/nvdec.c
@@ -186,7 +186,7 @@ static nvdec_pool_t* nvdec_pool_Create(vlc_video_context *vctx,
goto free_pool;
}
- pool->picture_pool = picture_pool_New(ARRAY_SIZE(pool->outputDevicePtr), pics);
+ pool->picture_pool = picture_pool_New(ARRAY_SIZE(pool->outputDevicePtr), pics, NULL);
if (!pool->picture_pool)
goto free_pool;
diff --git a/src/input/decoder.c b/src/input/decoder.c
index d24fa8feb34..7fa1e07f3ae 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -454,7 +454,8 @@ static int ModuleThread_UpdateVideoFormat( decoder_t *p_dec, vlc_video_context *
}
p_owner->out_pool = picture_pool_NewFromFormat( &p_dec->fmt_out.video,
- dpb_size + p_dec->i_extra_picture_buffers + 1 );
+ dpb_size + p_dec->i_extra_picture_buffers + 1,
+ NULL );
if (p_owner->out_pool == NULL)
{
msg_Err(p_dec, "Failed to create a pool of %d %4.4s pictures",
diff --git a/src/misc/picture_pool.c b/src/misc/picture_pool.c
index 82b49ebd4c4..b3034ad71e5 100644
--- a/src/misc/picture_pool.c
+++ b/src/misc/picture_pool.c
@@ -93,7 +93,8 @@ static picture_t *picture_pool_ClonePicture(picture_pool_t *pool,
(void*)sys);
}
-picture_pool_t *picture_pool_New(unsigned count, picture_t *const *tab)
+picture_pool_t *picture_pool_New(unsigned count, picture_t *const *tab,
+ vlc_cancelable *pool_cancel)
{
if (unlikely(count > POOL_MAX))
return NULL;
@@ -106,8 +107,13 @@ picture_pool_t *picture_pool_New(unsigned count, picture_t *const *tab)
if (unlikely(pool == NULL))
return NULL;
+ if (pool_cancel)
+ pool->cancelable = pool_cancel;
+ else
+ {
vlc_cancelable_Init( &pool->cancel );
pool->cancelable = &pool->cancel;
+ }
if (count == POOL_MAX)
pool->available = ~0ULL;
@@ -120,7 +126,8 @@ picture_pool_t *picture_pool_New(unsigned count, picture_t *const *tab)
}
picture_pool_t *picture_pool_NewFromFormat(const video_format_t *fmt,
- unsigned count)
+ unsigned count,
+ vlc_cancelable *pool_cancel)
{
picture_t *picture[count ? count : 1];
unsigned i;
@@ -131,7 +138,7 @@ picture_pool_t *picture_pool_NewFromFormat(const video_format_t *fmt,
goto error;
}
- picture_pool_t *pool = picture_pool_New(count, picture);
+ picture_pool_t *pool = picture_pool_New(count, picture, pool_cancel);
if (!pool)
goto error;
@@ -154,7 +161,7 @@ picture_pool_t *picture_pool_Reserve(picture_pool_t *master, unsigned count)
goto error;
}
- picture_pool_t *pool = picture_pool_New(count, picture);
+ picture_pool_t *pool = picture_pool_New(count, picture, NULL);
if (!pool)
goto error;
diff --git a/src/test/picture_pool.c b/src/test/picture_pool.c
index af2d36a06b2..a853fd6d0da 100644
--- a/src/test/picture_pool.c
+++ b/src/test/picture_pool.c
@@ -41,7 +41,7 @@ static void test(bool zombie)
{
picture_t *pics[PICTURES];
- pool = picture_pool_NewFromFormat(&fmt, PICTURES);
+ pool = picture_pool_NewFromFormat(&fmt, PICTURES, NULL);
assert(pool != NULL);
for (unsigned i = 0; i < PICTURES; i++) {
@@ -112,7 +112,7 @@ int main(void)
{
video_format_Setup(&fmt, VLC_CODEC_I420, 320, 200, 320, 200, 1, 1);
- pool = picture_pool_NewFromFormat(&fmt, PICTURES);
+ pool = picture_pool_NewFromFormat(&fmt, PICTURES, NULL);
assert(pool != NULL);
assert(picture_pool_GetSize(pool) == PICTURES);
diff --git a/src/video_output/display.c b/src/video_output/display.c
index 8fd444168d0..d23891f6eae 100644
--- a/src/video_output/display.c
+++ b/src/video_output/display.c
@@ -426,7 +426,7 @@ picture_pool_t *vout_GetPool(vout_display_t *vd, unsigned count)
vout_display_priv_t *osys = container_of(vd, vout_display_priv_t, display);
if (osys->pool == NULL)
- osys->pool = picture_pool_NewFromFormat(&vd->fmt, count);
+ osys->pool = picture_pool_NewFromFormat(&vd->fmt, count, NULL);
return osys->pool;
}
diff --git a/src/video_output/vout_wrapper.c b/src/video_output/vout_wrapper.c
index 6445f99b7a2..90d6ec3dc21 100644
--- a/src/video_output/vout_wrapper.c
+++ b/src/video_output/vout_wrapper.c
@@ -104,7 +104,8 @@ vout_display_t *vout_OpenWrapper(vout_thread_t *vout, vout_thread_private_t *sys
sys->private_pool =
picture_pool_NewFromFormat(&vd->source,
__MAX(VOUT_MAX_PICTURES,
- reserved_picture - DISPLAY_PICTURE_COUNT));
+ reserved_picture - DISPLAY_PICTURE_COUNT),
+ NULL);
}
if (sys->private_pool == NULL) {
picture_pool_Release(display_pool);
--
2.26.2
More information about the vlc-devel
mailing list