[vlc-commits] v4l2 demux: add colorimetry infos
Rémi Denis-Courmont
git at videolan.org
Sun Apr 17 11:07:59 CEST 2016
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Apr 17 11:44:41 2016 +0300| [2769e85f2a824c3a12fa777260a5014c56ed99d2] | committer: Rémi Denis-Courmont
v4l2 demux: add colorimetry infos
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=2769e85f2a824c3a12fa777260a5014c56ed99d2
---
modules/access/v4l2/demux.c | 134 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 134 insertions(+)
diff --git a/modules/access/v4l2/demux.c b/modules/access/v4l2/demux.c
index 7da2079..e56714c 100644
--- a/modules/access/v4l2/demux.c
+++ b/modules/access/v4l2/demux.c
@@ -404,6 +404,140 @@ static int InitVideo (demux_t *demux, int fd, uint32_t caps)
es_fmt.video.i_frame_rate_base = parm.parm.capture.timeperframe.numerator;
GetAR (fd, &es_fmt.video.i_sar_num, &es_fmt.video.i_sar_den);
+ msg_Dbg (demux, "color primaries: %u", fmt.fmt.pix.colorspace);
+ switch (fmt.fmt.pix.colorspace)
+ {
+ case V4L2_COLORSPACE_DEFAULT:
+ break;
+ case V4L2_COLORSPACE_SMPTE170M:
+ es_fmt.video.primaries = COLOR_PRIMARIES_BT601_525;
+ es_fmt.video.transfer = TRANSFER_FUNC_BT709;
+ es_fmt.video.space = COLOR_SPACE_BT601;
+ break;
+ case V4L2_COLORSPACE_SMPTE240M: /* not supported */
+ break;
+ case V4L2_COLORSPACE_REC709:
+ es_fmt.video.primaries = COLOR_PRIMARIES_BT709;
+ es_fmt.video.transfer = TRANSFER_FUNC_BT709;
+ es_fmt.video.space = COLOR_SPACE_BT709;
+ break;
+ case V4L2_COLORSPACE_470_SYSTEM_M:
+ es_fmt.video.transfer = TRANSFER_FUNC_BT709;
+ es_fmt.video.space = COLOR_SPACE_BT601;
+ break;
+ case V4L2_COLORSPACE_470_SYSTEM_BG:
+ es_fmt.video.primaries = COLOR_PRIMARIES_BT601_625;
+ es_fmt.video.transfer = TRANSFER_FUNC_BT709;
+ es_fmt.video.space = COLOR_SPACE_BT601;
+ break;
+ case V4L2_COLORSPACE_JPEG:
+ es_fmt.video.primaries = COLOR_PRIMARIES_SRGB;
+ es_fmt.video.transfer = TRANSFER_FUNC_SRGB;
+ es_fmt.video.space = COLOR_SPACE_BT601;
+ es_fmt.video.b_color_range_full = true;
+ break;
+ case V4L2_COLORSPACE_SRGB:
+ es_fmt.video.primaries = COLOR_PRIMARIES_SRGB;
+ es_fmt.video.transfer = TRANSFER_FUNC_SRGB;
+ es_fmt.video.space = COLOR_SPACE_UNDEF; /* sYCC unsupported */
+ break;
+ case V4L2_COLORSPACE_ADOBERGB: /* not supported */
+ es_fmt.video.space = COLOR_SPACE_BT601;
+ break;
+ case V4L2_COLORSPACE_BT2020:
+ es_fmt.video.primaries = COLOR_PRIMARIES_BT2020;
+ es_fmt.video.transfer = TRANSFER_FUNC_BT2020;
+ es_fmt.video.space = COLOR_SPACE_BT2020;
+ break;
+ case V4L2_COLORSPACE_RAW:
+ es_fmt.video.transfer = TRANSFER_FUNC_LINEAR;
+ break;
+ case V4L2_COLORSPACE_DCI_P3:
+ es_fmt.video.primaries = COLOR_PRIMARIES_DCI_P3;
+ es_fmt.video.transfer = TRANSFER_FUNC_UNDEF;
+ es_fmt.video.space = COLOR_SPACE_BT2020;
+ break;
+ default:
+ msg_Warn (demux, "unknown color space %u", fmt.fmt.pix.colorspace);
+ break;
+ }
+
+ msg_Dbg (demux, "transfer function: %u", fmt.fmt.pix.xfer_func);
+ switch (fmt.fmt.pix.xfer_func)
+ {
+ case V4L2_XFER_FUNC_DEFAULT:
+ /* If transfer function is default, the transfer function is
+ * inferred from the colorspace value for backward compatibility.
+ * See V4L2 documentation for details. */
+ break;
+ case V4L2_XFER_FUNC_709:
+ es_fmt.video.transfer = TRANSFER_FUNC_BT709;
+ break;
+ case V4L2_XFER_FUNC_SRGB:
+ es_fmt.video.transfer = TRANSFER_FUNC_SRGB;
+ break;
+ case V4L2_XFER_FUNC_ADOBERGB:
+ case V4L2_XFER_FUNC_SMPTE240M:
+ es_fmt.video.transfer = TRANSFER_FUNC_UNDEF;
+ break;
+ case V4L2_XFER_FUNC_NONE:
+ es_fmt.video.transfer = TRANSFER_FUNC_LINEAR;
+ break;
+ case V4L2_XFER_FUNC_DCI_P3:
+ case V4L2_XFER_FUNC_SMPTE2084:
+ es_fmt.video.transfer = TRANSFER_FUNC_UNDEF;
+ break;
+ default:
+ msg_Warn (demux, "unknown transfer function %u",
+ fmt.fmt.pix.xfer_func);
+ break;
+ }
+
+ msg_Dbg (demux, "YCbCr encoding: %u", fmt.fmt.pix.ycbcr_enc);
+ switch (fmt.fmt.pix.ycbcr_enc)
+ {
+ case V4L2_YCBCR_ENC_DEFAULT:
+ /* Same as transfer function - use color space value */
+ break;
+ case V4L2_YCBCR_ENC_601:
+ es_fmt.video.space = COLOR_SPACE_BT601;
+ break;
+ case V4L2_YCBCR_ENC_709:
+ es_fmt.video.space = COLOR_SPACE_BT709;
+ break;
+ case V4L2_YCBCR_ENC_XV601:
+ case V4L2_YCBCR_ENC_XV709:
+ case V4L2_YCBCR_ENC_SYCC:
+ break;
+ case V4L2_YCBCR_ENC_BT2020:
+ es_fmt.video.space = COLOR_SPACE_BT2020;
+ break;
+ case V4L2_YCBCR_ENC_BT2020_CONST_LUM:
+ case V4L2_YCBCR_ENC_SMPTE240M:
+ break;
+ default:
+ msg_Err (demux, "unknown YCbCr encoding: %u",
+ fmt.fmt.pix.ycbcr_enc);
+ break;
+ }
+
+ msg_Dbg (demux, "quantization: %u", fmt.fmt.pix.quantization);
+ switch (fmt.fmt.pix.quantization)
+ {
+ case V4L2_QUANTIZATION_DEFAULT:
+ break;
+ case V4L2_QUANTIZATION_FULL_RANGE:
+ es_fmt.video.b_color_range_full = true;
+ break;
+ case V4L2_QUANTIZATION_LIM_RANGE:
+ es_fmt.video.b_color_range_full = false;
+ break;
+ default:
+ msg_Err (demux, "unknown quantization: %u",
+ fmt.fmt.pix.quantization);
+ break;
+ }
+
msg_Dbg (demux, "added new video ES %4.4s %ux%u (%ux%u)",
(char *)&es_fmt.i_codec,
es_fmt.video.i_visible_width, es_fmt.video.i_visible_height,
More information about the vlc-commits
mailing list