BOOL APIENTRY DrvDeleteContext( DHGLRC dhglrc ) { struct stw_context *ctx ; BOOL ret = FALSE; if (!stw_dev) return FALSE; pipe_mutex_lock( stw_dev->ctx_mutex ); ctx = stw_lookup_context_locked(dhglrc); handle_table_remove(stw_dev->ctx_table, dhglrc); pipe_mutex_unlock( stw_dev->ctx_mutex ); if (ctx) { struct stw_context *curctx = stw_current_context(); /* Unbind current if deleting current context. */ if (curctx == ctx) stw_dev->stapi->make_current(stw_dev->stapi, NULL, NULL, NULL); if (ctx->hud) { hud_destroy(ctx->hud); } ctx->st->destroy(ctx->st); FREE(ctx); ret = TRUE; } return ret; }
VAStatus vlVaDestroyBuffer(VADriverContextP ctx, VABufferID buf_id) { vlVaDriver *drv; vlVaBuffer *buf; if (!ctx) return VA_STATUS_ERROR_INVALID_CONTEXT; drv = VL_VA_DRIVER(ctx); mtx_lock(&drv->mutex); buf = handle_table_get(drv->htab, buf_id); if (!buf) { mtx_unlock(&drv->mutex); return VA_STATUS_ERROR_INVALID_BUFFER; } if (buf->derived_surface.resource) pipe_resource_reference(&buf->derived_surface.resource, NULL); FREE(buf->data); FREE(buf); handle_table_remove(VL_VA_DRIVER(ctx)->htab, buf_id); mtx_unlock(&drv->mutex); return VA_STATUS_SUCCESS; }
VAStatus vlVaDestroyBuffer(VADriverContextP ctx, VABufferID buf_id) { vlVaBuffer *buf; if (!ctx) return VA_STATUS_ERROR_INVALID_CONTEXT; buf = handle_table_get(VL_VA_DRIVER(ctx)->htab, buf_id); if (!buf) return VA_STATUS_ERROR_INVALID_BUFFER; if (buf->derived_surface.resource) { if (buf->export_refcount > 0) return VA_STATUS_ERROR_INVALID_BUFFER; pipe_resource_reference(&buf->derived_surface.resource, NULL); } FREE(buf->data); FREE(buf); handle_table_remove(VL_VA_DRIVER(ctx)->htab, buf_id); return VA_STATUS_SUCCESS; }
VAStatus vlVaDestroyConfig(VADriverContextP ctx, VAConfigID config_id) { vlVaDriver *drv; vlVaConfig *config; if (!ctx) return VA_STATUS_ERROR_INVALID_CONTEXT; drv = VL_VA_DRIVER(ctx); if (!drv) return VA_STATUS_ERROR_INVALID_CONTEXT; pipe_mutex_lock(drv->mutex); config = handle_table_get(drv->htab, config_id); if (!config) return VA_STATUS_ERROR_INVALID_CONFIG; FREE(config); handle_table_remove(drv->htab, config_id); pipe_mutex_unlock(drv->mutex); return VA_STATUS_SUCCESS; }
VAStatus vlVaDestroySurfaces(VADriverContextP ctx, VASurfaceID *surface_list, int num_surfaces) { vlVaDriver *drv; int i; if (!ctx) return VA_STATUS_ERROR_INVALID_CONTEXT; drv = VL_VA_DRIVER(ctx); pipe_mutex_lock(drv->mutex); for (i = 0; i < num_surfaces; ++i) { vlVaSurface *surf = handle_table_get(drv->htab, surface_list[i]); if (!surf) { pipe_mutex_unlock(drv->mutex); return VA_STATUS_ERROR_INVALID_SURFACE; } if (surf->buffer) surf->buffer->destroy(surf->buffer); util_dynarray_fini(&surf->subpics); FREE(surf); handle_table_remove(drv->htab, surface_list[i]); } pipe_mutex_unlock(drv->mutex); return VA_STATUS_SUCCESS; }
VAStatus vlVaDestroyContext(VADriverContextP ctx, VAContextID context_id) { vlVaDriver *drv; vlVaContext *context; if (!ctx) return VA_STATUS_ERROR_INVALID_CONTEXT; drv = VL_VA_DRIVER(ctx); context = handle_table_get(drv->htab, context_id); if (context->decoder) { if (u_reduce_video_profile(context->decoder->profile) == PIPE_VIDEO_FORMAT_MPEG4_AVC) { FREE(context->desc.h264.pps->sps); FREE(context->desc.h264.pps); } if (u_reduce_video_profile(context->decoder->profile) == PIPE_VIDEO_FORMAT_HEVC) { FREE(context->desc.h265.pps->sps); FREE(context->desc.h265.pps); } context->decoder->destroy(context->decoder); } FREE(context); handle_table_remove(drv->htab, context_id); return VA_STATUS_SUCCESS; }
void vlRemoveDataHTAB(vlHandle handle) { #ifdef VL_HANDLES pipe_mutex_lock(htab_lock); if (htab) handle_table_remove(htab, handle); pipe_mutex_unlock(htab_lock); #endif }
VAStatus vlVaDestroyImage(VADriverContextP ctx, VAImageID image) { VAImage *vaimage; if (!ctx) return VA_STATUS_ERROR_INVALID_CONTEXT; vaimage = handle_table_get(VL_VA_DRIVER(ctx)->htab, image); if (!vaimage) return VA_STATUS_ERROR_INVALID_IMAGE; handle_table_remove(VL_VA_DRIVER(ctx)->htab, image); FREE(vaimage); return vlVaDestroyBuffer(ctx, vaimage->buf); }
VAStatus vlVaDestroyBuffer(VADriverContextP ctx, VABufferID buf_id) { vlVaBuffer *buf; if (!ctx) return VA_STATUS_ERROR_INVALID_CONTEXT; buf = handle_table_get(VL_VA_DRIVER(ctx)->htab, buf_id); if (!buf) return VA_STATUS_ERROR_INVALID_BUFFER; FREE(buf->data); FREE(buf); handle_table_remove(VL_VA_DRIVER(ctx)->htab, buf_id); return VA_STATUS_SUCCESS; }
VAStatus vlVaDestroyContext(VADriverContextP ctx, VAContextID context_id) { vlVaDriver *drv; vlVaContext *context; if (!ctx) return VA_STATUS_ERROR_INVALID_CONTEXT; drv = VL_VA_DRIVER(ctx); pipe_mutex_lock(drv->mutex); context = handle_table_get(drv->htab, context_id); if (!context) { pipe_mutex_unlock(drv->mutex); return VA_STATUS_ERROR_INVALID_CONTEXT; } if (context->decoder) { if (context->desc.base.entry_point != PIPE_VIDEO_ENTRYPOINT_ENCODE) { if (u_reduce_video_profile(context->decoder->profile) == PIPE_VIDEO_FORMAT_MPEG4_AVC) { FREE(context->desc.h264.pps->sps); FREE(context->desc.h264.pps); } if (u_reduce_video_profile(context->decoder->profile) == PIPE_VIDEO_FORMAT_HEVC) { FREE(context->desc.h265.pps->sps); FREE(context->desc.h265.pps); } } context->decoder->destroy(context->decoder); } if (context->deint) { vl_deint_filter_cleanup(context->deint); FREE(context->deint); } FREE(context); handle_table_remove(drv->htab, context_id); pipe_mutex_unlock(drv->mutex); return VA_STATUS_SUCCESS; }
VAStatus vlVaDestroyImage(VADriverContextP ctx, VAImageID image) { vlVaDriver *drv; VAImage *vaimage; if (!ctx) return VA_STATUS_ERROR_INVALID_CONTEXT; drv = VL_VA_DRIVER(ctx); pipe_mutex_lock(drv->mutex); vaimage = handle_table_get(drv->htab, image); if (!vaimage) { pipe_mutex_unlock(drv->mutex); return VA_STATUS_ERROR_INVALID_IMAGE; } handle_table_remove(VL_VA_DRIVER(ctx)->htab, image); pipe_mutex_unlock(drv->mutex); FREE(vaimage); return vlVaDestroyBuffer(ctx, vaimage->buf); }
VAStatus vlVaDestroySurfaces(VADriverContextP ctx, VASurfaceID *surface_list, int num_surfaces) { vlVaDriver *drv; int i; if (!ctx) return VA_STATUS_ERROR_INVALID_CONTEXT; drv = VL_VA_DRIVER(ctx); for (i = 0; i < num_surfaces; ++i) { vlVaSurface *surf = handle_table_get(drv->htab, surface_list[i]); if (surf->buffer) surf->buffer->destroy(surf->buffer); if(surf->fence) drv->pipe->screen->fence_reference(drv->pipe->screen, &surf->fence, NULL); util_dynarray_fini(&surf->subpics); FREE(surf); handle_table_remove(drv->htab, surface_list[i]); } return VA_STATUS_SUCCESS; }