vlc | branch: master | Steve Lhomme <[email protected]> | Mon Jul 22 13:47:54 2019 +0200| [9d9918797287dbc8c374659cfb640455fcb4a7e9] | committer: Steve Lhomme
avcodec: vaapi: allocate output pictures locally The pictures are similar to the ones created in the OpenGL converter. > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=9d9918797287dbc8c374659cfb640455fcb4a7e9 --- modules/codec/avcodec/vaapi.c | 26 ++++++++++++++++---------- modules/hw/vaapi/vlc_vaapi.c | 9 --------- modules/hw/vaapi/vlc_vaapi.h | 5 ----- 3 files changed, 16 insertions(+), 24 deletions(-) diff --git a/modules/codec/avcodec/vaapi.c b/modules/codec/avcodec/vaapi.c index 2b2783e559..bb736083fd 100644 --- a/modules/codec/avcodec/vaapi.c +++ b/modules/codec/avcodec/vaapi.c @@ -51,6 +51,8 @@ struct vlc_va_sys_t { 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, @@ -136,6 +138,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); free(sys); @@ -163,21 +166,22 @@ static int Create(vlc_va_t *va, AVCodecContext *ctx, const AVPixFmtDescriptor *d VADisplay va_dpy = dec_device->opaque; - 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; + video_format_t fmt_video = fmt->video; + fmt_video.i_chroma = i_vlc_chroma; + + 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->hw_ctx.display = va_dpy; sys->hw_ctx.config_id = VA_INVALID_ID; @@ -193,7 +197,7 @@ static int Create(vlc_va_t *va, AVCodecContext *ctx, const AVPixFmtDescriptor *d 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; @@ -205,6 +209,8 @@ static int Create(vlc_va_t *va, AVCodecContext *ctx, const AVPixFmtDescriptor *d 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) diff --git a/modules/hw/vaapi/vlc_vaapi.c b/modules/hw/vaapi/vlc_vaapi.c index 05184a013b..1e603bb8fc 100644 --- a/modules/hw/vaapi/vlc_vaapi.c +++ b/modules/hw/vaapi/vlc_vaapi.c @@ -570,15 +570,6 @@ error: return NULL; } -unsigned -vlc_vaapi_PicSysGetRenderTargets(void *_sys, VASurfaceID **render_targets) -{ - picture_sys_t *sys = (picture_sys_t *)_sys; - assert(sys && sys->instance); - *render_targets = sys->instance->render_targets; - return sys->instance->num_render_targets; -} - vlc_decoder_device * vlc_vaapi_PicSysHoldInstance(void *_sys, VADisplay *dpy) { diff --git a/modules/hw/vaapi/vlc_vaapi.h b/modules/hw/vaapi/vlc_vaapi.h index ede4ff01dd..e72caa0350 100644 --- a/modules/hw/vaapi/vlc_vaapi.h +++ b/modules/hw/vaapi/vlc_vaapi.h @@ -166,11 +166,6 @@ vlc_vaapi_PoolNew(vlc_object_t *o, vlc_decoder_device *dec_device, VADisplay dpy, unsigned count, VASurfaceID **render_targets, const video_format_t *restrict fmt, bool b_force_fourcc); -/* Get render targets from a pic_sys allocated by the vaapi pool (see - * vlc_vaapi_PoolNew()) */ -unsigned -vlc_vaapi_PicSysGetRenderTargets(void *sys, VASurfaceID **render_targets); - /* Get and hold the VADisplay instance attached to the picture sys */ vlc_decoder_device * vlc_vaapi_PicSysHoldInstance(void *sys, VADisplay *dpy); _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
