[vlc-devel] [PATCH 2/9] avcodec: vdpau: allocate output pictures locally

Steve Lhomme robux4 at ycbcr.xyz
Fri Oct 18 17:11:07 CEST 2019


The pictures are similar to the ones created in the OpenGL converter.

!! There might be a lifecycle issue when releasing the decoder module and
pictures are still "in-flight". We will need to keep the module and pool alive
as long as pictures are alive, or keep the resources allocated tied to the
video context so they are released together.
---
 modules/hw/vdpau/avcodec.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/modules/hw/vdpau/avcodec.c b/modules/hw/vdpau/avcodec.c
index ae10789249a..9f66cd72167 100644
--- a/modules/hw/vdpau/avcodec.c
+++ b/modules/hw/vdpau/avcodec.c
@@ -36,6 +36,7 @@
 #include <vlc_fourcc.h>
 #include <vlc_picture.h>
 #include <vlc_codec.h>
+#include <vlc_picture_pool.h>
 #include <vlc_xlib.h>
 #include "vlc_vdpau.h"
 #include "../../codec/avcodec/va.h"
@@ -49,6 +50,8 @@ struct vlc_va_sys_t
     uint32_t width;
     uint32_t height;
     vlc_video_context *vctx;
+    /* until we can allocate pictures and provide a picture_sys without a VdpOutputSurface */
+    picture_pool_t *picture_pool;
     vlc_vdp_video_field_t *pool[];
 };
 
@@ -124,6 +127,7 @@ static void Close(vlc_va_t *va)
 {
     vlc_va_sys_t *sys = va->sys;
 
+    picture_pool_Release(sys->picture_pool);
     for (unsigned i = 0; sys->pool[i] != NULL; i++)
         vlc_vdp_video_destroy(sys->pool[i]);
     vdp_release_x11(sys->vdp);
@@ -222,6 +226,12 @@ static int Open(vlc_va_t *va, AVCodecContext *avctx, const AVPixFmtDescriptor *d
         msg_Warn(va, "video RAM low (allocated %u of %u buffers)",
                  i, refs);
 
+    /* similar to the pool found in converter_vdpau */
+    sys->picture_pool = vlc_vdp_output_pool_create(sys->vdp,
+                            VDP_RGBA_FORMAT_B8G8R8A8, &fmt->video, i);
+    if (sys->picture_pool == NULL)
+        goto error;
+
     const char *infos;
     if (vdp_get_information_string(sys->vdp, &infos) == VDP_STATUS_OK)
         msg_Info(va, "Using %s", infos);
@@ -231,6 +241,8 @@ static int Open(vlc_va_t *va, AVCodecContext *avctx, const AVPixFmtDescriptor *d
     return VLC_SUCCESS;
 
 error:
+    if (sys->picture_pool)
+        picture_pool_Release(sys->picture_pool);
     if (sys->hwaccel_context)
         av_free(sys->hwaccel_context);
     vdp_release_x11(sys->vdp);
-- 
2.17.1



More information about the vlc-devel mailing list