1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "third_party/blink/renderer/platform/graphics/color_space_profile_data.h"
6
7 #include "base/logging.h"
8 #include "third_party/blink/renderer/platform/wtf/wtf.h"
9
10 struct bt709ColorProfile {
databt709ColorProfile11 static char* data() // BT.709 HDTV ITU
12 {
13 static unsigned char colorProfile[] = {
14 0x00, 0x00, 0x01, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
15 0x6d, 0x6e, 0x74, 0x72, 0x52, 0x47, 0x42, 0x20, 0x58, 0x59, 0x5a, 0x20,
16 0x07, 0xdf, 0x00, 0x0c, 0x00, 0x1f, 0x00, 0x17, 0x00, 0x3b, 0x00, 0x3b,
17 0x61, 0x63, 0x73, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
18 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
19 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf6, 0xd6,
20 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xd3, 0x2d, 0x67, 0x6f, 0x6f, 0x67,
21 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
23 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08,
25 0x64, 0x65, 0x73, 0x63, 0x00, 0x00, 0x00, 0xe4, 0x00, 0x00, 0x00, 0x25,
26 0x77, 0x74, 0x70, 0x74, 0x00, 0x00, 0x01, 0x0c, 0x00, 0x00, 0x00, 0x14,
27 0x72, 0x58, 0x59, 0x5a, 0x00, 0x00, 0x01, 0x20, 0x00, 0x00, 0x00, 0x14,
28 0x67, 0x58, 0x59, 0x5a, 0x00, 0x00, 0x01, 0x34, 0x00, 0x00, 0x00, 0x14,
29 0x62, 0x58, 0x59, 0x5a, 0x00, 0x00, 0x01, 0x48, 0x00, 0x00, 0x00, 0x14,
30 0x72, 0x54, 0x52, 0x43, 0x00, 0x00, 0x01, 0x5c, 0x00, 0x00, 0x00, 0x20,
31 0x62, 0x54, 0x52, 0x43, 0x00, 0x00, 0x01, 0x5c, 0x00, 0x00, 0x00, 0x20,
32 0x67, 0x54, 0x52, 0x43, 0x00, 0x00, 0x01, 0x5c, 0x00, 0x00, 0x00, 0x20,
33 0x64, 0x65, 0x73, 0x63, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11,
34 0x42, 0x54, 0x2e, 0x37, 0x30, 0x39, 0x20, 0x48, 0x44, 0x54, 0x56, 0x20,
35 0x49, 0x54, 0x55, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
36 0x00, 0x00, 0x00, 0x00, 0x58, 0x59, 0x5a, 0x20, 0x00, 0x00, 0x00, 0x00,
37 0x00, 0x00, 0xf3, 0x51, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x16, 0xcc,
38 0x58, 0x59, 0x5a, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6f, 0xa2,
39 0x00, 0x00, 0x38, 0xf5, 0x00, 0x00, 0x03, 0x90, 0x58, 0x59, 0x5a, 0x20,
40 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x62, 0x99, 0x00, 0x00, 0xb7, 0x85,
41 0x00, 0x00, 0x18, 0xda, 0x58, 0x59, 0x5a, 0x20, 0x00, 0x00, 0x00, 0x00,
42 0x00, 0x00, 0x24, 0xa0, 0x00, 0x00, 0x0f, 0x84, 0x00, 0x00, 0xb6, 0xcf,
43 0x70, 0x61, 0x72, 0x61, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00,
44 0x00, 0x02, 0x38, 0xe4, 0x00, 0x00, 0xe8, 0xf0, 0x00, 0x00, 0x17, 0x10,
45 0x00, 0x00, 0x38, 0xe3, 0x00, 0x00, 0x14, 0xbc};
46
47 return reinterpret_cast<char*>(colorProfile);
48 }
49
sizebt709ColorProfile50 static size_t size() { return 380u; }
51 };
52
53 struct bt601ColorProfile {
databt601ColorProfile54 static char* data() // BT.601 SMPTE-C
55 {
56 static unsigned char colorProfile[] = {
57 0x00, 0x00, 0x01, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
58 0x6d, 0x6e, 0x74, 0x72, 0x52, 0x47, 0x42, 0x20, 0x58, 0x59, 0x5a, 0x20,
59 0x07, 0xdf, 0x00, 0x0c, 0x00, 0x1f, 0x00, 0x17, 0x00, 0x3b, 0x00, 0x3b,
60 0x61, 0x63, 0x73, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
61 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
62 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf6, 0xd6,
63 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xd3, 0x2d, 0x67, 0x6f, 0x6f, 0x67,
64 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
65 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
66 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
67 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08,
68 0x64, 0x65, 0x73, 0x63, 0x00, 0x00, 0x00, 0xe4, 0x00, 0x00, 0x00, 0x25,
69 0x77, 0x74, 0x70, 0x74, 0x00, 0x00, 0x01, 0x0c, 0x00, 0x00, 0x00, 0x14,
70 0x72, 0x58, 0x59, 0x5a, 0x00, 0x00, 0x01, 0x20, 0x00, 0x00, 0x00, 0x14,
71 0x67, 0x58, 0x59, 0x5a, 0x00, 0x00, 0x01, 0x34, 0x00, 0x00, 0x00, 0x14,
72 0x62, 0x58, 0x59, 0x5a, 0x00, 0x00, 0x01, 0x48, 0x00, 0x00, 0x00, 0x14,
73 0x72, 0x54, 0x52, 0x43, 0x00, 0x00, 0x01, 0x5c, 0x00, 0x00, 0x00, 0x20,
74 0x62, 0x54, 0x52, 0x43, 0x00, 0x00, 0x01, 0x5c, 0x00, 0x00, 0x00, 0x20,
75 0x67, 0x54, 0x52, 0x43, 0x00, 0x00, 0x01, 0x5c, 0x00, 0x00, 0x00, 0x20,
76 0x64, 0x65, 0x73, 0x63, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f,
77 0x42, 0x54, 0x2e, 0x36, 0x30, 0x31, 0x20, 0x53, 0x4d, 0x50, 0x54, 0x45,
78 0x2d, 0x43, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
79 0x00, 0x00, 0x00, 0x00, 0x58, 0x59, 0x5a, 0x20, 0x00, 0x00, 0x00, 0x00,
80 0x00, 0x00, 0xf3, 0x51, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x16, 0xcc,
81 0x58, 0x59, 0x5a, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6a, 0x95,
82 0x00, 0x00, 0x38, 0xc1, 0x00, 0x00, 0x03, 0x7f, 0x58, 0x59, 0x5a, 0x20,
83 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0xa5, 0x00, 0x00, 0xb4, 0x09,
84 0x00, 0x00, 0x17, 0x63, 0x58, 0x59, 0x5a, 0x20, 0x00, 0x00, 0x00, 0x00,
85 0x00, 0x00, 0x27, 0x9d, 0x00, 0x00, 0x13, 0x36, 0x00, 0x00, 0xb8, 0x5f,
86 0x70, 0x61, 0x72, 0x61, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00,
87 0x00, 0x02, 0x38, 0xe4, 0x00, 0x00, 0xe8, 0xf0, 0x00, 0x00, 0x17, 0x10,
88 0x00, 0x00, 0x38, 0xe3, 0x00, 0x00, 0x14, 0xbc};
89
90 return reinterpret_cast<char*>(colorProfile);
91 }
92
sizebt601ColorProfile93 static size_t size() { return 380u; }
94 };
95
96 namespace blink {
97
Bt709ColorProfileData(Vector<char> & data)98 void Bt709ColorProfileData(Vector<char>& data) {
99 DCHECK(WTF::IsMainThread());
100 DCHECK(data.IsEmpty());
101
102 data.Append(bt709ColorProfile::data(), bt709ColorProfile::size());
103 }
104
Bt601ColorProfileData(Vector<char> & data)105 void Bt601ColorProfileData(Vector<char>& data) {
106 DCHECK(WTF::IsMainThread());
107 DCHECK(data.IsEmpty());
108
109 data.Append(bt601ColorProfile::data(), bt601ColorProfile::size());
110 }
111
112 } // namespace blink
113