This is an automatic generated email to let you know that the following patch were queued at the http://git.linuxtv.org/cgit.cgi/v4l-utils.git tree:
Subject: v4l-utils: clean up printf formatting for top, left, width and height Author: Hans Verkuil <hverk...@xs4all.nl> Date: Tue Mar 4 12:39:48 2025 +0100 Typically the top/left fields are signed, while width and height are unsigned. This was used inconsistently in the code, fix this. Also report rectangles using the standard format "(t,l)/wxh". Signed-off-by: Hans Verkuil <hverk...@xs4all.nl> contrib/test/sdlcam.c | 2 +- lib/libv4lconvert/libv4lconvert.c | 12 ++++++------ utils/libv4l2util/v4l2_driver.c | 6 +++--- utils/media-ctl/libv4l2subdev.c | 4 ++-- utils/media-ctl/media-ctl.c | 8 ++++---- utils/qv4l2/general-tab.cpp | 4 ++-- utils/v4l2-compliance/v4l2-test-buffers.cpp | 14 +++++++------- utils/v4l2-compliance/v4l2-test-formats.cpp | 26 +++++++++++++------------- utils/v4l2-ctl/v4l2-ctl-common.cpp | 2 +- utils/v4l2-ctl/v4l2-ctl-stds.cpp | 2 +- utils/v4l2-ctl/v4l2-ctl-subdev.cpp | 2 +- utils/v4l2-ctl/v4l2-ctl.cpp | 10 +++++----- 12 files changed, 46 insertions(+), 46 deletions(-) --- http://git.linuxtv.org/cgit.cgi/v4l-utils.git/commit/?id=0b852765266e5160596e7da2d947d33906e09ffe diff --git a/contrib/test/sdlcam.c b/contrib/test/sdlcam.c index cc43a10ccd89..9ff0c65bae5b 100644 --- a/contrib/test/sdlcam.c +++ b/contrib/test/sdlcam.c @@ -44,7 +44,7 @@ static void fmt_print(struct v4l2_format *fmt) { int f; - printf("Format: %dx%d. ", fmt->fmt.pix.width, fmt->fmt.pix.height); + printf("Format: %ux%u. ", fmt->fmt.pix.width, fmt->fmt.pix.height); printf("%x ", fmt->fmt.pix.pixelformat); f = fmt->fmt.pix.pixelformat; for (int i=0; i<4; i++) { diff --git a/lib/libv4lconvert/libv4lconvert.c b/lib/libv4lconvert/libv4lconvert.c index 80f39dc4541e..2160384ddda1 100644 --- a/lib/libv4lconvert/libv4lconvert.c +++ b/lib/libv4lconvert/libv4lconvert.c @@ -1901,8 +1901,8 @@ int v4lconvert_enum_frameintervals(struct v4lconvert_data *data, int frmival_pixformat = frmival->pixel_format; int dest_pixformat = dest_fmt.fmt.pix.pixelformat; - V4LCONVERT_ERR("Could not find matching framesize for: %c%c%c%c %dx%d " - "closest match: %c%c%c%c %dx%d\n", + V4LCONVERT_ERR("Could not find matching framesize for: %c%c%c%c %ux%u " + "closest match: %c%c%c%c %ux%u\n", frmival_pixformat & 0xff, (frmival_pixformat >> 8) & 0xff, (frmival_pixformat >> 16) & 0xff, @@ -1912,7 +1912,7 @@ int v4lconvert_enum_frameintervals(struct v4lconvert_data *data, (dest_pixformat >> 8) & 0xff, (dest_pixformat >> 16) & 0xff, dest_pixformat >> 24, - dest_fmt.fmt.pix.width , dest_fmt.fmt.pix.height); + dest_fmt.fmt.pix.width, dest_fmt.fmt.pix.height); errno = EINVAL; return -1; } @@ -1927,14 +1927,14 @@ int v4lconvert_enum_frameintervals(struct v4lconvert_data *data, int dest_pixfmt = dest_fmt.fmt.pix.pixelformat; int src_pixfmt = src_fmt.fmt.pix.pixelformat; - V4LCONVERT_ERR("Could not enum frameival index: %d for: %c%c%c%c %dx%d " - "using src: %c%c%c%c %dx%d, error: %s\n", + V4LCONVERT_ERR("Could not enum frameival index: %d for: %c%c%c%c %ux%u " + "using src: %c%c%c%c %ux%u, error: %s\n", frmival->index, dest_pixfmt & 0xff, (dest_pixfmt >> 8) & 0xff, (dest_pixfmt >> 16) & 0xff, dest_pixfmt >> 24, - dest_fmt.fmt.pix.width , dest_fmt.fmt.pix.height, + dest_fmt.fmt.pix.width, dest_fmt.fmt.pix.height, src_pixfmt & 0xff, (src_pixfmt >> 8) & 0xff, (src_pixfmt >> 16) & 0xff, diff --git a/utils/libv4l2util/v4l2_driver.c b/utils/libv4l2util/v4l2_driver.c index 51e97b61e327..c956032696ad 100644 --- a/utils/libv4l2util/v4l2_driver.c +++ b/utils/libv4l2util/v4l2_driver.c @@ -509,9 +509,9 @@ int v4l2_gettryset_fmt_cap (struct v4l2_driver *drv, enum v4l2_direction dir, } if (drv->debug) - printf( "FMT SET: %dx%d, fourcc=%c%c%c%c, %d bytes/line," - " %d bytes/frame, colorspace=0x%08x\n", - pix->width,pix->height, + printf( "FMT SET: %ux%u, fourcc=%c%c%c%c, %u bytes/line," + " %u bytes/frame, colorspace=0x%08x\n", + pix->width, pix->height, pix->pixelformat & 0xff, (pix->pixelformat >> 8) & 0xff, (pix->pixelformat >> 16) & 0xff, diff --git a/utils/media-ctl/libv4l2subdev.c b/utils/media-ctl/libv4l2subdev.c index 629c4059ac55..2f6b1c948a07 100644 --- a/utils/media-ctl/libv4l2subdev.c +++ b/utils/media-ctl/libv4l2subdev.c @@ -1011,7 +1011,7 @@ static int set_selection(struct media_pad *pad, unsigned int stream, return 0; media_dbg(pad->entity->media, - "Setting up selection target %u rectangle (%u,%u)/%ux%u on pad %s/%u/%u\n", + "Setting up selection target %u rectangle (%d,%d)/%ux%u on pad %s/%u/%u\n", target, rect->left, rect->top, rect->width, rect->height, pad->entity->info.name, pad->index, stream); @@ -1025,7 +1025,7 @@ static int set_selection(struct media_pad *pad, unsigned int stream, } media_dbg(pad->entity->media, - "Selection rectangle set: (%u,%u)/%ux%u\n", + "Selection rectangle set: (%d,%d)/%ux%u\n", rect->left, rect->top, rect->width, rect->height); return 0; diff --git a/utils/media-ctl/media-ctl.c b/utils/media-ctl/media-ctl.c index 33df0880fd9b..37fe9c0dc3a1 100644 --- a/utils/media-ctl/media-ctl.c +++ b/utils/media-ctl/media-ctl.c @@ -144,28 +144,28 @@ static void v4l2_subdev_print_format(struct media_entity *entity, V4L2_SEL_TGT_CROP_BOUNDS, which); if (ret == 0) - printf("\n\t\t crop.bounds:(%u,%u)/%ux%u", rect.left, rect.top, + printf("\n\t\t crop.bounds:(%d,%d)/%ux%u", rect.left, rect.top, rect.width, rect.height); ret = v4l2_subdev_get_selection(entity, &rect, pad, stream, V4L2_SEL_TGT_CROP, which); if (ret == 0) - printf("\n\t\t crop:(%u,%u)/%ux%u", rect.left, rect.top, + printf("\n\t\t crop:(%d,%d)/%ux%u", rect.left, rect.top, rect.width, rect.height); ret = v4l2_subdev_get_selection(entity, &rect, pad, stream, V4L2_SEL_TGT_COMPOSE_BOUNDS, which); if (ret == 0) - printf("\n\t\t compose.bounds:(%u,%u)/%ux%u", + printf("\n\t\t compose.bounds:(%d,%d)/%ux%u", rect.left, rect.top, rect.width, rect.height); ret = v4l2_subdev_get_selection(entity, &rect, pad, stream, V4L2_SEL_TGT_COMPOSE, which); if (ret == 0) - printf("\n\t\t compose:(%u,%u)/%ux%u", + printf("\n\t\t compose:(%d,%d)/%ux%u", rect.left, rect.top, rect.width, rect.height); printf("]\n"); diff --git a/utils/qv4l2/general-tab.cpp b/utils/qv4l2/general-tab.cpp index 2fb165770150..b07fc1baf17e 100644 --- a/utils/qv4l2/general-tab.cpp +++ b/utils/qv4l2/general-tab.cpp @@ -1859,10 +1859,10 @@ void GeneralTab::refreshTimings() char buf[100]; if (bt.interlaced) - sprintf(buf, "%dx%di%.2f", bt.width, bt.height, + sprintf(buf, "%ux%ui%.2f", bt.width, bt.height, (double)bt.pixelclock / (tot_width * (tot_height / 2))); else - sprintf(buf, "%dx%dp%.2f", bt.width, bt.height, + sprintf(buf, "%ux%up%.2f", bt.width, bt.height, (double)bt.pixelclock / (tot_width * tot_height)); m_videoTimings->addItem(buf); } while (!enum_dv_timings(timings)); diff --git a/utils/v4l2-compliance/v4l2-test-buffers.cpp b/utils/v4l2-compliance/v4l2-test-buffers.cpp index 71390ba6f208..572973b2b755 100644 --- a/utils/v4l2-compliance/v4l2-test-buffers.cpp +++ b/utils/v4l2-compliance/v4l2-test-buffers.cpp @@ -3376,15 +3376,15 @@ static void streamFmtRun(struct node *node, cv4l_fmt &fmt, unsigned frame_count, if (has_crop) { node->g_frame_selection(crop, fmt.g_field()); - sprintf(s_crop, "Crop %ux%u@%ux%u, ", - crop.r.width, crop.r.height, - crop.r.left, crop.r.top); + sprintf(s_crop, "Crop (%d,%d)/%ux%u, ", + crop.r.left, crop.r.top, + crop.r.width, crop.r.height); } if (has_compose) { node->g_frame_selection(compose, fmt.g_field()); - sprintf(s_compose, "Compose %ux%u@%ux%u, ", - compose.r.width, compose.r.height, - compose.r.left, compose.r.top); + sprintf(s_compose, "Compose (%d,%d)/%ux%u, ", + compose.r.left, compose.r.top, + compose.r.width, compose.r.height); } printf("\r\t\t%s%sStride %u, Field %s%s: %s \n", s_crop, s_compose, @@ -3729,7 +3729,7 @@ static void streamM2MRun(struct node *node, unsigned frame_count) node->g_fmt(out_fmt, out_type); if (!no_progress) printf("\r"); - printf("\t%s (%s) %dx%d -> %s (%s) %dx%d: %s\n", + printf("\t%s (%s) %ux%u -> %s (%s) %ux%u: %s\n", fcc2s(out_fmt.g_pixelformat()).c_str(), pixfmt2s(out_fmt.g_pixelformat()).c_str(), out_fmt.g_width(), out_fmt.g_height(), diff --git a/utils/v4l2-compliance/v4l2-test-formats.cpp b/utils/v4l2-compliance/v4l2-test-formats.cpp index bac28cbae2bf..e206a9c695be 100644 --- a/utils/v4l2-compliance/v4l2-test-formats.cpp +++ b/utils/v4l2-compliance/v4l2-test-formats.cpp @@ -68,7 +68,7 @@ static int testEnumFrameIntervals(struct node *node, __u32 pixfmt, fail_on_test(node->is_m2m && !(node->codec_mask & STATEFUL_ENCODER)); if (f == 0 && ret == EINVAL) { if (type == V4L2_FRMSIZE_TYPE_DISCRETE) - warn("found framesize %dx%d, but no frame intervals\n", w, h); + warn("found framesize %ux%u, but no frame intervals\n", w, h); return ENOTTY; } if (ret == EINVAL) @@ -120,8 +120,8 @@ static int testEnumFrameIntervals(struct node *node, __u32 pixfmt, node->has_frmintervals = true; } if (type == 0) - return fail("found frame intervals for invalid size %dx%d\n", w, h); - info("found %d frameintervals for pixel format %08x (%s) and size %dx%d\n", + return fail("found frame intervals for invalid size %ux%u\n", w, h); + info("found %d frameintervals for pixel format %08x (%s) and size %ux%u\n", f, pixfmt, fcc2s(pixfmt).c_str(), w, h); return 0; } @@ -722,10 +722,10 @@ static bool matchFormats(const struct v4l2_format &f1, const struct v4l2_format case V4L2_BUF_TYPE_VIDEO_OUTPUT: if (!memcmp(&f1.fmt.pix, &f2.fmt.pix, sizeof(f1.fmt.pix))) return true; - printf("\t\tG_FMT: %dx%d, %s, %d, %d, %d, %d, %d, %d, %x\n", + printf("\t\tG_FMT: %ux%u, %s, %u, %u, %u, %u, %u, %u, %x\n", pix1.width, pix1.height, fcc2s(pix1.pixelformat).c_str(), pix1.field, pix1.bytesperline, pix1.sizeimage, pix1.colorspace, pix1.ycbcr_enc, pix1.quantization, pix1.priv); - printf("\t\tTRY/S_FMT: %dx%d, %s, %d, %d, %d, %d, %d, %d, %x\n", + printf("\t\tTRY/S_FMT: %ux%u, %s, %u, %u, %u, %u, %u, %u, %x\n", pix2.width, pix2.height, fcc2s(pix2.pixelformat).c_str(), pix2.field, pix2.bytesperline, pix2.sizeimage, pix2.colorspace, pix2.ycbcr_enc, pix2.quantization, pix2.priv); return false; @@ -733,11 +733,11 @@ static bool matchFormats(const struct v4l2_format &f1, const struct v4l2_format case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY: if (!memcmp(&f1.fmt.win, &f2.fmt.win, sizeof(f1.fmt.win))) return true; - printf("\t\tG_FMT: %dx%d@%dx%d, %d, %x, %p, %d, %p, %x\n", - win1.w.width, win1.w.height, win1.w.left, win1.w.top, win1.field, + printf("\t\tG_FMT: (%d,%d)/%ux%u, %u, %x, %p, %u, %p, %x\n", + win1.w.left, win1.w.top, win1.w.width, win1.w.height, win1.field, win1.chromakey, (void *)win1.clips, win1.clipcount, win1.bitmap, win1.global_alpha); - printf("\t\tTRY/S_FMT: %dx%d@%dx%d, %d, %x, %p, %d, %p, %x\n", - win2.w.width, win2.w.height, win2.w.left, win2.w.top, win2.field, + printf("\t\tTRY/S_FMT: (%d,%d)/%ux%u, %u, %x, %p, %u, %p, %x\n", + win2.w.left, win2.w.top, win2.w.width, win2.w.height, win2.field, win2.chromakey, (void *)win2.clips, win2.clipcount, win2.bitmap, win2.global_alpha); return false; case V4L2_BUF_TYPE_VBI_CAPTURE: @@ -750,16 +750,16 @@ static bool matchFormats(const struct v4l2_format &f1, const struct v4l2_format case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE: if (!memcmp(&f1.fmt.pix_mp, &f2.fmt.pix_mp, sizeof(f1.fmt.pix_mp))) return true; - printf("\t\tG_FMT: %dx%d, %s, %d, %d, %d, %d, %d\n", + printf("\t\tG_FMT: %ux%u, %s, %u, %u, %u, %u, %u\n", pix_mp1.width, pix_mp1.height, fcc2s(pix_mp1.pixelformat).c_str(), pix_mp1.num_planes, pix_mp1.field, pix_mp1.colorspace, pix_mp1.ycbcr_enc, pix_mp1.quantization); for (unsigned p = 0; p < pix_mp1.num_planes; p++) printf("\t\t\t%d: %d, %d\n", p, pix_mp1.plane_fmt[p].sizeimage, pix_mp1.plane_fmt[p].bytesperline); - printf("\t\tTRY/S_FMT: %dx%d, %s, %d, %d, %d, %d, %d\n", + printf("\t\tTRY/S_FMT: %ux%u, %s, %u, %u, %u, %u, %u\n", pix_mp2.width, pix_mp2.height, fcc2s(pix_mp2.pixelformat).c_str(), pix_mp2.num_planes, pix_mp2.field, pix_mp2.colorspace, pix_mp2.ycbcr_enc, pix_mp2.quantization); for (unsigned p = 0; p < pix_mp2.num_planes; p++) - printf("\t\t\t%d: %d, %d\n", p, pix_mp2.plane_fmt[p].sizeimage, pix_mp2.plane_fmt[p].bytesperline); + printf("\t\t\t%u: %u, %u\n", p, pix_mp2.plane_fmt[p].sizeimage, pix_mp2.plane_fmt[p].bytesperline); return false; case V4L2_BUF_TYPE_SDR_CAPTURE: case V4L2_BUF_TYPE_SDR_OUTPUT: @@ -1158,7 +1158,7 @@ static int testGlobalFormat(struct node *node, int type) h2 = p2->height; } if (pixfmt1 != pixfmt2 || w1 != w2 || h1 != h2) - return fail("Global format mismatch: %08x(%s)/%dx%d vs %08x(%s)/%dx%d\n", + return fail("Global format mismatch: %08x(%s)/%ux%u vs %08x(%s)/%ux%u\n", pixfmt1, fcc2s(pixfmt1).c_str(), w1, h1, pixfmt2, fcc2s(pixfmt2).c_str(), w2, h2); info("Global format check succeeded for type %d\n", type); diff --git a/utils/v4l2-ctl/v4l2-ctl-common.cpp b/utils/v4l2-ctl/v4l2-ctl-common.cpp index 1859292f6f77..5b953cbdf24b 100644 --- a/utils/v4l2-ctl/v4l2-ctl-common.cpp +++ b/utils/v4l2-ctl/v4l2-ctl-common.cpp @@ -612,7 +612,7 @@ static void print_value(int fd, const v4l2_query_ext_ctrl &qc, const v4l2_ext_co printf("'%s'", safename(ctrl.string).c_str()); break; case V4L2_CTRL_TYPE_AREA: - printf("%dx%d", ctrl.p_area->width, ctrl.p_area->height); + printf("%ux%u", ctrl.p_area->width, ctrl.p_area->height); break; case V4L2_CTRL_TYPE_RECT: printf("(%d,%d)/%ux%u", diff --git a/utils/v4l2-ctl/v4l2-ctl-stds.cpp b/utils/v4l2-ctl/v4l2-ctl-stds.cpp index 6b596d00b37e..8c9abf5df687 100644 --- a/utils/v4l2-ctl/v4l2-ctl-stds.cpp +++ b/utils/v4l2-ctl/v4l2-ctl-stds.cpp @@ -363,7 +363,7 @@ static void print_dv_timings(const struct v4l2_dv_timings *t) tot_width = bt->width + bt->hfrontporch + bt->hsync + bt->hbackporch; if (options[OptConcise]) { - printf("\t%dx%d%c%.2f %s\n", bt->width, bt->height, + printf("\t%ux%u%c%.2f %s\n", bt->width, bt->height, bt->interlaced ? 'i' : 'p', static_cast<double>(bt->pixelclock) / (tot_width * (tot_height / (bt->interlaced ? 2 : 1))), diff --git a/utils/v4l2-ctl/v4l2-ctl-subdev.cpp b/utils/v4l2-ctl/v4l2-ctl-subdev.cpp index 48b79288dfc3..0d8e65c58d26 100644 --- a/utils/v4l2-ctl/v4l2-ctl-subdev.cpp +++ b/utils/v4l2-ctl/v4l2-ctl-subdev.cpp @@ -891,7 +891,7 @@ static std::string fract2fps(const struct v4l2_fract &f) static void print_frmsize(const struct v4l2_subdev_frame_size_enum &frmsize) { - printf("\tSize Range: %dx%d - %dx%d\n", + printf("\tSize Range: %ux%u - %ux%u\n", frmsize.min_width, frmsize.min_height, frmsize.max_width, frmsize.max_height); } diff --git a/utils/v4l2-ctl/v4l2-ctl.cpp b/utils/v4l2-ctl/v4l2-ctl.cpp index 86550994712c..0eb4bb5c9200 100644 --- a/utils/v4l2-ctl/v4l2-ctl.cpp +++ b/utils/v4l2-ctl/v4l2-ctl.cpp @@ -474,8 +474,8 @@ void printfmt(int fd, const struct v4l2_format &vfmt) for (unsigned i = 0; i < vfmt.fmt.win.clipcount; i++) { struct v4l2_rect &r = vfmt.fmt.win.clips[i].c; - printf("\t\tClip %2d: %ux%u@%ux%u\n", i, - r.width, r.height, r.left, r.top); + printf("\t\tClip %2d: (%d,%d)/%ux%u\n", i, + r.left, r.top, r.width, r.height); } printf("\tClip Bitmap : %s", vfmt.fmt.win.bitmap ? "Yes, " : "No\n"); if (vfmt.fmt.win.bitmap) { @@ -566,15 +566,15 @@ void print_frmsize(const struct v4l2_frmsizeenum &frmsize, const char *prefix) { printf("%s\tSize: %s ", prefix, frmtype2s(frmsize.type).c_str()); if (frmsize.type == V4L2_FRMSIZE_TYPE_DISCRETE) { - printf("%dx%d", frmsize.discrete.width, frmsize.discrete.height); + printf("%ux%u", frmsize.discrete.width, frmsize.discrete.height); } else if (frmsize.type == V4L2_FRMSIZE_TYPE_CONTINUOUS) { - printf("%dx%d - %dx%d", + printf("%ux%u - %ux%u", frmsize.stepwise.min_width, frmsize.stepwise.min_height, frmsize.stepwise.max_width, frmsize.stepwise.max_height); } else if (frmsize.type == V4L2_FRMSIZE_TYPE_STEPWISE) { - printf("%dx%d - %dx%d with step %d/%d", + printf("%ux%u - %ux%u with step %u/%u", frmsize.stepwise.min_width, frmsize.stepwise.min_height, frmsize.stepwise.max_width,