X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fgallium%2Fstate_trackers%2Fva%2Fcontext.c;h=f2cb37aa22a71e0c633cf86116a67ad19afe9775;hb=f8e42237283d2b4ec829449adbbcfc9e51ac8756;hp=8882cbaf11658ee6cc389f299df60df7b4524361;hpb=5bcaa1b9e9707aea7be73b406345bb9e46f92a18;p=mesa.git diff --git a/src/gallium/state_trackers/va/context.c b/src/gallium/state_trackers/va/context.c index 8882cbaf116..f2cb37aa22a 100644 --- a/src/gallium/state_trackers/va/context.c +++ b/src/gallium/state_trackers/va/context.c @@ -103,7 +103,6 @@ PUBLIC VAStatus VA_DRIVER_INIT_FUNC(VADriverContextP ctx) { vlVaDriver *drv; - struct drm_state *drm_info; if (!ctx) return VA_STATUS_ERROR_INVALID_CONTEXT; @@ -118,18 +117,14 @@ VA_DRIVER_INIT_FUNC(VADriverContextP ctx) return VA_STATUS_ERROR_UNIMPLEMENTED; case VA_DISPLAY_GLX: case VA_DISPLAY_X11: -#if defined(HAVE_DRI3) drv->vscreen = vl_dri3_screen_create(ctx->native_dpy, ctx->x11_screen); -#endif if (!drv->vscreen) drv->vscreen = vl_dri2_screen_create(ctx->native_dpy, ctx->x11_screen); - if (!drv->vscreen) - goto error_screen; break; case VA_DISPLAY_WAYLAND: case VA_DISPLAY_DRM: case VA_DISPLAY_DRM_RENDERNODES: { - drm_info = (struct drm_state *) ctx->drm_state; + const struct drm_state *drm_info = (struct drm_state *) ctx->drm_state; if (!drm_info || drm_info->fd < 0) { FREE(drv); @@ -137,17 +132,18 @@ VA_DRIVER_INIT_FUNC(VADriverContextP ctx) } drv->vscreen = vl_drm_screen_create(drm_info->fd); - if (!drv->vscreen) - goto error_screen; - } break; + } default: FREE(drv); return VA_STATUS_ERROR_INVALID_DISPLAY; } + if (!drv->vscreen) + goto error_screen; + drv->pipe = drv->vscreen->pscreen->context_create(drv->vscreen->pscreen, - drv->vscreen, 0); + NULL, 0); if (!drv->pipe) goto error_pipe; @@ -155,12 +151,15 @@ VA_DRIVER_INIT_FUNC(VADriverContextP ctx) if (!drv->htab) goto error_htab; - vl_compositor_init(&drv->compositor, drv->pipe); - vl_compositor_init_state(&drv->cstate, drv->pipe); + if (!vl_compositor_init(&drv->compositor, drv->pipe)) + goto error_compositor; + if (!vl_compositor_init_state(&drv->cstate, drv->pipe)) + goto error_compositor_state; vl_csc_get_matrix(VL_CSC_COLOR_STANDARD_BT_601, NULL, true, &drv->csc); - vl_compositor_set_csc_matrix(&drv->cstate, (const vl_csc_matrix *)&drv->csc, 1.0f, 0.0f); - pipe_mutex_init(drv->mutex); + if (!vl_compositor_set_csc_matrix(&drv->cstate, (const vl_csc_matrix *)&drv->csc, 1.0f, 0.0f)) + goto error_csc_matrix; + (void) mtx_init(&drv->mutex, mtx_plain); ctx->pDriverData = (void *)drv; ctx->version_major = 0; @@ -168,7 +167,7 @@ VA_DRIVER_INIT_FUNC(VADriverContextP ctx) *ctx->vtable = vtable; *ctx->vtable_vpp = vtable_vpp; ctx->max_profiles = PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH - PIPE_VIDEO_PROFILE_UNKNOWN; - ctx->max_entrypoints = 1; + ctx->max_entrypoints = 2; ctx->max_attributes = 1; ctx->max_image_formats = VL_VA_MAX_IMAGE_FORMATS; ctx->max_subpic_formats = 1; @@ -177,6 +176,15 @@ VA_DRIVER_INIT_FUNC(VADriverContextP ctx) return VA_STATUS_SUCCESS; +error_csc_matrix: + vl_compositor_cleanup_state(&drv->cstate); + +error_compositor_state: + vl_compositor_cleanup(&drv->compositor); + +error_compositor: + handle_table_destroy(drv->htab); + error_htab: drv->pipe->destroy(drv->pipe); @@ -202,9 +210,9 @@ vlVaCreateContext(VADriverContextP ctx, VAConfigID config_id, int picture_width, return VA_STATUS_ERROR_INVALID_CONTEXT; drv = VL_VA_DRIVER(ctx); - pipe_mutex_lock(drv->mutex); + mtx_lock(&drv->mutex); config = handle_table_get(drv->htab, config_id); - pipe_mutex_unlock(drv->mutex); + mtx_unlock(&drv->mutex); is_vpp = config->profile == PIPE_VIDEO_PROFILE_UNKNOWN && !picture_width && !picture_height && !flag && !render_targets && !num_render_targets; @@ -218,10 +226,6 @@ vlVaCreateContext(VADriverContextP ctx, VAConfigID config_id, int picture_width, if (is_vpp) { context->decoder = NULL; - if (!drv->compositor.upload) { - FREE(context); - return VA_STATUS_ERROR_INVALID_CONTEXT; - } } else { context->templat.profile = config->profile; context->templat.entrypoint = config->entrypoint; @@ -276,10 +280,14 @@ vlVaCreateContext(VADriverContextP ctx, VAConfigID config_id, int picture_width, context->desc.base.profile = config->profile; context->desc.base.entry_point = config->entrypoint; + if (config->entrypoint == PIPE_VIDEO_ENTRYPOINT_ENCODE) { + context->desc.h264enc.rate_ctrl.rate_ctrl_method = config->rc; + context->desc.h264enc.frame_idx = util_hash_table_create(handle_hash, handle_compare); + } - pipe_mutex_lock(drv->mutex); + mtx_lock(&drv->mutex); *context_id = handle_table_add(drv->htab, context); - pipe_mutex_unlock(drv->mutex); + mtx_unlock(&drv->mutex); return VA_STATUS_SUCCESS; } @@ -294,15 +302,18 @@ vlVaDestroyContext(VADriverContextP ctx, VAContextID context_id) return VA_STATUS_ERROR_INVALID_CONTEXT; drv = VL_VA_DRIVER(ctx); - pipe_mutex_lock(drv->mutex); + mtx_lock(&drv->mutex); context = handle_table_get(drv->htab, context_id); if (!context) { - pipe_mutex_unlock(drv->mutex); + mtx_unlock(&drv->mutex); return VA_STATUS_ERROR_INVALID_CONTEXT; } if (context->decoder) { - if (context->desc.base.entry_point != PIPE_VIDEO_ENTRYPOINT_ENCODE) { + if (context->desc.base.entry_point == PIPE_VIDEO_ENTRYPOINT_ENCODE) { + if (context->desc.h264enc.frame_idx) + util_hash_table_destroy (context->desc.h264enc.frame_idx); + } else { if (u_reduce_video_profile(context->decoder->profile) == PIPE_VIDEO_FORMAT_MPEG4_AVC) { FREE(context->desc.h264.pps->sps); @@ -322,7 +333,7 @@ vlVaDestroyContext(VADriverContextP ctx, VAContextID context_id) } FREE(context); handle_table_remove(drv->htab, context_id); - pipe_mutex_unlock(drv->mutex); + mtx_unlock(&drv->mutex); return VA_STATUS_SUCCESS; } @@ -341,7 +352,7 @@ vlVaTerminate(VADriverContextP ctx) drv->pipe->destroy(drv->pipe); drv->vscreen->destroy(drv->vscreen); handle_table_destroy(drv->htab); - pipe_mutex_destroy(drv->mutex); + mtx_destroy(&drv->mutex); FREE(drv); return VA_STATUS_SUCCESS;