From 8fd01b54b655a859af4572104f7c6da78f7e1205 Mon Sep 17 00:00:00 2001 From: Paul Kocialkowski Date: Mon, 23 Apr 2018 11:50:27 +0200 Subject: [PATCH] context: Rename object context structure fields for more clarity Signed-off-by: Paul Kocialkowski --- src/context.c | 21 +++++++++++---------- src/context.h | 11 ++++++----- src/picture.c | 8 ++++---- 3 files changed, 21 insertions(+), 19 deletions(-) diff --git a/src/context.c b/src/context.c index be04fe9..a9b5a1a 100644 --- a/src/context.c +++ b/src/context.c @@ -73,16 +73,19 @@ VAStatus SunxiCedrusCreateContext(VADriverContextP ctx, VAConfigID config_id, return vaStatus; } - obj_context->context_id = contextID; - *context = contextID; - obj_context->current_render_target = -1; obj_context->config_id = config_id; + obj_context->render_target = VA_INVALID; + obj_context->render_targets = (VASurfaceID *) malloc(num_render_targets * sizeof(VASurfaceID)); + obj_context->render_targets_count = num_render_targets; obj_context->picture_width = picture_width; obj_context->picture_height = picture_height; - obj_context->num_render_targets = num_render_targets; - obj_context->render_targets = (VASurfaceID *) malloc(num_render_targets * sizeof(VASurfaceID)); obj_context->num_rendered_surfaces = 0; + *context = contextID; + + struct v4l2_ctrl_mpeg2_frame_hdr mpeg2_frame_hdr; + uint32_t num_rendered_surfaces; + if (obj_context->render_targets == NULL) { vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED; @@ -103,11 +106,10 @@ VAStatus SunxiCedrusCreateContext(VADriverContextP ctx, VAConfigID config_id, /* Error recovery */ if (VA_STATUS_SUCCESS != vaStatus) { - obj_context->context_id = -1; obj_context->config_id = -1; free(obj_context->render_targets); obj_context->render_targets = NULL; - obj_context->num_render_targets = 0; + obj_context->render_targets_count = 0; obj_context->flags = 0; object_heap_free(&driver_data->context_heap, (object_base_p) obj_context); } @@ -160,17 +162,16 @@ VAStatus SunxiCedrusDestroyContext(VADriverContextP ctx, VAContextID context) type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; ioctl(driver_data->mem2mem_fd, VIDIOC_STREAMOFF, &type); - obj_context->context_id = -1; obj_context->config_id = -1; obj_context->picture_width = 0; obj_context->picture_height = 0; if (obj_context->render_targets) free(obj_context->render_targets); obj_context->render_targets = NULL; - obj_context->num_render_targets = 0; + obj_context->render_targets_count = 0; obj_context->flags = 0; - obj_context->current_render_target = -1; + obj_context->render_target = -1; object_heap_free(&driver_data->context_heap, (object_base_p) obj_context); diff --git a/src/context.h b/src/context.h index c9d49ff..0ad97ca 100644 --- a/src/context.h +++ b/src/context.h @@ -41,17 +41,18 @@ struct object_context { struct object_base base; - VAContextID context_id; + VAConfigID config_id; - VASurfaceID current_render_target; + VASurfaceID render_target; + VASurfaceID *render_targets; + int render_targets_count; + int picture_width; int picture_height; - int num_render_targets; int flags; - VASurfaceID *render_targets; - uint32_t num_rendered_surfaces; struct v4l2_ctrl_mpeg2_frame_hdr mpeg2_frame_hdr; + uint32_t num_rendered_surfaces; }; VAStatus SunxiCedrusCreateContext(VADriverContextP ctx, VAConfigID config_id, diff --git a/src/picture.c b/src/picture.c index d0e2e5e..b290cd0 100644 --- a/src/picture.c +++ b/src/picture.c @@ -75,7 +75,7 @@ VAStatus SunxiCedrusBeginPicture(VADriverContextP ctx, VAContextID context, obj_surface->input_buf_index = obj_context->num_rendered_surfaces%INPUT_BUFFERS_NB; obj_context->num_rendered_surfaces ++; - obj_context->current_render_target = obj_surface->base.id; + obj_context->render_target = obj_surface->base.id; return vaStatus; } @@ -101,7 +101,7 @@ VAStatus SunxiCedrusRenderPicture(VADriverContextP ctx, VAContextID context, return vaStatus; } - obj_surface = SURFACE(obj_context->current_render_target); + obj_surface = SURFACE(obj_context->render_target); assert(obj_surface); /* verify that we got valid buffer references */ @@ -151,7 +151,7 @@ VAStatus SunxiCedrusEndPicture(VADriverContextP ctx, VAContextID context) obj_context = CONTEXT(context); assert(obj_context); - obj_surface = SURFACE(obj_context->current_render_target); + obj_surface = SURFACE(obj_context->render_target); assert(obj_surface); obj_config = CONFIG(obj_context->config_id); @@ -242,7 +242,7 @@ VAStatus SunxiCedrusEndPicture(VADriverContextP ctx, VAContextID context) /* For now, assume that we are done with rendering right away */ - obj_context->current_render_target = -1; + obj_context->render_target = -1; return vaStatus; }