[vlc-devel] [PATCH 22/32] avcodec: vaapi: allocate output pictures locally
Steve Lhomme
robux4 at ycbcr.xyz
Thu Sep 26 16:00:13 CEST 2019
The pictures are similar to the ones created in the OpenGL converter.
---
modules/codec/avcodec/vaapi.c | 23 +++++++++++++----------
1 file changed, 13 insertions(+), 10 deletions(-)
diff --git a/modules/codec/avcodec/vaapi.c b/modules/codec/avcodec/vaapi.c
index 5dee6687d40..569fc6cec81 100644
--- a/modules/codec/avcodec/vaapi.c
+++ b/modules/codec/avcodec/vaapi.c
@@ -52,6 +52,8 @@ struct vlc_va_sys_t
{
vlc_decoder_device *dec_device;
struct vaapi_context hw_ctx;
+ /* mimick what is done in the decoder pool from the display for now */
+ picture_pool_t *picture_pool;
};
static int GetVaProfile(const AVCodecContext *ctx, const es_format_t *fmt,
@@ -137,6 +139,7 @@ static void Delete(vlc_va_t *va)
vlc_va_sys_t *sys = va->sys;
vlc_object_t *o = VLC_OBJECT(va);
+ picture_pool_Release(sys->picture_pool);
vlc_vaapi_DestroyContext(o, sys->hw_ctx.display, sys->hw_ctx.context_id);
vlc_vaapi_DestroyConfig(o, sys->hw_ctx.display, sys->hw_ctx.config_id);
vlc_decoder_device_Release(sys->dec_device);
@@ -165,21 +168,19 @@ static int Create(vlc_va_t *va, AVCodecContext *ctx, enum PixelFormat pix_fmt,
vlc_decoder_device *dec_device =
vlc_vaapi_PicSysHoldInstance(p_sys, &va_dpy);
- VASurfaceID *render_targets;
- unsigned num_render_targets;
-#if 0 // TODO create the render targets locally
- num_render_targets =
- vlc_vaapi_PicSysGetRenderTargets(p_sys, &render_targets);
- if (num_render_targets == 0)
- goto error;
-#endif
-
VAProfile i_profile;
unsigned count;
int i_vlc_chroma;
if (GetVaProfile(ctx, fmt, &i_profile, &i_vlc_chroma, &count) != VLC_SUCCESS)
goto error;
+ VASurfaceID *render_targets;
+ sys->picture_pool =
+ vlc_vaapi_PoolNew(VLC_OBJECT(va), dec_device, va_dpy, count,
+ &render_targets, &fmt->video, true);
+ if (sys->picture_pool == NULL)
+ goto error;
+
/* */
sys->dec_device = dec_device;
sys->hw_ctx.display = va_dpy;
@@ -196,7 +197,7 @@ static int Create(vlc_va_t *va, AVCodecContext *ctx, enum PixelFormat pix_fmt,
sys->hw_ctx.context_id =
vlc_vaapi_CreateContext(o, sys->hw_ctx.display, sys->hw_ctx.config_id,
ctx->coded_width, ctx->coded_height, VA_PROGRESSIVE,
- render_targets, num_render_targets);
+ render_targets, count);
if (sys->hw_ctx.context_id == VA_INVALID_ID)
goto error;
@@ -208,6 +209,8 @@ static int Create(vlc_va_t *va, AVCodecContext *ctx, enum PixelFormat pix_fmt,
return VLC_SUCCESS;
error:
+ if (sys->picture_pool != NULL)
+ picture_pool_Release(sys->picture_pool);
if (sys->hw_ctx.context_id != VA_INVALID_ID)
vlc_vaapi_DestroyContext(o, sys->hw_ctx.display, sys->hw_ctx.context_id);
if (sys->hw_ctx.config_id != VA_INVALID_ID)
--
2.17.1
More information about the vlc-devel
mailing list