vlc | branch: master | Steve Lhomme <[email protected]> | Fri Oct 18 13:59:32 2019 +0200| [3d4f30925bd45ffc6a261b9c24caed3c6dd065e4] | committer: Steve Lhomme
va_surface: create the picture context each time Rather than doing a copy each time. In other words we don't have one by laying aroung by default. > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=3d4f30925bd45ffc6a261b9c24caed3c6dd065e4 --- modules/codec/avcodec/d3d11va.c | 9 +-------- modules/codec/avcodec/dxva2.c | 9 +-------- modules/codec/avcodec/va_surface.c | 12 ++++-------- 3 files changed, 6 insertions(+), 24 deletions(-) diff --git a/modules/codec/avcodec/d3d11va.c b/modules/codec/avcodec/d3d11va.c index 796de13012..d25c8b7c34 100644 --- a/modules/codec/avcodec/d3d11va.c +++ b/modules/codec/avcodec/d3d11va.c @@ -221,10 +221,6 @@ static picture_context_t* NewSurfacePicContext(void *opaque, vlc_va_surface_t *v ID3D11Resource_Release(p_resource); if (unlikely(pic_ctx==NULL)) return NULL; - /* all the resources are acquired during surfaces init, and a second time in - * CreatePicContext(), undo one of them otherwise we need an extra release - * when the pool is emptied */ - ReleaseD3D11PictureSys(&pic_ctx->ctx.picsys); pic_ctx->va_surface = va_surface; return &pic_ctx->ctx.s; } @@ -235,15 +231,12 @@ static int Get(vlc_va_t *va, picture_t *pic, uint8_t **data) vlc_va_surface_t *va_surface = va_pool_Get(sys->va_pool); if (unlikely(va_surface == NULL)) return VLC_ENOITEM; - picture_context_t *pic_ctx = va_surface_GetContext(va_surface); - pic->context = pic_ctx->copy(pic_ctx); + pic->context = va_surface_GetContext(va_surface); if (unlikely(pic->context == NULL)) { va_surface_Release(va_surface); return VLC_ENOITEM; } - // the internal copy adds an extra reference we already had with va_pool_Get() - va_surface_Release(va_surface); *data = (uint8_t*)D3D11VA_PICCONTEXT_FROM_PICCTX(pic->context)->ctx.picsys.decoder; return VLC_SUCCESS; } diff --git a/modules/codec/avcodec/dxva2.c b/modules/codec/avcodec/dxva2.c index 193271027b..01bc28a743 100644 --- a/modules/codec/avcodec/dxva2.c +++ b/modules/codec/avcodec/dxva2.c @@ -202,10 +202,6 @@ static picture_context_t* NewSurfacePicContext(void *opaque, vlc_va_surface_t *v struct dxva2_pic_context *pic_ctx = CreatePicContext(sys->hw_surface[va_surface_GetIndex(va_surface)], sys->hw.decoder); if (unlikely(pic_ctx==NULL)) return NULL; - /* all the resources are acquired during surfaces init, and a second time in - * CreatePicContext(), undo one of them otherwise we need an extra release - * when the pool is emptied */ - ReleaseD3D9PictureSys(&pic_ctx->ctx.picsys); pic_ctx->va_surface = va_surface; return &pic_ctx->ctx.s; } @@ -228,15 +224,12 @@ static int Get(vlc_va_t *va, picture_t *pic, uint8_t **data) if (unlikely(va_surface==NULL)) return VLC_ENOITEM; - picture_context_t *pic_ctx = va_surface_GetContext(va_surface); - pic->context = pic_ctx->copy(pic_ctx); + pic->context = va_surface_GetContext(va_surface); if (unlikely(pic->context == NULL)) { va_surface_Release(va_surface); return VLC_ENOITEM; } - // the internal copy adds an extra reference we already had with va_pool_Get() - va_surface_Release(va_surface); *data = (uint8_t*)DXVA2_PICCONTEXT_FROM_PICCTX(pic->context)->ctx.picsys.surface; return VLC_SUCCESS; } diff --git a/modules/codec/avcodec/va_surface.c b/modules/codec/avcodec/va_surface.c index 9040982aa3..8edfbb7117 100644 --- a/modules/codec/avcodec/va_surface.c +++ b/modules/codec/avcodec/va_surface.c @@ -55,7 +55,6 @@ struct va_pool_t struct vlc_va_surface_t { unsigned index; atomic_uintptr_t refcount; // 1 ref for the surface existance, 1 per surface/clone in-flight - picture_context_t *pic_va_ctx; va_pool_t *va_pool; }; @@ -118,12 +117,6 @@ static int SetupSurfaces(vlc_va_t *va, va_pool_t *va_pool) goto done; p_surface->index = i; p_surface->va_pool = va_pool; - p_surface->pic_va_ctx = va_pool->callbacks.pf_new_surface_context(va_pool->callbacks.opaque, p_surface); - if (unlikely(p_surface->pic_va_ctx==NULL)) - { - free(p_surface); - goto done; - } va_pool->surface[i] = p_surface; atomic_init(&p_surface->refcount, 1); } @@ -174,7 +167,10 @@ vlc_va_surface_t *va_pool_Get(va_pool_t *va_pool) picture_context_t *va_surface_GetContext(vlc_va_surface_t *surface) { - return surface->pic_va_ctx; + picture_context_t *pic_va_ctx = surface->va_pool->callbacks.pf_new_surface_context(surface->va_pool->callbacks.opaque, surface); + if (unlikely(pic_va_ctx==NULL)) + return NULL; + return pic_va_ctx; } void va_surface_AddRef(vlc_va_surface_t *surface) _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
