picture: Harmonize coding style
Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
This commit is contained in:
+81
-98
@@ -46,30 +46,27 @@ VAStatus SunxiCedrusBeginPicture(VADriverContextP context,
|
|||||||
{
|
{
|
||||||
struct sunxi_cedrus_driver_data *driver_data =
|
struct sunxi_cedrus_driver_data *driver_data =
|
||||||
(struct sunxi_cedrus_driver_data *) context->pDriverData;
|
(struct sunxi_cedrus_driver_data *) context->pDriverData;
|
||||||
VAStatus vaStatus = VA_STATUS_SUCCESS;
|
struct object_context *context_object;
|
||||||
struct object_context *obj_context;
|
struct object_surface *surface_object;
|
||||||
struct object_surface *obj_surface;
|
VAStatus status;
|
||||||
|
|
||||||
obj_context = CONTEXT(context_id);
|
context_object = CONTEXT(context_id);
|
||||||
assert(obj_context);
|
if (context_object == NULL)
|
||||||
|
return VA_STATUS_ERROR_INVALID_CONTEXT;
|
||||||
|
|
||||||
obj_surface = SURFACE(surface_id);
|
surface_object = SURFACE(surface_id);
|
||||||
assert(obj_surface);
|
if (surface_object == NULL)
|
||||||
|
return VA_STATUS_ERROR_INVALID_SURFACE;
|
||||||
|
|
||||||
if (obj_surface->status == VASurfaceRendering) {
|
if (surface_object->status == VASurfaceRendering)
|
||||||
vaStatus = SunxiCedrusSyncSurface(context, surface_id);
|
SunxiCedrusSyncSurface(context, surface_id);
|
||||||
if (vaStatus != VA_STATUS_SUCCESS)
|
|
||||||
return vaStatus;
|
|
||||||
}
|
|
||||||
|
|
||||||
obj_surface->status = VASurfaceRendering;
|
surface_object->status = VASurfaceRendering;
|
||||||
obj_surface->request = (obj_context->num_rendered_surfaces)%INPUT_BUFFERS_NB+1;
|
surface_object->input_buf_index = context_object->num_rendered_surfaces % INPUT_BUFFERS_NB;
|
||||||
obj_surface->input_buf_index = obj_context->num_rendered_surfaces%INPUT_BUFFERS_NB;
|
context_object->render_surface_id = surface_id;
|
||||||
obj_context->num_rendered_surfaces ++;
|
context_object->num_rendered_surfaces++;
|
||||||
|
|
||||||
obj_context->render_surface_id = obj_surface->base.id;
|
return VA_STATUS_SUCCESS;
|
||||||
|
|
||||||
return vaStatus;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VAStatus SunxiCedrusRenderPicture(VADriverContextP context,
|
VAStatus SunxiCedrusRenderPicture(VADriverContextP context,
|
||||||
@@ -77,50 +74,53 @@ VAStatus SunxiCedrusRenderPicture(VADriverContextP context,
|
|||||||
{
|
{
|
||||||
struct sunxi_cedrus_driver_data *driver_data =
|
struct sunxi_cedrus_driver_data *driver_data =
|
||||||
(struct sunxi_cedrus_driver_data *) context->pDriverData;
|
(struct sunxi_cedrus_driver_data *) context->pDriverData;
|
||||||
VAStatus vaStatus = VA_STATUS_SUCCESS;
|
struct object_context *context_object;
|
||||||
struct object_context *obj_context;
|
struct object_config *config_object;
|
||||||
struct object_surface *obj_surface;
|
struct object_surface *surface_object;
|
||||||
struct object_config *obj_config;
|
VAStatus status;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
obj_context = CONTEXT(context_id);
|
context_object = CONTEXT(context_id);
|
||||||
assert(obj_context);
|
if (context_object == NULL)
|
||||||
|
return VA_STATUS_ERROR_INVALID_CONTEXT;
|
||||||
|
|
||||||
obj_config = CONFIG(obj_context->config_id);
|
config_object = CONFIG(context_object->config_id);
|
||||||
if (NULL == obj_config)
|
if (config_object == NULL)
|
||||||
{
|
return VA_STATUS_ERROR_INVALID_CONFIG;
|
||||||
vaStatus = VA_STATUS_ERROR_INVALID_CONFIG;
|
|
||||||
return vaStatus;
|
|
||||||
}
|
|
||||||
|
|
||||||
obj_surface = SURFACE(obj_context->render_surface_id);
|
surface_object = SURFACE(context_object->render_surface_id);
|
||||||
assert(obj_surface);
|
if (surface_object == NULL)
|
||||||
|
return VA_STATUS_ERROR_INVALID_SURFACE;
|
||||||
|
|
||||||
/* verify that we got valid buffer references */
|
for (i = 0; i < buffers_count; i++) {
|
||||||
for(i = 0; i < buffers_count; i++)
|
buffer_object = BUFFER(buffers[i]);
|
||||||
{
|
if (buffer_object == NULL)
|
||||||
struct object_buffer *obj_buffer = BUFFER(buffers[i]);
|
return VA_STATUS_ERROR_INVALID_BUFFER;
|
||||||
assert(obj_buffer);
|
|
||||||
if (NULL == obj_buffer)
|
|
||||||
{
|
|
||||||
vaStatus = VA_STATUS_ERROR_INVALID_BUFFER;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch(obj_config->profile) {
|
switch (config_object->profile) {
|
||||||
case VAProfileMPEG2Simple:
|
case VAProfileMPEG2Simple:
|
||||||
case VAProfileMPEG2Main:
|
case VAProfileMPEG2Main:
|
||||||
if(obj_buffer->type == VASliceDataBufferType)
|
if (buffer_object->type == VASliceDataBufferType) {
|
||||||
vaStatus = sunxi_cedrus_render_mpeg2_slice_data(ctx, obj_context, obj_surface, obj_buffer);
|
status = sunxi_cedrus_render_mpeg2_slice_data(context, context_object, surface_object, buffer_object);
|
||||||
else if(obj_buffer->type == VAPictureParameterBufferType)
|
if (status != VA_STATUS_SUCCESS)
|
||||||
vaStatus = sunxi_cedrus_render_mpeg2_picture_parameter(ctx, obj_context, obj_surface, obj_buffer);
|
return status;
|
||||||
|
} else if (buffer_object->type == VAPictureParameterBufferType) {
|
||||||
|
status = sunxi_cedrus_render_mpeg2_picture_parameter(context, context_object, surface_object, buffer_object);
|
||||||
|
if (status != VA_STATUS_SUCCESS)
|
||||||
|
return status;
|
||||||
|
} else {
|
||||||
|
sunxi_cedrus_msg("Unsupported buffer type: %d\n", buffer_object->type);
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return vaStatus;
|
return VA_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
VAStatus SunxiCedrusEndPicture(VADriverContextP context,
|
VAStatus SunxiCedrusEndPicture(VADriverContextP context,
|
||||||
@@ -128,36 +128,29 @@ VAStatus SunxiCedrusEndPicture(VADriverContextP context,
|
|||||||
{
|
{
|
||||||
struct sunxi_cedrus_driver_data *driver_data =
|
struct sunxi_cedrus_driver_data *driver_data =
|
||||||
(struct sunxi_cedrus_driver_data *) context->pDriverData;
|
(struct sunxi_cedrus_driver_data *) context->pDriverData;
|
||||||
VAStatus vaStatus = VA_STATUS_SUCCESS;
|
struct object_context *context_object;
|
||||||
struct object_context *obj_context;
|
struct object_surface *surface_object;
|
||||||
struct object_surface *obj_surface;
|
|
||||||
struct v4l2_buffer out_buf, cap_buf;
|
struct v4l2_buffer out_buf, cap_buf;
|
||||||
struct v4l2_plane plane[1];
|
struct v4l2_plane plane[1];
|
||||||
struct v4l2_plane planes[2];
|
struct v4l2_plane planes[2];
|
||||||
struct v4l2_ext_control ctrl;
|
struct v4l2_ext_control ctrl;
|
||||||
struct v4l2_ext_controls ctrls;
|
struct v4l2_ext_controls ctrls;
|
||||||
struct media_request_new media_request;
|
struct media_request_new media_request;
|
||||||
struct object_config *obj_config;
|
|
||||||
int request_fd;
|
int request_fd;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
obj_context = CONTEXT(context_id);
|
context_object = CONTEXT(context_id);
|
||||||
assert(obj_context);
|
if (context_object == NULL)
|
||||||
|
return VA_STATUS_ERROR_INVALID_CONTEXT;
|
||||||
|
|
||||||
obj_surface = SURFACE(obj_context->render_surface_id);
|
surface_object = SURFACE(context_object->render_surface_id);
|
||||||
assert(obj_surface);
|
if (surface_object == NULL)
|
||||||
|
return VA_STATUS_ERROR_INVALID_SURFACE;
|
||||||
|
|
||||||
obj_config = CONFIG(obj_context->config_id);
|
request_fd = driver_data->request_fds[surface_object->input_buf_index];
|
||||||
if (NULL == obj_config)
|
|
||||||
{
|
|
||||||
vaStatus = VA_STATUS_ERROR_INVALID_CONFIG;
|
|
||||||
return vaStatus;
|
|
||||||
}
|
|
||||||
|
|
||||||
request_fd = driver_data->request_fds[obj_surface->input_buf_index];
|
|
||||||
if(request_fd < 0) {
|
if(request_fd < 0) {
|
||||||
assert(ioctl(driver_data->mem2mem_fd, VIDIOC_NEW_REQUEST, &media_request)==0);
|
assert(ioctl(driver_data->mem2mem_fd, VIDIOC_NEW_REQUEST, &media_request)==0);
|
||||||
driver_data->request_fds[obj_surface->input_buf_index] = media_request.fd;
|
driver_data->request_fds[surface_object->input_buf_index] = media_request.fd;
|
||||||
request_fd = media_request.fd;
|
request_fd = media_request.fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -169,21 +162,23 @@ VAStatus SunxiCedrusEndPicture(VADriverContextP context,
|
|||||||
memset(&(out_buf), 0, sizeof(out_buf));
|
memset(&(out_buf), 0, sizeof(out_buf));
|
||||||
out_buf.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
|
out_buf.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
|
||||||
out_buf.memory = V4L2_MEMORY_MMAP;
|
out_buf.memory = V4L2_MEMORY_MMAP;
|
||||||
out_buf.index = obj_surface->input_buf_index;
|
out_buf.index = surface_object->input_buf_index;
|
||||||
out_buf.length = 1;
|
out_buf.length = 1;
|
||||||
out_buf.m.planes = plane;
|
out_buf.m.planes = plane;
|
||||||
|
out_buf.request_fd = request_fd;
|
||||||
|
|
||||||
switch(obj_config->profile) {
|
switch (config_object->profile) {
|
||||||
case VAProfileMPEG2Simple:
|
case VAProfileMPEG2Simple:
|
||||||
case VAProfileMPEG2Main:
|
case VAProfileMPEG2Main:
|
||||||
obj_context->mpeg2_frame_hdr.slice_pos = 0;
|
context_object->mpeg2_frame_hdr.slice_pos = 0;
|
||||||
obj_context->mpeg2_frame_hdr.slice_len = driver_data->slice_offset[obj_surface->input_buf_index] * 8;
|
context_object->mpeg2_frame_hdr.slice_len = driver_data->slice_offset[surface_object->input_buf_index] * 8;
|
||||||
|
|
||||||
out_buf.m.planes[0].bytesused = driver_data->slice_offset[obj_surface->input_buf_index];
|
out_buf.m.planes[0].bytesused = driver_data->slice_offset[surface_object->input_buf_index];
|
||||||
ctrl.id = V4L2_CID_MPEG_VIDEO_MPEG2_FRAME_HDR;
|
ctrl.id = V4L2_CID_MPEG_VIDEO_MPEG2_FRAME_HDR;
|
||||||
ctrl.ptr = &obj_context->mpeg2_frame_hdr;
|
ctrl.ptr = &context_object->mpeg2_frame_hdr;
|
||||||
ctrl.size = sizeof(obj_context->mpeg2_frame_hdr);
|
ctrl.size = sizeof(context_object->mpeg2_frame_hdr);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
out_buf.m.planes[0].bytesused = 0;
|
out_buf.m.planes[0].bytesused = 0;
|
||||||
ctrl.id = V4L2_CID_MPEG_VIDEO_MPEG2_FRAME_HDR;
|
ctrl.id = V4L2_CID_MPEG_VIDEO_MPEG2_FRAME_HDR;
|
||||||
@@ -192,12 +187,12 @@ VAStatus SunxiCedrusEndPicture(VADriverContextP context,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
driver_data->slice_offset[obj_surface->input_buf_index] = 0;
|
driver_data->slice_offset[surface_object->input_buf_index] = 0;
|
||||||
|
|
||||||
memset(&(cap_buf), 0, sizeof(cap_buf));
|
memset(&cap_buf, 0, sizeof(cap_buf));
|
||||||
cap_buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
|
cap_buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
|
||||||
cap_buf.memory = V4L2_MEMORY_MMAP;
|
cap_buf.memory = V4L2_MEMORY_MMAP;
|
||||||
cap_buf.index = obj_surface->output_buf_index;
|
cap_buf.index = surface_object->output_buf_index;
|
||||||
cap_buf.length = 2;
|
cap_buf.length = 2;
|
||||||
cap_buf.m.planes = planes;
|
cap_buf.m.planes = planes;
|
||||||
|
|
||||||
@@ -206,30 +201,18 @@ VAStatus SunxiCedrusEndPicture(VADriverContextP context,
|
|||||||
ctrls.request_fd = request_fd;
|
ctrls.request_fd = request_fd;
|
||||||
|
|
||||||
rc = ioctl(driver_data->mem2mem_fd, VIDIOC_S_EXT_CTRLS, &ctrls);
|
rc = ioctl(driver_data->mem2mem_fd, VIDIOC_S_EXT_CTRLS, &ctrls);
|
||||||
if (rc) {
|
if (rc < 0)
|
||||||
printf("ioctl VIDIOC_S_EXT_CTRLS failed with %d/%d/%s\n", rc, errno, strerror(errno));
|
return VA_STATUS_ERROR_OPERATION_FAILED;
|
||||||
assert(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
out_buf.request_fd = request_fd;
|
rc = ioctl(driver_data->mem2mem_fd, VIDIOC_QBUF, &cap_buf);
|
||||||
|
if (rc < 0)
|
||||||
|
return VA_STATUS_ERROR_OPERATION_FAILED;
|
||||||
|
|
||||||
if(ioctl(driver_data->mem2mem_fd, VIDIOC_QBUF, &cap_buf)) {
|
rc = ioctl(driver_data->mem2mem_fd, VIDIOC_QBUF, &out_buf);
|
||||||
obj_surface->status = VASurfaceSkipped;
|
if (rc < 0)
|
||||||
sunxi_cedrus_msg("Error when queuing output: %s\n", strerror(errno));
|
return VA_STATUS_ERROR_OPERATION_FAILED;
|
||||||
return VA_STATUS_ERROR_UNKNOWN;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(ioctl(driver_data->mem2mem_fd, VIDIOC_QBUF, &out_buf)) {
|
context_object->render_surface_id = VA_INVALID_ID;
|
||||||
obj_surface->status = VASurfaceSkipped;
|
|
||||||
sunxi_cedrus_msg("Error when queuing input: %s\n", strerror(errno));
|
|
||||||
|
|
||||||
ioctl(driver_data->mem2mem_fd, VIDIOC_DQBUF, &cap_buf);
|
return VA_STATUS_SUCCESS;
|
||||||
return VA_STATUS_ERROR_UNKNOWN;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* For now, assume that we are done with rendering right away */
|
|
||||||
obj_context->render_surface_id = -1;
|
|
||||||
|
|
||||||
return vaStatus;
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user