Skip to content

Commit 8825a42

Browse files
Added CICP profile types
1 parent c5cc7a7 commit 8825a42

5 files changed

Lines changed: 363 additions & 0 deletions

File tree

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
// Copyright (c) Six Labors.
2+
// Licensed under the Six Labors Split License.
3+
4+
namespace SixLabors.ImageSharp.Metadata.Profiles.CICP;
5+
6+
/// <summary>
7+
/// Represents a CICP profile as per ITU-T H.273 / ISO/IEC 23091-2_2019 providing access to color space information
8+
/// </summary>
9+
public sealed class CicpProfile : IDeepCloneable<CicpProfile>
10+
{
11+
/// <summary>
12+
/// Initializes a new instance of the <see cref="CicpProfile"/> class.
13+
/// </summary>
14+
public CicpProfile()
15+
: this(2, 2, 2, null)
16+
{
17+
}
18+
19+
/// <summary>
20+
/// Initializes a new instance of the <see cref="CicpProfile"/> class.
21+
/// </summary>
22+
/// <param name="colorPrimaries">The color primaries as number according to ITU-T H.273 / ISO/IEC 23091-2_2019.</param>
23+
/// <param name="transferCharacteristics">The transfer characteristics as number according to ITU-T H.273 / ISO/IEC 23091-2_2019.</param>
24+
/// <param name="matrixCoefficients">The matrix coefficients as number according to ITU-T H.273 / ISO/IEC 23091-2_2019.</param>
25+
/// <param name="fullRange">The full range flag, or null if unknown.</param>
26+
public CicpProfile(byte colorPrimaries, byte transferCharacteristics, byte matrixCoefficients, bool? fullRange)
27+
{
28+
this.ColorPrimaries = Enum.IsDefined(typeof(CicpColorPrimaries), colorPrimaries) ? (CicpColorPrimaries)colorPrimaries : CicpColorPrimaries.Unspecified;
29+
this.TransferCharacteristics = Enum.IsDefined(typeof(CicpTransferCharacteristics), transferCharacteristics) ? (CicpTransferCharacteristics)transferCharacteristics : CicpTransferCharacteristics.Unspecified;
30+
this.MatrixCoefficients = Enum.IsDefined(typeof(CicpMatrixCoefficients), matrixCoefficients) ? (CicpMatrixCoefficients)matrixCoefficients : CicpMatrixCoefficients.Unspecified;
31+
this.FullRange = fullRange ?? (this.MatrixCoefficients == CicpMatrixCoefficients.Identity);
32+
}
33+
34+
/// <summary>
35+
/// Initializes a new instance of the <see cref="CicpProfile"/> class
36+
/// by making a copy from another CICP profile.
37+
/// </summary>
38+
/// <param name="other">The other CICP profile, where the clone should be made from.</param>
39+
/// <exception cref="ArgumentNullException"><paramref name="other"/> is null.</exception>>
40+
private CicpProfile(CicpProfile other)
41+
{
42+
Guard.NotNull(other, nameof(other));
43+
44+
this.ColorPrimaries = other.ColorPrimaries;
45+
this.TransferCharacteristics = other.TransferCharacteristics;
46+
this.MatrixCoefficients = other.MatrixCoefficients;
47+
this.FullRange = other.FullRange;
48+
}
49+
50+
/// <summary>
51+
/// Gets or sets the color primaries
52+
/// </summary>
53+
public CicpColorPrimaries ColorPrimaries { get; set; }
54+
55+
/// <summary>
56+
/// Gets or sets the transfer characteristics
57+
/// </summary>
58+
public CicpTransferCharacteristics TransferCharacteristics { get; set; }
59+
60+
/// <summary>
61+
/// Gets or sets the matrix coefficients
62+
/// </summary>
63+
public CicpMatrixCoefficients MatrixCoefficients { get; set; }
64+
65+
/// <summary>
66+
/// Gets or sets a value indicating whether the colors use the full numeric range
67+
/// </summary>
68+
public bool FullRange { get; set; }
69+
70+
/// <inheritdoc/>
71+
public CicpProfile DeepClone() => new(this);
72+
}
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
// Copyright (c) Six Labors.
2+
// Licensed under the Six Labors Split License.
3+
4+
namespace SixLabors.ImageSharp.Metadata.Profiles.CICP;
5+
6+
#pragma warning disable CA1707 // Underscores in enum members
7+
8+
/// <summary>
9+
/// Color primaries according to ITU-T H.273 / ISO/IEC 23091-2_2019 subclause 8.1
10+
/// </summary>
11+
public enum CicpColorPrimaries : byte
12+
{
13+
/// <summary>
14+
/// Rec. ITU-R BT.709-6
15+
/// IEC 61966-2-1 sRGB or sYCC
16+
/// IEC 61966-2-4
17+
/// SMPTE RP 177 (1993) Annex B
18+
/// </summary>
19+
ItuRBt709_6 = 1,
20+
21+
/// <summary>
22+
/// Image characteristics are unknown or are determined by the application.
23+
/// </summary>
24+
Unspecified = 2,
25+
26+
/// <summary>
27+
/// Rec. ITU-R BT.470-6 System M (historical)
28+
/// </summary>
29+
ItuRBt470_6M = 4,
30+
31+
/// <summary>
32+
/// Rec. ITU-R BT.601-7 625
33+
/// Rec. ITU-R BT.1700-0 625 PAL and 625 SECAM
34+
/// </summary>
35+
ItuRBt601_7_625 = 5,
36+
37+
/// <summary>
38+
/// Rec. ITU-R BT.601-7 525
39+
/// Rec. ITU-R BT.1700-0 NTSC
40+
/// SMPTE ST 170 (2004)
41+
/// (functionally the same as the value 7)
42+
/// </summary>
43+
ItuRBt601_7_525 = 6,
44+
45+
/// <summary>
46+
/// SMPTE ST 240 (1999)
47+
/// (functionally the same as the value 6)
48+
/// </summary>
49+
SmpteSt240 = 7,
50+
51+
/// <summary>
52+
/// Generic film (colour filters using Illuminant C)
53+
/// </summary>
54+
GenericFilm = 8,
55+
56+
/// <summary>
57+
/// Rec. ITU-R BT.2020-2
58+
/// Rec. ITU-R BT.2100-2
59+
/// </summary>
60+
ItuRBt2020_2 = 9,
61+
62+
/// <summary>
63+
/// SMPTE ST 428-1 (2019)
64+
/// (CIE 1931 XYZ as in ISO 11664-1)
65+
/// </summary>
66+
SmpteSt428_1 = 10,
67+
68+
/// <summary>
69+
/// SMPTE RP 431-2 (2011)
70+
/// DCI P3
71+
/// </summary>
72+
SmpteRp431_2 = 11,
73+
74+
/// <summary>
75+
/// SMPTE ST 432-1 (2010)
76+
/// P3 D65 / Display P3
77+
/// </summary>
78+
SmpteEg432_1 = 12,
79+
80+
/// <summary>
81+
/// EBU Tech.3213-E
82+
/// </summary>
83+
EbuTech3213E = 22,
84+
}
85+
86+
#pragma warning restore CA1707 // Underscores in enum members
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
// Copyright (c) Six Labors.
2+
// Licensed under the Six Labors Split License.
3+
4+
namespace SixLabors.ImageSharp.Metadata.Profiles.CICP;
5+
6+
#pragma warning disable CA1707 // Underscores in enum members
7+
8+
/// <summary>
9+
/// Matrix coefficients according to ITU-T H.273 / ISO/IEC 23091-2_2019 subclause 8.3
10+
/// </summary>
11+
public enum CicpMatrixCoefficients : byte
12+
{
13+
/// <summary>
14+
/// The identity matrix.
15+
/// IEC 61966-2-1 sRGB
16+
/// SMPTE ST 428-1 (2019)
17+
/// </summary>
18+
Identity = 0,
19+
20+
/// <summary>
21+
/// Rec. ITU-R BT.709-6
22+
/// IEC 61966-2-4 xvYCC709
23+
/// SMPTE RP 177 (1993) Annex B
24+
/// </summary>
25+
ItuRBt709_6 = 1,
26+
27+
/// <summary>
28+
/// Image characteristics are unknown or are determined by the application.
29+
/// </summary>
30+
Unspecified = 2,
31+
32+
/// <summary>
33+
/// FCC Title 47 Code of Federal Regulations 73.682 (a) (20)
34+
/// </summary>
35+
Fcc47 = 4,
36+
37+
/// <summary>
38+
/// Rec. ITU-R BT.601-7 625
39+
/// Rec. ITU-R BT.1700-0 625 PAL and 625 SECAM
40+
/// IEC 61966-2-1 sYCC
41+
/// IEC 61966-2-4 xvYCC601
42+
/// (functionally the same as the value 6)
43+
/// </summary>
44+
ItuRBt601_7_625 = 5,
45+
46+
/// <summary>
47+
/// Rec. ITU-R BT.601-7 525
48+
/// Rec. ITU-R BT.1700-0 NTSC
49+
/// SMPTE ST 170 (2004)
50+
/// (functionally the same as the value 5)
51+
/// </summary>
52+
ItuRBt601_7_525 = 6,
53+
54+
/// <summary>
55+
/// SMPTE ST 240 (1999)
56+
/// </summary>
57+
SmpteSt240 = 7,
58+
59+
/// <summary>
60+
/// YCgCo
61+
/// </summary>
62+
YCgCo = 8,
63+
64+
/// <summary>
65+
/// Rec. ITU-R BT.2020-2 (non-constant luminance)
66+
/// Rec. ITU-R BT.2100-2 Y′CbCr
67+
/// </summary>
68+
ItuRBt2020_2_Ncl = 9,
69+
70+
/// <summary>
71+
/// Rec. ITU-R BT.2020-2 (constant luminance)
72+
/// </summary>
73+
ItuRBt2020_2_Cl = 10,
74+
75+
/// <summary>
76+
/// SMPTE ST 2085 (2015)
77+
/// </summary>
78+
SmpteSt2085 = 11,
79+
80+
/// <summary>
81+
/// Chromaticity-derived non-constant luminance system
82+
/// </summary>
83+
ChromaDerivedNcl = 12,
84+
85+
/// <summary>
86+
/// Chromaticity-derived constant luminance system
87+
/// </summary>
88+
ChromaDerivedCl = 13,
89+
90+
/// <summary>
91+
/// Rec. ITU-R BT.2100-2 ICtCp
92+
/// </summary>
93+
ICtCp = 14,
94+
}
95+
96+
#pragma warning restore CA1707 // Underscores in enum members
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
// Copyright (c) Six Labors.
2+
// Licensed under the Six Labors Split License.
3+
4+
namespace SixLabors.ImageSharp.Metadata.Profiles.CICP;
5+
6+
#pragma warning disable CA1707 // Underscores in enum members
7+
8+
/// <summary>
9+
/// Transfer characteristics according to ITU-T H.273 / ISO/IEC 23091-2_2019 subclause 8.2
10+
/// /// </summary>
11+
public enum CicpTransferCharacteristics : byte
12+
{
13+
/// <summary>
14+
/// Rec. ITU-R BT.709-6
15+
/// (functionally the same as the values 6, 14 and 15)
16+
/// </summary>
17+
ItuRBt709_6 = 1,
18+
19+
/// <summary>
20+
/// Image characteristics are unknown or are determined by the application.
21+
/// </summary>
22+
Unspecified = 2,
23+
24+
/// <summary>
25+
/// Assumed display gamma 2.2
26+
/// Rec. ITU-R BT.1700-0 625 PAL and 625 SECAM
27+
/// </summary>
28+
Gamma2_2 = 4,
29+
30+
/// <summary>
31+
/// Assumed display gamma 2.8
32+
/// Rec. ITU-R BT.470-6 System B, G (historical)
33+
/// </summary>
34+
Gamma2_8 = 5,
35+
36+
/// <summary>
37+
/// Rec. ITU-R BT.601-7 525 or 625
38+
/// Rec. ITU-R BT.1700-0 NTSC
39+
/// SMPTE ST 170 (2004)
40+
/// (functionally the same as the values 1, 14 and 15)
41+
/// </summary>
42+
ItuRBt601_7 = 6,
43+
44+
/// <summary>
45+
/// SMPTE ST 240 (1999)
46+
/// </summary>
47+
SmpteSt240 = 7,
48+
49+
/// <summary>
50+
/// Linear transfer characteristics
51+
/// </summary>
52+
Linear = 8,
53+
54+
/// <summary>
55+
/// Logarithmic transfer characteristic (100:1 range)
56+
/// </summary>
57+
Log100 = 9,
58+
59+
/// <summary>
60+
/// Logarithmic transfer characteristic (100 * Sqrt( 10 ) : 1 range)
61+
/// </summary>
62+
Log100Sqrt = 10,
63+
64+
/// <summary>
65+
/// IEC 61966-2-4
66+
/// </summary>
67+
Iec61966_2_4 = 11,
68+
69+
/// <summary>
70+
/// Rec. ITU-R BT.1361-0 extended colour gamut system (historical)
71+
/// </summary>
72+
ItuRBt1361_0 = 12,
73+
74+
/// <summary>
75+
/// IEC 61966-2-1 sRGB or sYCC / Display P3
76+
/// </summary>
77+
Iec61966_2_1 = 13,
78+
79+
/// <summary>
80+
/// Rec. ITU-R BT.2020-2 (10-bit system)
81+
/// (functionally the same as the values 1, 6 and 15)
82+
/// </summary>
83+
ItuRBt2020_2_10bit = 14,
84+
85+
/// <summary>
86+
/// Rec. ITU-R BT.2020-2 (12-bit system)
87+
/// (functionally the same as the values 1, 6 and 14)
88+
/// /// </summary>
89+
ItuRBt2020_2_12bit = 15,
90+
91+
/// <summary>
92+
/// SMPTE ST 2084 (2014) for 10-, 12-, 14- and 16-bit systems
93+
/// Rec. ITU-R BT.2100-2 perceptual quantization (PQ) system
94+
/// </summary>
95+
SmpteSt2084 = 16,
96+
97+
/// <summary>
98+
/// SMPTE ST 428-1 (2019)
99+
/// </summary>
100+
SmpteSt428_1 = 17,
101+
102+
/// <summary>
103+
/// ARIB STD-B67 (2015)
104+
/// Rec. ITU-R BT.2100-2 hybrid log-gamma (HLG) system
105+
/// </summary>
106+
AribStdB67 = 18,
107+
}
108+
109+
#pragma warning restore CA1707 // Underscores in enum members
Binary file not shown.

0 commit comments

Comments
 (0)