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: v4l2-ctl: add support for colorspace transfer functions Author: Hans Verkuil <[email protected]> Date: Sat Jun 6 10:44:06 2015 +0200 Support the new xfer_func field. Signed-off-by: Hans Verkuil <[email protected]> utils/v4l2-ctl/v4l2-ctl-streaming.cpp | 2 + utils/v4l2-ctl/v4l2-ctl-vidcap.cpp | 30 ++++++++++------ utils/v4l2-ctl/v4l2-ctl-vidout.cpp | 34 ++++++++++------- utils/v4l2-ctl/v4l2-ctl.cpp | 64 ++++++++++++++++++++++++++------- utils/v4l2-ctl/v4l2-ctl.h | 5 ++- 5 files changed, 95 insertions(+), 40 deletions(-) --- http://git.linuxtv.org/cgit.cgi/v4l-utils.git/commit/?id=df85746c1e7d7292d3055b9a291d7d82915e2e38 diff --git a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp index a8c389b..789d303 100644 --- a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp +++ b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp @@ -640,6 +640,7 @@ static int do_setup_out_buffers(int fd, buffers &b, FILE *fin, bool qbuf) tpg_reset_source(&tpg, fmt.fmt.pix_mp.width, fmt.fmt.pix_mp.height * factor, field); tpg_s_colorspace(&tpg, fmt.fmt.pix_mp.colorspace); + tpg_s_xfer_func(&tpg, fmt.fmt.pix_mp.xfer_func); tpg_s_ycbcr_enc(&tpg, fmt.fmt.pix_mp.ycbcr_enc); tpg_s_quantization(&tpg, fmt.fmt.pix_mp.quantization); if (can_fill) @@ -652,6 +653,7 @@ static int do_setup_out_buffers(int fd, buffers &b, FILE *fin, bool qbuf) tpg_reset_source(&tpg, fmt.fmt.pix.width, fmt.fmt.pix.height * factor, field); tpg_s_colorspace(&tpg, fmt.fmt.pix.colorspace); + tpg_s_xfer_func(&tpg, fmt.fmt.pix.xfer_func); tpg_s_ycbcr_enc(&tpg, fmt.fmt.pix.ycbcr_enc); tpg_s_quantization(&tpg, fmt.fmt.pix.quantization); tpg_s_bytesperline(&tpg, 0, fmt.fmt.pix.bytesperline); diff --git a/utils/v4l2-ctl/v4l2-ctl-vidcap.cpp b/utils/v4l2-ctl/v4l2-ctl-vidcap.cpp index 8a9d872..c011c3e 100644 --- a/utils/v4l2-ctl/v4l2-ctl-vidcap.cpp +++ b/utils/v4l2-ctl/v4l2-ctl-vidcap.cpp @@ -40,18 +40,25 @@ void vidcap_usage(void) " -V, --get-fmt-video\n" " query the video capture format [VIDIOC_G_FMT]\n" " -v, --set-fmt-video\n" - " --try-fmt-video=width=<w>,height=<h>,pixelformat=<pf>,field=<f>,quantization=<q>,\n" - " premul-alpha,bytesperline=<bpl>\n" + " --try-fmt-video=width=<w>,height=<h>,pixelformat=<pf>,field=<f>,colorspace=<c>,\n" + " xfer=<xf>,ycbcr=<y>,quantization=<q>,premul-alpha,bytesperline=<bpl>\n" " set/try the video capture format [VIDIOC_S/TRY_FMT]\n" " pixelformat is either the format index as reported by\n" - " --list-formats, or the fourcc value as a string.\n" + " --list-formats, or the fourcc value as a string.\n" " The bytesperline option can be used multiple times, once for each plane.\n" " premul-alpha sets V4L2_PIX_FMT_FLAG_PREMUL_ALPHA.\n" - " <f> can be one of:\n" - " any, none, top, bottom, interlaced, seq_tb, seq_bt,\n" - " alternate, interlaced_tb, interlaced_bt\n" - " <q> can be one of:\n" - " default, full-range, lim-range\n" + " <f> can be one of the following field layouts:\n" + " any, none, top, bottom, interlaced, seq_tb, seq_bt,\n" + " alternate, interlaced_tb, interlaced_bt\n" + " <c> can be one of the following colorspaces:\n" + " smpte170m, smpte240m, rec709, 470m, 470bg, jpeg, srgb,\n" + " adobergb, bt2020\n" + " <xf> can be one of the following transfer functions:\n" + " default, 709, srgb, adobergb, smpte240m, none\n" + " <y> can be one of the following Y'CbCr encodings:\n" + " default, 601, 709, xv601, xv709, sycc, bt2020, bt2020c, smpte240m\n" + " <q> can be one of the following quantization methods:\n" + " default, full-range, lim-range\n" ); } @@ -194,15 +201,16 @@ static void print_video_fields(int fd) void vidcap_cmd(int ch, char *optarg) { - __u32 colorspace, ycbcr, quantization; + __u32 colorspace, xfer_func, ycbcr, quantization; char *value, *subs; switch (ch) { case OptSetVideoFormat: case OptTryVideoFormat: set_fmts = parse_fmt(optarg, width, height, pixfmt, field, colorspace, - ycbcr, quantization, flags, bytesperline); - if (!set_fmts || (set_fmts & (FmtColorspace | FmtYCbCr | FmtQuantization))) { + xfer_func, ycbcr, quantization, flags, bytesperline); + if (!set_fmts || + (set_fmts & (FmtColorspace | FmtYCbCr | FmtQuantization | FmtXferFunc))) { vidcap_usage(); exit(1); } diff --git a/utils/v4l2-ctl/v4l2-ctl-vidout.cpp b/utils/v4l2-ctl/v4l2-ctl-vidout.cpp index a0540ff..f9deea9 100644 --- a/utils/v4l2-ctl/v4l2-ctl-vidout.cpp +++ b/utils/v4l2-ctl/v4l2-ctl-vidout.cpp @@ -17,7 +17,7 @@ #include "v4l2-ctl.h" static unsigned set_fmts_out; -static __u32 width, height, pixfmt, field, colorspace, ycbcr, quantization, flags; +static __u32 width, height, pixfmt, field, colorspace, xfer_func, ycbcr, quantization, flags; static __u32 bytesperline[VIDEO_MAX_PLANES]; void vidout_usage(void) @@ -29,22 +29,24 @@ void vidout_usage(void) " query the video output format [VIDIOC_G_FMT]\n" " --set-fmt-video-out\n" " --try-fmt-video-out=width=<w>,height=<h>,pixelformat=<pf>,field=<f>,colorspace=<c>,\n" - " ycbcr=<y>,quantization=<q>,premul-alpha,bytesperline=<bpl>\n" + " xfer=<xf>,ycbcr=<y>,quantization=<q>,premul-alpha,bytesperline=<bpl>\n" " set/try the video output format [VIDIOC_S/TRY_FMT]\n" " pixelformat is either the format index as reported by\n" - " --list-formats-out, or the fourcc value as a string.\n" + " --list-formats-out, or the fourcc value as a string.\n" " premul-alpha sets V4L2_PIX_FMT_FLAG_PREMUL_ALPHA.\n" " The bytesperline option can be used multiple times, once for each plane.\n" - " <f> can be one of:\n" - " any, none, top, bottom, interlaced, seq_tb, seq_bt,\n" - " alternate, interlaced_tb, interlaced_bt\n" - " <c> can be one of:\n" - " smpte170m, smpte240m, rec709, 470m, 470bg, jpeg, srgb,\n" - " adobergb, bt2020\n" - " <y> can be one of:\n" - " default, 601, 709, xv601, xv709, sycc, bt2020, bt2020c, smpte240m\n" - " <q> can be one of:\n" - " default, full-range, lim-range\n" + " <f> can be one of the following field layouts:\n" + " any, none, top, bottom, interlaced, seq_tb, seq_bt,\n" + " alternate, interlaced_tb, interlaced_bt\n" + " <c> can be one of the following colorspaces:\n" + " smpte170m, smpte240m, rec709, 470m, 470bg, jpeg, srgb,\n" + " adobergb, bt2020\n" + " <xf> can be one of the following transfer functions:\n" + " default, 709, srgb, adobergb, smpte240m, none\n" + " <y> can be one of the following Y'CbCr encodings:\n" + " default, 601, 709, xv601, xv709, sycc, bt2020, bt2020c, smpte240m\n" + " <q> can be one of the following quantization methods:\n" + " default, full-range, lim-range\n" ); } @@ -85,7 +87,7 @@ void vidout_cmd(int ch, char *optarg) case OptSetVideoOutFormat: case OptTryVideoOutFormat: set_fmts_out = parse_fmt(optarg, width, height, pixfmt, field, - colorspace, ycbcr, quantization, flags, bytesperline); + colorspace, xfer_func, ycbcr, quantization, flags, bytesperline); if (!set_fmts_out) { vidcap_usage(); exit(1); @@ -122,6 +124,8 @@ void vidout_set(int fd) vfmt.fmt.pix_mp.field = field; if (set_fmts_out & FmtColorspace) vfmt.fmt.pix_mp.colorspace = colorspace; + if (set_fmts_out & FmtXferFunc) + vfmt.fmt.pix_mp.xfer_func = xfer_func; if (set_fmts_out & FmtYCbCr) vfmt.fmt.pix_mp.ycbcr_enc = ycbcr; if (set_fmts_out & FmtQuantization) @@ -156,6 +160,8 @@ void vidout_set(int fd) vfmt.fmt.pix.field = field; if (set_fmts_out & FmtColorspace) vfmt.fmt.pix.colorspace = colorspace; + if (set_fmts_out & FmtXferFunc) + vfmt.fmt.pix.xfer_func = xfer_func; if (set_fmts_out & FmtYCbCr) vfmt.fmt.pix.ycbcr_enc = ycbcr; if (set_fmts_out & FmtQuantization) diff --git a/utils/v4l2-ctl/v4l2-ctl.cpp b/utils/v4l2-ctl/v4l2-ctl.cpp index 5124540..a7f1e9e 100644 --- a/utils/v4l2-ctl/v4l2-ctl.cpp +++ b/utils/v4l2-ctl/v4l2-ctl.cpp @@ -396,7 +396,27 @@ std::string colorspace2s(int val) } } -std::string ycbcr_enc2s(int val) +static std::string xfer_func2s(int val) +{ + switch (val) { + case V4L2_XFER_FUNC_DEFAULT: + return "Default"; + case V4L2_XFER_FUNC_709: + return "Rec. 709"; + case V4L2_XFER_FUNC_SRGB: + return "sRGB"; + case V4L2_XFER_FUNC_ADOBERGB: + return "AdobeRGB"; + case V4L2_XFER_FUNC_SMPTE240M: + return "SMPTE 240M"; + case V4L2_XFER_FUNC_NONE: + return "None"; + default: + return "Unknown (" + num2s(val) + ")"; + } +} + +static std::string ycbcr_enc2s(int val) { switch (val) { case V4L2_YCBCR_ENC_DEFAULT: @@ -422,7 +442,7 @@ std::string ycbcr_enc2s(int val) } } -std::string quantization2s(int val) +static std::string quantization2s(int val) { switch (val) { case V4L2_QUANTIZATION_DEFAULT: @@ -491,16 +511,17 @@ void printfmt(const struct v4l2_format &vfmt) 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("\tYCbCr Encoding: %s\n", ycbcr_enc2s(vfmt.fmt.pix.ycbcr_enc).c_str()); - printf("\tQuantization : %s\n", quantization2s(vfmt.fmt.pix.quantization).c_str()); + 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()); + 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: @@ -510,6 +531,7 @@ void printfmt(const struct v4l2_format &vfmt) 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++) { @@ -788,6 +810,17 @@ static __u32 parse_colorspace(const char *s) return 0; } +static __u32 parse_xfer_func(const char *s) +{ + if (!strcmp(s, "default")) return V4L2_XFER_FUNC_DEFAULT; + if (!strcmp(s, "smpte240m")) return V4L2_XFER_FUNC_SMPTE240M; + if (!strcmp(s, "rec709")) return V4L2_XFER_FUNC_709; + if (!strcmp(s, "srgb")) return V4L2_XFER_FUNC_SRGB; + if (!strcmp(s, "adobergb")) return V4L2_XFER_FUNC_ADOBERGB; + if (!strcmp(s, "none")) return V4L2_XFER_FUNC_NONE; + return 0; +} + static __u32 parse_ycbcr(const char *s) { if (!strcmp(s, "default")) return V4L2_YCBCR_ENC_DEFAULT; @@ -811,8 +844,8 @@ static __u32 parse_quantization(const char *s) } int parse_fmt(char *optarg, __u32 &width, __u32 &height, __u32 &pixelformat, - __u32 &field, __u32 &colorspace, __u32 &ycbcr, __u32 &quantization, - __u32 &flags, __u32 *bytesperline) + __u32 &field, __u32 &colorspace, __u32 &xfer_func, __u32 &ycbcr, + __u32 &quantization, __u32 &flags, __u32 *bytesperline) { char *value, *subs; int fmts = 0; @@ -833,6 +866,7 @@ int parse_fmt(char *optarg, __u32 &width, __u32 &height, __u32 &pixelformat, "bytesperline", "premul-alpha", "quantization", + "xfer", NULL }; @@ -892,6 +926,10 @@ int parse_fmt(char *optarg, __u32 &width, __u32 &height, __u32 &pixelformat, quantization = parse_quantization(value); fmts |= FmtQuantization; break; + case 9: + xfer_func = parse_xfer_func(value); + fmts |= FmtXferFunc; + break; default: return 0; } diff --git a/utils/v4l2-ctl/v4l2-ctl.h b/utils/v4l2-ctl/v4l2-ctl.h index e47612f..efb5eb3 100644 --- a/utils/v4l2-ctl/v4l2-ctl.h +++ b/utils/v4l2-ctl/v4l2-ctl.h @@ -232,6 +232,7 @@ typedef struct { #define FmtQuantization (1L<<10) #define FmtFlags (1L<<11) #define FmtBytesPerLine (1L<<12) +#define FmtXferFunc (1L<<13) // v4l2-ctl.cpp int doioctl_name(int fd, unsigned long int request, void *parm, const char *name); @@ -248,8 +249,8 @@ std::string field2s(int val); void print_v4lstd(v4l2_std_id std); __u32 parse_field(const char *s); int parse_fmt(char *optarg, __u32 &width, __u32 &height, __u32 &pixelformat, - __u32 &field, __u32 &colorspace, __u32 &ycbcr, __u32 &quantization, - __u32 &flags, __u32 *bytesperline); + __u32 &field, __u32 &colorspace, __u32 &xfer, __u32 &ycbcr, + __u32 &quantization, __u32 &flags, __u32 *bytesperline); __u32 find_pixel_format(int fd, unsigned index, bool output, bool mplane); void printfmt(const struct v4l2_format &vfmt); void print_video_formats(int fd, __u32 type); _______________________________________________ linuxtv-commits mailing list [email protected] http://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits
