Commit 2769e85f authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

v4l2 demux: add colorimetry infos

parent 8748a077
......@@ -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,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment