forked from marfrit/libva-v4l2-request-fourier
Add support for the single-planar V4L2 API
Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
This commit is contained in:
+28
-19
@@ -50,18 +50,27 @@ VAStatus RequestCreateContext(VADriverContextP context, VAConfigID config_id,
|
||||
struct object_config *config_object;
|
||||
struct object_surface *surface_object;
|
||||
struct object_context *context_object = NULL;
|
||||
struct video_format *video_format;
|
||||
unsigned int length;
|
||||
unsigned int offset;
|
||||
void *source_data = MAP_FAILED;
|
||||
VASurfaceID *ids = NULL;
|
||||
VAContextID id;
|
||||
VAStatus status;
|
||||
unsigned int output_type, capture_type;
|
||||
unsigned int pixelformat;
|
||||
unsigned int index_base;
|
||||
unsigned int index;
|
||||
unsigned int i;
|
||||
int rc;
|
||||
|
||||
video_format = driver_data->video_format;
|
||||
if (video_format == NULL)
|
||||
return VA_STATUS_ERROR_OPERATION_FAILED;
|
||||
|
||||
output_type = v4l2_type_video_output(video_format->v4l2_mplane);
|
||||
capture_type = v4l2_type_video_capture(video_format->v4l2_mplane);
|
||||
|
||||
config_object = CONFIG(driver_data, config_id);
|
||||
if (config_object == NULL) {
|
||||
status = VA_STATUS_ERROR_INVALID_CONFIG;
|
||||
@@ -99,16 +108,14 @@ VAStatus RequestCreateContext(VADriverContextP context, VAConfigID config_id,
|
||||
goto error;
|
||||
}
|
||||
|
||||
rc = v4l2_set_format(driver_data->video_fd,
|
||||
V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, pixelformat,
|
||||
rc = v4l2_set_format(driver_data->video_fd, output_type, pixelformat,
|
||||
picture_width, picture_height);
|
||||
if (rc < 0) {
|
||||
status = VA_STATUS_ERROR_OPERATION_FAILED;
|
||||
goto error;
|
||||
}
|
||||
|
||||
rc = v4l2_create_buffers(driver_data->video_fd,
|
||||
V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE,
|
||||
rc = v4l2_create_buffers(driver_data->video_fd, output_type,
|
||||
surfaces_count, &index_base);
|
||||
if (rc < 0) {
|
||||
status = VA_STATUS_ERROR_ALLOCATION_FAILED;
|
||||
@@ -137,9 +144,8 @@ VAStatus RequestCreateContext(VADriverContextP context, VAConfigID config_id,
|
||||
goto error;
|
||||
}
|
||||
|
||||
rc = v4l2_query_buffer(driver_data->video_fd,
|
||||
V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, index,
|
||||
&length, &offset, 1);
|
||||
rc = v4l2_query_buffer(driver_data->video_fd, output_type,
|
||||
index, &length, &offset, 1);
|
||||
if (rc < 0) {
|
||||
status = VA_STATUS_ERROR_ALLOCATION_FAILED;
|
||||
goto error;
|
||||
@@ -157,15 +163,13 @@ VAStatus RequestCreateContext(VADriverContextP context, VAConfigID config_id,
|
||||
surface_object->source_size = length;
|
||||
}
|
||||
|
||||
rc = v4l2_set_stream(driver_data->video_fd,
|
||||
V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, true);
|
||||
rc = v4l2_set_stream(driver_data->video_fd, output_type, true);
|
||||
if (rc < 0) {
|
||||
status = VA_STATUS_ERROR_OPERATION_FAILED;
|
||||
goto error;
|
||||
}
|
||||
|
||||
rc = v4l2_set_stream(driver_data->video_fd,
|
||||
V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, true);
|
||||
rc = v4l2_set_stream(driver_data->video_fd, capture_type, true);
|
||||
if (rc < 0) {
|
||||
status = VA_STATUS_ERROR_OPERATION_FAILED;
|
||||
goto error;
|
||||
@@ -203,20 +207,27 @@ VAStatus RequestDestroyContext(VADriverContextP context, VAContextID context_id)
|
||||
{
|
||||
struct request_data *driver_data = context->pDriverData;
|
||||
struct object_context *context_object;
|
||||
struct video_format *video_format;
|
||||
unsigned int output_type, capture_type;
|
||||
VAStatus status;
|
||||
int rc;
|
||||
|
||||
video_format = driver_data->video_format;
|
||||
if (video_format == NULL)
|
||||
return VA_STATUS_ERROR_OPERATION_FAILED;
|
||||
|
||||
output_type = v4l2_type_video_output(video_format->v4l2_mplane);
|
||||
capture_type = v4l2_type_video_capture(video_format->v4l2_mplane);
|
||||
|
||||
context_object = CONTEXT(driver_data, context_id);
|
||||
if (context_object == NULL)
|
||||
return VA_STATUS_ERROR_INVALID_CONTEXT;
|
||||
|
||||
rc = v4l2_set_stream(driver_data->video_fd,
|
||||
V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, false);
|
||||
rc = v4l2_set_stream(driver_data->video_fd, output_type, false);
|
||||
if (rc < 0)
|
||||
return VA_STATUS_ERROR_OPERATION_FAILED;
|
||||
|
||||
rc = v4l2_set_stream(driver_data->video_fd,
|
||||
V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, false);
|
||||
rc = v4l2_set_stream(driver_data->video_fd, capture_type, false);
|
||||
if (rc < 0)
|
||||
return VA_STATUS_ERROR_OPERATION_FAILED;
|
||||
|
||||
@@ -232,13 +243,11 @@ VAStatus RequestDestroyContext(VADriverContextP context, VAContextID context_id)
|
||||
object_heap_free(&driver_data->context_heap,
|
||||
(struct object_base *)context_object);
|
||||
|
||||
rc = v4l2_request_buffers(driver_data->video_fd,
|
||||
V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, 0);
|
||||
rc = v4l2_request_buffers(driver_data->video_fd, output_type, 0);
|
||||
if (rc < 0)
|
||||
return VA_STATUS_ERROR_OPERATION_FAILED;
|
||||
|
||||
rc = v4l2_request_buffers(driver_data->video_fd,
|
||||
V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, 0);
|
||||
rc = v4l2_request_buffers(driver_data->video_fd, capture_type, 0);
|
||||
if (rc < 0)
|
||||
return VA_STATUS_ERROR_OPERATION_FAILED;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user