Skip to content

Commit

Permalink
app/v4l2_to_ip: refine code (#688)
Browse files Browse the repository at this point in the history
  • Loading branch information
gongxiao-intel authored Jan 5, 2024
1 parent 8e49cf9 commit f4a85c5
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions app/v4l2_to_ip/v4l2_to_ip.c
Original file line number Diff line number Diff line change
Expand Up @@ -842,25 +842,30 @@ static int video_set_format(struct device* dev, unsigned int w, unsigned int h,

ret = ioctl(dev->fd, VIDIOC_S_FMT, &fmt);
if (ret < 0) {
printf("Unable to set format: %s (%d).\n", strerror(errno), errno);
printf("Failed to configure video format: %s (%d).\n", strerror(errno), errno);
return ret;
}

if (video_is_mplane(dev)) {
printf("Video format set: %s (%08x) %ux%u field %s, %u planes: \n",
v4l2_format_name(fmt.fmt.pix_mp.pixelformat), fmt.fmt.pix_mp.pixelformat,
fmt.fmt.pix_mp.width, fmt.fmt.pix_mp.height,
v4l2_field_name(fmt.fmt.pix_mp.field), fmt.fmt.pix_mp.num_planes);
printf(
"Video attributes, pixel format: %s (%08x), resolution: %ux%u field: %s, number "
"of planes: %u\n",
v4l2_format_name(fmt.fmt.pix_mp.pixelformat), fmt.fmt.pix_mp.pixelformat,
fmt.fmt.pix_mp.width, fmt.fmt.pix_mp.height,
v4l2_field_name(fmt.fmt.pix_mp.field), fmt.fmt.pix_mp.num_planes);

for (i = 0; i < fmt.fmt.pix_mp.num_planes; i++) {
printf(" * Stride %u, buffer size %u\n", fmt.fmt.pix_mp.plane_fmt[i].bytesperline,
printf("Plane %d attributes, stride: %u, buffer size: %u\n", i,
fmt.fmt.pix_mp.plane_fmt[i].bytesperline,
fmt.fmt.pix_mp.plane_fmt[i].sizeimage);
}
} else {
printf("Video format set: %s (%08x) %ux%u (stride %u) field %s buffer size %u\n",
v4l2_format_name(fmt.fmt.pix.pixelformat), fmt.fmt.pix.pixelformat,
fmt.fmt.pix.width, fmt.fmt.pix.height, fmt.fmt.pix.bytesperline,
v4l2_field_name(fmt.fmt.pix.field), fmt.fmt.pix.sizeimage);
printf(
"Video attributes, pixel format: %s (%08x), resolution: %ux%u, stride: %u, "
"field: %s buffer size %u\n",
v4l2_format_name(fmt.fmt.pix.pixelformat), fmt.fmt.pix.pixelformat,
fmt.fmt.pix.width, fmt.fmt.pix.height, fmt.fmt.pix.bytesperline,
v4l2_field_name(fmt.fmt.pix.field), fmt.fmt.pix.sizeimage);
}

return 0;
Expand Down

0 comments on commit f4a85c5

Please sign in to comment.