[vlc-commits] vdpau: factor pool creation
Rémi Denis-Courmont
git at videolan.org
Mon Dec 24 18:23:20 CET 2018
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon Dec 24 16:40:05 2018 +0200| [9dfeb4952a5927d8fb50a6db4951827d055ddcf8] | committer: Rémi Denis-Courmont
vdpau: factor pool creation
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=9dfeb4952a5927d8fb50a6db4951827d055ddcf8
---
modules/hw/vdpau/display.c | 35 ++++-----------------------
modules/hw/vdpau/picture.c | 28 +++++++++++++++++++++
modules/hw/vdpau/vlc_vdpau.h | 7 ++++--
modules/video_output/opengl/converter_vdpau.c | 28 ++-------------------
4 files changed, 40 insertions(+), 58 deletions(-)
diff --git a/modules/hw/vdpau/display.c b/modules/hw/vdpau/display.c
index 25db2e28ae..cee2cbd8cb 100644
--- a/modules/hw/vdpau/display.c
+++ b/modules/hw/vdpau/display.c
@@ -70,35 +70,6 @@ struct vout_display_sys_t
unsigned height;
};
-static picture_pool_t *PoolAlloc(vout_display_t *vd, unsigned requested_count)
-{
- vout_display_sys_t *sys = vd->sys;
- picture_t *pics[requested_count];
-
- unsigned count = 0;
- while (count < requested_count)
- {
- pics[count] = vlc_vdp_output_surface_create(sys->vdp, sys->rgb_fmt,
- &vd->fmt);
- if (pics[count] == NULL)
- {
- msg_Err(vd, "%s creation failure", "output surface");
- break;
- }
- count++;
- }
- sys->current = NULL;
-
- if (count == 0)
- return NULL;
-
- picture_pool_t *pool = picture_pool_New(count, pics);
- if (unlikely(pool == NULL))
- while (count > 0)
- picture_Release(pics[--count]);
- return pool;
-}
-
static void PoolFree(vout_display_t *vd, picture_pool_t *pool)
{
vout_display_sys_t *sys = vd->sys;
@@ -113,7 +84,11 @@ static picture_pool_t *Pool(vout_display_t *vd, unsigned requested_count)
vout_display_sys_t *sys = vd->sys;
if (sys->pool == NULL)
- sys->pool = PoolAlloc(vd, requested_count);
+ {
+ sys->current = NULL;
+ sys->pool = vlc_vdp_output_pool_create(sys->vdp, sys->rgb_fmt,
+ &vd->fmt, requested_count);
+ }
return sys->pool;
}
diff --git a/modules/hw/vdpau/picture.c b/modules/hw/vdpau/picture.c
index be1940ab22..cbc5c21ec4 100644
--- a/modules/hw/vdpau/picture.c
+++ b/modules/hw/vdpau/picture.c
@@ -28,6 +28,7 @@
#include <assert.h>
#include <vlc_common.h>
#include <vlc_picture.h>
+#include <vlc_picture_pool.h>
#include "vlc_vdpau.h"
#pragma GCC visibility push(default)
@@ -136,6 +137,7 @@ static void vlc_vdp_output_surface_destroy(picture_t *pic)
free(sys);
}
+static
picture_t *vlc_vdp_output_surface_create(vdp_t *vdp, VdpRGBAFormat rgb_fmt,
const video_format_t *restrict fmt)
{
@@ -144,6 +146,7 @@ picture_t *vlc_vdp_output_surface_create(vdp_t *vdp, VdpRGBAFormat rgb_fmt,
return NULL;
sys->vdp = vdp_hold_x11(vdp, &sys->device);
+ sys->gl_nv_surface = 0;
VdpStatus err = vdp_output_surface_create(vdp, sys->device, rgb_fmt,
fmt->i_visible_width, fmt->i_visible_height, &sys->surface);
@@ -168,3 +171,28 @@ error:
}
return pic;
}
+
+picture_pool_t *vlc_vdp_output_pool_create(vdp_t *vdp, VdpRGBAFormat rgb_fmt,
+ const video_format_t *restrict fmt,
+ unsigned requested_count)
+{
+ picture_t *pics[requested_count];
+ unsigned count = 0;
+
+ while (count < requested_count)
+ {
+ pics[count] = vlc_vdp_output_surface_create(vdp, rgb_fmt, fmt);
+ if (pics[count] == NULL)
+ break;
+ count++;
+ }
+
+ if (count == 0)
+ return NULL;
+
+ picture_pool_t *pool = picture_pool_New(count, pics);
+ if (unlikely(pool == NULL))
+ while (count > 0)
+ picture_Release(pics[--count]);
+ return pool;
+}
diff --git a/modules/hw/vdpau/vlc_vdpau.h b/modules/hw/vdpau/vlc_vdpau.h
index 83c53d92b9..d0e8bde787 100644
--- a/modules/hw/vdpau/vlc_vdpau.h
+++ b/modules/hw/vdpau/vlc_vdpau.h
@@ -307,7 +307,10 @@ typedef struct vlc_vdp_output_surface
ptrdiff_t gl_nv_surface;
} vlc_vdp_output_surface_t;
-picture_t *vlc_vdp_output_surface_create(vdp_t *vdp, VdpRGBAFormat rgb_fmt,
- const video_format_t *restrict fmt);
+struct picture_pool_t;
+
+struct picture_pool_t *vlc_vdp_output_pool_create(vdp_t *, VdpRGBAFormat,
+ const video_format_t *,
+ unsigned count);
#endif
diff --git a/modules/video_output/opengl/converter_vdpau.c b/modules/video_output/opengl/converter_vdpau.c
index cdf0f0434d..76d1d0a5b5 100644
--- a/modules/video_output/opengl/converter_vdpau.c
+++ b/modules/video_output/opengl/converter_vdpau.c
@@ -61,32 +61,8 @@ static picture_pool_t *
tc_vdpau_gl_get_pool(opengl_tex_converter_t const *tc,
unsigned int requested_count)
{
- vdp_t *vdp = tc->priv;
- picture_t *pics[requested_count];
-
- unsigned int i;
- for (i = 0; i < requested_count; ++i)
- {
- pics[i] = vlc_vdp_output_surface_create(vdp, VDP_RGBA_FORMAT_B8G8R8A8,
- &tc->fmt);
- if (pics[i] == NULL)
- goto error;
-
- vlc_vdp_output_surface_t *picsys = pics[i]->p_sys;
-
- picsys->gl_nv_surface = 0;
- }
-
- picture_pool_t *pool = picture_pool_New(requested_count, pics);
- if (!pool)
- goto error;
-
- return pool;
-
-error:
- while (i--)
- picture_Release(pics[i]);
- return NULL;
+ return vlc_vdp_output_pool_create(tc->priv, VDP_RGBA_FORMAT_B8G8R8A8,
+ &tc->fmt, requested_count);
}
static int
More information about the vlc-commits
mailing list