From 52e69d7789a5b214edbb7d8b77a14a5f1d879f84 Mon Sep 17 00:00:00 2001 From: Johannes Kron Date: Mon, 19 Nov 2018 15:33:45 +0100 Subject: [PATCH] Explicitly specify color space enum indices This CL changes the color space enum indices to have the same values as specified in H264. The reason for this is to simplify a coming transmission protocol for color space information. Bug: webrtc:8651 Change-Id: I16fccae137f75d96ed925ed1421b111ec29ae7c9 Reviewed-on: https://webrtc-review.googlesource.com/c/111245 Commit-Queue: Johannes Kron Reviewed-by: Niels Moller Reviewed-by: Emircan Uysaler Cr-Commit-Position: refs/heads/master@{#25697} --- api/video/color_space.h | 122 +++++++++++++++++++++++----------------- 1 file changed, 69 insertions(+), 53 deletions(-) diff --git a/api/video/color_space.h b/api/video/color_space.h index 8102647b6f..cce3d92eb3 100644 --- a/api/video/color_space.h +++ b/api/video/color_space.h @@ -11,77 +11,93 @@ #ifndef API_VIDEO_COLOR_SPACE_H_ #define API_VIDEO_COLOR_SPACE_H_ +#include + namespace webrtc { -// Used to represent a color space for the purpose of color conversion. This -// class only represents color information that can be transferred through the -// bitstream of WebRTC's internal supported codecs: +// This class represents color information as specified in T-REC H.273, +// available from https://www.itu.int/rec/T-REC-H.273. +// +// WebRTC's supported codecs: // - VP9 supports color profiles, see VP9 Bitstream & Decoding Process // Specification Version 0.6 Section 7.2.2 "Color config semantics" available // from https://www.webmproject.org. -// TODO(emircan): Extract these values from decode and add to the existing ones. // - VP8 only supports BT.601, see // https://tools.ietf.org/html/rfc6386#section-9.2 -// - H264 supports different color primaries, transfer characteristics, matrix -// coefficients and range. See T-REC-H.264 E.2.1, "VUI parameters semantics", -// available from https://www.itu.int/rec/T-REC-H.264. +// - H264 uses the exact same representation as T-REC H.273. See T-REC-H.264 +// E.2.1, "VUI parameters semantics", available from +// https://www.itu.int/rec/T-REC-H.264. + class ColorSpace { public: - enum class PrimaryID { - kInvalid, - kBT709, - kBT470M, - kBT470BG, - kSMPTE170M, // Identical to BT601 - kSMPTE240M, - kFILM, - kBT2020, - kSMPTEST428, - kSMPTEST431, - kSMPTEST432, - kJEDECP22, + enum class PrimaryID : uint8_t { + // The indices are equal to the values specified in T-REC H.273 Table 2. + kInvalid = 0, + kBT709 = 1, + kUNSPECIFIED = 2, + kBT470M = 4, + kBT470BG = 5, + kSMPTE170M = 6, // Identical to BT601 + kSMPTE240M = 7, + kFILM = 8, + kBT2020 = 9, + kSMPTEST428 = 10, + kSMPTEST431 = 11, + kSMPTEST432 = 12, + kJEDECP22 = 22, // Identical to EBU3213-E }; - enum class TransferID { - kInvalid, - kBT709, - kGAMMA22, - kGAMMA28, - kSMPTE170M, - kSMPTE240M, - kLINEAR, - kLOG, - kLOG_SQRT, - kIEC61966_2_4, - kBT1361_ECG, - kIEC61966_2_1, - kBT2020_10, - kBT2020_12, - kSMPTEST2084, - kSMPTEST428, - kARIB_STD_B67, + enum class TransferID : uint8_t { + // The indices are equal to the values specified in T-REC H.273 Table 3. + kInvalid = 0, + kBT709 = 1, + kUNSPECIFIED = 2, + kGAMMA22 = 4, + kGAMMA28 = 5, + kSMPTE170M = 6, + kSMPTE240M = 7, + kLINEAR = 8, + kLOG = 9, + kLOG_SQRT = 10, + kIEC61966_2_4 = 11, + kBT1361_ECG = 12, + kIEC61966_2_1 = 13, + kBT2020_10 = 14, + kBT2020_12 = 15, + kSMPTEST2084 = 16, + kSMPTEST428 = 17, + kARIB_STD_B67 = 18, }; - enum class MatrixID { - kInvalid, - kRGB, - kBT709, - kFCC, - kBT470BG, - kSMPTE170M, - kSMPTE240M, - kYCOCG, - kBT2020_NCL, - kBT2020_CL, - kSMPTE2085, + enum class MatrixID : uint8_t { + // The indices are equal to the values specified in T-REC H.273 Table 4. + kRGB = 0, + kBT709 = 1, + kUNSPECIFIED = 2, + kFCC = 4, + kBT470BG = 5, + kSMPTE170M = 6, + kSMPTE240M = 7, + kYCOCG = 8, + kBT2020_NCL = 9, + kBT2020_CL = 10, + kSMPTE2085 = 11, + kCDNCLS = 12, + kCDCLS = 13, + kBT2100_ICTCP = 14, + kInvalid = 255 }; enum class RangeID { - kInvalid, + // The indices are equal to the values specified at + // https://www.webmproject.org/docs/container/#colour for the element Range. + kInvalid = 0, // Limited Rec. 709 color range with RGB values ranging from 16 to 235. - kLimited, + kLimited = 1, // Full RGB color range with RGB valees from 0 to 255. - kFull, + kFull = 2, + // Range is defined by MatrixCoefficients/TransferCharacteristics. + kDerived = 3 }; ColorSpace();