static void printfbuf(const struct v4l2_framebuffer &fb) { int is_ext = fb.capability & V4L2_FBUF_CAP_EXTERNOVERLAY; printf("Framebuffer Format:\n"); printf("\tCapability : %s", fbufcap2s(fb.capability).c_str() + 3); printf("\tFlags : %s", fbufflags2s(fb.flags).c_str() + 3); if (fb.base) printf("\tBase : 0x%p\n", fb.base); printf("\tWidth : %d\n", fb.fmt.width); printf("\tHeight : %d\n", fb.fmt.height); printf("\tPixel Format : '%s'\n", fcc2s(fb.fmt.pixelformat).c_str()); if (!is_ext) { printf("\tBytes per Line: %d\n", fb.fmt.bytesperline); printf("\tSize image : %d\n", fb.fmt.sizeimage); printf("\tColorspace : %s\n", colorspace2s(fb.fmt.colorspace).c_str()); if (fb.fmt.priv) printf("\tCustom Info : %08x\n", fb.fmt.priv); } }
void printfmt(const struct v4l2_format &vfmt) { const flag_def vbi_def[] = { { V4L2_VBI_UNSYNC, "unsynchronized" }, { V4L2_VBI_INTERLACED, "interlaced" }, { 0, NULL } }; printf("Format %s:\n", buftype2s(vfmt.type).c_str()); switch (vfmt.type) { case V4L2_BUF_TYPE_VIDEO_CAPTURE: case V4L2_BUF_TYPE_VIDEO_OUTPUT: printf("\tWidth/Height : %u/%u\n", vfmt.fmt.pix.width, vfmt.fmt.pix.height); printf("\tPixel Format : '%s'\n", fcc2s(vfmt.fmt.pix.pixelformat).c_str()); printf("\tField : %s\n", field2s(vfmt.fmt.pix.field).c_str()); printf("\tBytes per Line : %u\n", vfmt.fmt.pix.bytesperline); printf("\tSize Image : %u\n", vfmt.fmt.pix.sizeimage); printf("\tColorspace : %s\n", colorspace2s(vfmt.fmt.pix.colorspace).c_str()); printf("\tTransfer Function : %s\n", xfer_func2s(vfmt.fmt.pix.xfer_func).c_str()); printf("\tYCbCr Encoding : %s\n", ycbcr_enc2s(vfmt.fmt.pix.ycbcr_enc).c_str()); printf("\tQuantization : %s\n", quantization2s(vfmt.fmt.pix.quantization).c_str()); if (vfmt.fmt.pix.priv == V4L2_PIX_FMT_PRIV_MAGIC) printf("\tFlags : %s\n", pixflags2s(vfmt.fmt.pix.flags).c_str()); break; case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE: case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE: printf("\tWidth/Height : %u/%u\n", vfmt.fmt.pix_mp.width, vfmt.fmt.pix_mp.height); printf("\tPixel Format : '%s'\n", fcc2s(vfmt.fmt.pix_mp.pixelformat).c_str()); printf("\tField : %s\n", field2s(vfmt.fmt.pix_mp.field).c_str()); printf("\tNumber of planes : %u\n", vfmt.fmt.pix_mp.num_planes); printf("\tFlags : %s\n", pixflags2s(vfmt.fmt.pix_mp.flags).c_str()); printf("\tColorspace : %s\n", colorspace2s(vfmt.fmt.pix_mp.colorspace).c_str()); printf("\tTransfer Function : %s\n", xfer_func2s(vfmt.fmt.pix_mp.xfer_func).c_str()); printf("\tYCbCr Encoding : %s\n", ycbcr_enc2s(vfmt.fmt.pix_mp.ycbcr_enc).c_str()); printf("\tQuantization : %s\n", quantization2s(vfmt.fmt.pix_mp.quantization).c_str()); for (int i = 0; i < vfmt.fmt.pix_mp.num_planes && i < VIDEO_MAX_PLANES; i++) { printf("\tPlane %d :\n", i); printf("\t Bytes per Line : %u\n", vfmt.fmt.pix_mp.plane_fmt[i].bytesperline); printf("\t Size Image : %u\n", vfmt.fmt.pix_mp.plane_fmt[i].sizeimage); } break; case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY: case V4L2_BUF_TYPE_VIDEO_OVERLAY: printf("\tLeft/Top : %d/%d\n", vfmt.fmt.win.w.left, vfmt.fmt.win.w.top); printf("\tWidth/Height: %d/%d\n", vfmt.fmt.win.w.width, vfmt.fmt.win.w.height); printf("\tField : %s\n", field2s(vfmt.fmt.win.field).c_str()); printf("\tChroma Key : 0x%08x\n", vfmt.fmt.win.chromakey); printf("\tGlobal Alpha: 0x%02x\n", vfmt.fmt.win.global_alpha); printf("\tClip Count : %u\n", vfmt.fmt.win.clipcount); if (vfmt.fmt.win.clips) 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("\tClip Bitmap : %s", vfmt.fmt.win.bitmap ? "Yes, " : "No\n"); if (vfmt.fmt.win.bitmap) { unsigned char *bitmap = (unsigned char *)vfmt.fmt.win.bitmap; unsigned stride = (vfmt.fmt.win.w.width + 7) / 8; unsigned cnt = 0; for (unsigned y = 0; y < vfmt.fmt.win.w.height; y++) for (unsigned x = 0; x < vfmt.fmt.win.w.width; x++) if (bitmap[y * stride + x / 8] & (1 << (x & 7))) cnt++; printf("%u bits of %u are set\n", cnt, vfmt.fmt.win.w.width * vfmt.fmt.win.w.height); } break; case V4L2_BUF_TYPE_VBI_CAPTURE: case V4L2_BUF_TYPE_VBI_OUTPUT: printf("\tSampling Rate : %u Hz\n", vfmt.fmt.vbi.sampling_rate); printf("\tOffset : %u samples (%g secs after leading edge)\n", vfmt.fmt.vbi.offset, (double)vfmt.fmt.vbi.offset / (double)vfmt.fmt.vbi.sampling_rate); printf("\tSamples per Line: %u\n", vfmt.fmt.vbi.samples_per_line); printf("\tSample Format : %s\n", fcc2s(vfmt.fmt.vbi.sample_format).c_str()); printf("\tStart 1st Field : %u\n", vfmt.fmt.vbi.start[0]); printf("\tCount 1st Field : %u\n", vfmt.fmt.vbi.count[0]); printf("\tStart 2nd Field : %u\n", vfmt.fmt.vbi.start[1]); printf("\tCount 2nd Field : %u\n", vfmt.fmt.vbi.count[1]); if (vfmt.fmt.vbi.flags) printf("\tFlags : %s\n", flags2s(vfmt.fmt.vbi.flags, vbi_def).c_str()); break; case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE: case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT: printf("\tService Set : %s\n", service2s(vfmt.fmt.sliced.service_set).c_str()); for (int i = 0; i < 24; i++) { printf("\tService Line %2d: %8s / %-8s\n", i, service2s(vfmt.fmt.sliced.service_lines[0][i]).c_str(), service2s(vfmt.fmt.sliced.service_lines[1][i]).c_str()); } printf("\tI/O Size : %u\n", vfmt.fmt.sliced.io_size); break; case V4L2_BUF_TYPE_SDR_CAPTURE: case V4L2_BUF_TYPE_SDR_OUTPUT: printf("\tSample Format : %s\n", fcc2s(vfmt.fmt.sdr.pixelformat).c_str()); printf("\tBuffer Size : %u\n", vfmt.fmt.sdr.buffersize); break; } }