Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wip] Rework backend for Linux 5.14 #38

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
h264: use v4l2_get_controls to query decode mode and start code
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
  • Loading branch information
pH5 committed Jan 23, 2020
commit c7385a6bf44d7aac5657ad8df742f090d1f5c764
2 changes: 2 additions & 0 deletions src/context.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ VAStatus RequestCreateContext(VADriverContextP context, VAConfigID config_id,
case VAProfileH264MultiviewHigh:
case VAProfileH264StereoHigh:
pixelformat = V4L2_PIX_FMT_H264_SLICE;
/* Query decode mode and start code */
h264_get_controls(driver_data, context_object);
break;

case VAProfileHEVCMain:
Expand Down
1 change: 1 addition & 0 deletions src/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ struct object_context {

/* H264 only */
struct h264_dpb dpb;
bool h264_start_code;
};

VAStatus RequestCreateContext(VADriverContextP context, VAConfigID config_id,
Expand Down
40 changes: 40 additions & 0 deletions src/h264.c
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,46 @@ static void h264_va_slice_to_v4l2(struct request_data *driver_data,
VASlice->chroma_offset_l1);
}

int h264_get_controls(struct request_data *driver_data,
struct object_context *context)
{
struct v4l2_ext_control controls[2] = {
{
.id = V4L2_CID_MPEG_VIDEO_H264_DECODE_MODE,
}, {
.id = V4L2_CID_MPEG_VIDEO_H264_START_CODE,
}
};
int rc;

rc = v4l2_get_controls(driver_data->video_fd, -1, controls, 2);
if (rc < 0)
return VA_STATUS_ERROR_OPERATION_FAILED;

switch (controls[0].value) {
case V4L2_MPEG_VIDEO_H264_DECODE_MODE_SLICE_BASED:
break;
case V4L2_MPEG_VIDEO_H264_DECODE_MODE_FRAME_BASED:
break;
default:
request_log("Unsupported decode mode\n");
return VA_STATUS_ERROR_OPERATION_FAILED;
}

switch (controls[1].value) {
case V4L2_MPEG_VIDEO_H264_START_CODE_NONE:
break;
case V4L2_MPEG_VIDEO_H264_START_CODE_ANNEX_B:
context->h264_start_code = true;
break;
default:
request_log("Unsupported start code\n");
return VA_STATUS_ERROR_OPERATION_FAILED;
}

return VA_STATUS_SUCCESS;
}

int h264_set_controls(struct request_data *driver_data,
struct object_context *context,
struct object_surface *surface)
Expand Down
2 changes: 2 additions & 0 deletions src/h264.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ struct h264_dpb {
unsigned int age;
};

int h264_get_controls(struct request_data *driver_data,
struct object_context *context);
int h264_set_controls(struct request_data *data,
struct object_context *context,
struct object_surface *surface);
Expand Down