MWCapture SDK Linux  3.3.1.LAST_SVN_COMMIT_NUM
MWHDMIPackets.h
1 // CONFIDENTIAL and PROPRIETARY software of Magewell Electronics Co., Ltd.
3 // Copyright (c) 2011-2016 Magewell Electronics Co., Ltd. (Nanjing)
4 // All rights reserved.
5 // This copyright notice MUST be reproduced on all authorized copies.
7 
8 #pragma once
9 
10 #pragma pack(push)
11 #pragma pack(1)
12 
13 // AVI infoframe
14 #define HDMI_EC_XVYCC601 0x00
15 #define HDMI_EC_XVYCC709 0x01
16 #define HDMI_EC_SYCC601 0x02
17 #define HDMI_EC_ADOBEYCC601 0x03
18 #define HDMI_EC_ADOBERGB 0x04
19 
20 #define HDMI_YQ_LIMITED_RANGE 0x00
21 #define HDMI_YQ_FULL_RANGE 0x01
22 
23 #define HDMI_CN_NONE_OR_GRAPHICS 0x00
24 #define HDMI_CN_PHOTO 0x01
25 #define HDMI_CN_CINEMA 0x02
26 #define HDMI_CN_GAME 0x03
27 
28 typedef struct _HDMI_VIC_FORMAT {
29  uint16_t cx;
30  uint16_t cy;
31  bool bInterlaced;
32  uint16_t wAspectX;
33  uint16_t wAspectY;
34  uint32_t dwFrameDuration;
36 
37 static const HDMI_VIC_FORMAT g_aHDMIVICFormats[] = {
38  { /* 0 */ 0, 0, false, 0, 0, 0 },
39  { /* 1 */ 640, 480, false, 4, 3, 166667 },
40  { /* 2 */ 720, 480, false, 4, 3, 166667 },
41  { /* 3 */ 720, 480, false, 16, 9, 166667 },
42  { /* 4 */ 1280, 720, false, 16, 9, 166667 },
43  { /* 5 */ 1920, 1080, true, 16, 9, 333333 },
44  { /* 6 */ 720, 480, true, 4, 3, 333333 },
45  { /* 7 */ 720, 480, true, 16, 9, 333333 },
46  { /* 8 */ 720, 240, false, 4, 3, 166667 },
47  { /* 9 */ 720, 240, false, 16, 9, 166667 },
48  { /* 10 */ 2880, 480, true, 4, 3, 333333 },
49  { /* 11 */ 2880, 480, true, 16, 9, 333333 },
50  { /* 12 */ 2880, 240, false, 4, 3, 166667 },
51  { /* 13 */ 2880, 240, false, 16, 9, 166667 },
52  { /* 14 */ 1440, 480, false, 4, 3, 166667 },
53  { /* 15 */ 1440, 480, false, 16, 9, 166667 },
54  { /* 16 */ 1920, 1080, false, 16, 9, 166667 },
55  { /* 17 */ 720, 576, false, 4, 3, 200000 },
56  { /* 18 */ 720, 576, false, 16, 9, 200000 },
57  { /* 19 */ 1280, 720, false, 16, 9, 200000 },
58  { /* 20 */ 1920, 1080, true, 16, 9, 400000 },
59  { /* 21 */ 720, 576, true, 4, 3, 400000 },
60  { /* 22 */ 720, 576, true, 16, 9, 400000 },
61  { /* 23 */ 720, 288, false, 4, 3, 200000 },
62  { /* 24 */ 720, 288, false, 16, 9, 200000 },
63  { /* 25 */ 2880, 576, true, 4, 3, 400000 },
64  { /* 26 */ 2880, 576, true, 4, 3, 400000 },
65  { /* 27 */ 2880, 288, false, 4, 3, 200000 },
66  { /* 28 */ 2880, 288, false, 16, 9, 200000 },
67  { /* 29 */ 1440, 576, false, 4, 3, 200000 },
68  { /* 30 */ 1440, 576, false, 16, 9, 200000 },
69  { /* 31 */ 1920, 1080, false, 16, 9, 200000 },
70  { /* 32 */ 1920, 1080, false, 16, 9, 416667 },
71  { /* 33 */ 1920, 1080, false, 16, 9, 400000 },
72  { /* 34 */ 1920, 1080, false, 16, 9, 333333 },
73  { /* 35 */ 2880, 480, false, 4, 3, 166667 },
74  { /* 36 */ 2880, 480, false, 16, 9, 166667 },
75  { /* 37 */ 2880, 576, false, 4, 3, 200000 },
76  { /* 38 */ 2880, 576, false, 16, 9, 200000 },
77  { /* 39 */ 1920, 1080, true, 16, 9, 400000 },
78  { /* 40 */ 1920, 1080, true, 16, 9, 200000 },
79  { /* 41 */ 1280, 720, false, 16, 9, 100000 },
80  { /* 42 */ 720, 576, false, 4, 3, 100000 },
81  { /* 43 */ 720, 576, false, 16, 9, 100000 },
82  { /* 44 */ 720, 576, true, 4, 3, 200000 },
83  { /* 45 */ 720, 576, true, 16, 9, 200000 },
84  { /* 46 */ 1920, 1080, true, 16, 9, 166667 },
85  { /* 47 */ 1280, 720, false, 16, 9, 83333 },
86  { /* 48 */ 720, 480, false, 4, 3, 83333 },
87  { /* 49 */ 720, 480, false, 16, 9, 83333 },
88  { /* 50 */ 720, 480, true, 4, 3, 166667 },
89  { /* 51 */ 720, 480, true, 16, 9, 166667 },
90  { /* 52 */ 720, 576, false, 4, 3, 50000 },
91  { /* 53 */ 720, 576, false, 16, 9, 50000 },
92  { /* 54 */ 720, 576, true, 4, 3, 100000 },
93  { /* 55 */ 720, 576, true, 16, 9, 100000 },
94  { /* 56 */ 720, 480, false, 4, 3, 41667 },
95  { /* 57 */ 720, 480, false, 16, 9, 41667 },
96  { /* 58 */ 720, 480, true, 4, 3, 83333 },
97  { /* 59 */ 720, 480, true, 16, 9, 83333 },
98  { /* 60 */ 1280, 720, false, 16, 9, 416667 },
99  { /* 61 */ 1280, 720, false, 16, 9, 400000 },
100  { /* 62 */ 1280, 720, false, 16, 9, 333333 },
101  { /* 63 */ 1920, 1080, false, 16, 9, 83333 },
102  { /* 64 */ 1920, 1080, false, 16, 9, 100000 },
103  { /* 65 */ 1280, 720, false, 64, 27, 416667 },
104  { /* 66 */ 1280, 720, false, 64, 27, 400000 },
105  { /* 67 */ 1280, 720, false, 64, 27, 333333 },
106  { /* 68 */ 1280, 720, false, 64, 27, 200000 },
107  { /* 69 */ 1280, 720, false, 64, 27, 166667 },
108  { /* 70 */ 1280, 720, false, 64, 27, 100000 },
109  { /* 71 */ 1280, 720, false, 64, 27, 83333 },
110  { /* 72 */ 1920, 1080, false, 64, 27, 416667 },
111  { /* 73 */ 1920, 1080, false, 64, 27, 400000 },
112  { /* 74 */ 1920, 1080, false, 64, 27, 333333 },
113  { /* 75 */ 1920, 1080, false, 64, 27, 200000 },
114  { /* 76 */ 1920, 1080, false, 64, 27, 166667 },
115  { /* 77 */ 1920, 1080, false, 64, 27, 100000 },
116  { /* 78 */ 1920, 1080, false, 64, 27, 83333 },
117  { /* 79 */ 1780, 720, false, 64, 27, 416667 },
118  { /* 80 */ 1780, 720, false, 64, 27, 400000 },
119  { /* 81 */ 1780, 720, false, 64, 27, 333333 },
120  { /* 82 */ 1780, 720, false, 64, 27, 200000 },
121  { /* 83 */ 1780, 720, false, 64, 27, 166667 },
122  { /* 84 */ 1780, 720, false, 64, 27, 100000 },
123  { /* 85 */ 1780, 720, false, 64, 27, 83333 },
124  { /* 86 */ 2560, 1080, false, 64, 27, 416667 },
125  { /* 87 */ 2560, 1080, false, 64, 27, 400000 },
126  { /* 88 */ 2560, 1080, false, 64, 27, 333333 },
127  { /* 89 */ 2560, 1080, false, 64, 27, 200000 },
128  { /* 90 */ 2560, 1080, false, 64, 27, 166667 },
129  { /* 91 */ 2560, 1080, false, 64, 27, 100000 },
130  { /* 92 */ 2560, 1080, false, 64, 27, 83333 },
131  { /* 93 */ 3840, 2160, false, 16, 9, 416667 },
132  { /* 94 */ 3840, 2160, false, 16, 9, 400000 },
133  { /* 95 */ 3840, 2160, false, 16, 9, 333333 },
134  { /* 96 */ 3840, 2160, false, 16, 9, 200000 },
135  { /* 97 */ 3840, 2160, false, 16, 9, 166667 },
136  { /* 98 */ 4096, 2160, false, 256, 135, 416667 },
137  { /* 99 */ 4096, 2160, false, 256, 135, 400000 },
138  { /* 100 */ 4096, 2160, false, 256, 135, 333333 },
139  { /* 101 */ 4096, 2160, false, 256, 135, 200000 },
140  { /* 102 */ 4096, 2160, false, 256, 135, 166667 },
141  { /* 103 */ 3840, 2160, false, 64, 27, 416667 },
142  { /* 104 */ 3840, 2160, false, 64, 27, 400000 },
143  { /* 105 */ 3840, 2160, false, 64, 27, 333333 },
144  { /* 106 */ 3840, 2160, false, 64, 27, 200000 },
145  { /* 107 */ 3840, 2160, false, 64, 27, 166667 }
146 };
147 
148 static const uint8_t g_abyDefaultYUV709VICs[] = {
149  0, 1, 4, 5, 16, 19, 20, 31, 32, 33, 34, 39, 40, 46, 47, 60, 61, 62, 63, 64
150 };
151 
152 // byRGB_YCbCr
154  uint8_t byScanInfo : 2;
155  uint8_t byBarDataPresent : 2;
156  uint8_t byActiveFormatInfoPresent : 1;
157  uint8_t byRGB_YCbCr : 2;
158  uint8_t byFutureUseByte1 : 1;
159 
160  uint8_t byActivePortionAspectRatio : 4;
161  uint8_t byCodedFrameAspectRatio : 2;
162  uint8_t byColorimetry : 2;
163 
164  uint8_t byNonUniformPictureScaling : 2;
165  uint8_t byRGBQuantizationRange : 2;
166  uint8_t byExtendedColorimetry : 3;
167  uint8_t byITContent : 1;
168 
169  uint8_t byVIC : 7;
170  uint8_t byFutureUseByte4 : 1;
171 
172  uint8_t byPixelRepetitionFactor : 4;
173  uint8_t byITContentType : 2;
174  uint8_t byYCCQuantizationRange : 2;
175 
176  uint16_t wEndOfTopBar;
177  uint16_t wStartOfBottomBar;
178  uint16_t wEndOfLeftBar;
179  uint16_t wStartOfRightBar;
181 
182 // Audio infoframe
183 #define HDMI_AUDIO_CODING_TYPE_STREAM 0x00
184 #define HDMI_AUDIO_CODING_TYPE_PCM 0x01
185 #define HDMI_AUDIO_CODING_TYPE_AC3 0x02
186 #define HDMI_AUDIO_CODING_TYPE_MPEG1 0x03
187 #define HDMI_AUDIO_CODING_TYPE_MP3 0x04
188 #define HDMI_AUDIO_CODING_TYPE_MPEG2 0x05
189 #define HDMI_AUDIO_CODING_TYPE_AAC_LC 0x06
190 #define HDMI_AUDIO_CODING_TYPE_DTS 0x07
191 #define HDMI_AUDIO_CODING_TYPE_ATRAC 0x08
192 #define HDMI_AUDIO_CODING_TYPE_DSD 0x09
193 #define HDMI_AUDIO_CODING_TYPE_EAC3 0x0A
194 #define HDMI_AUDIO_CODING_TYPE_DTS_HD 0x0B
195 
196 #define HDMI_AUDIO_SAMPLE_SIZE_STREAM 0x00
197 #define HDMI_AUDIO_SAMPLE_SIZE_16BIT 0x01
198 #define HDMI_AUDIO_SAMPLE_SIZE_20BIT 0x02
199 #define HDMI_AUDIO_SAMPLE_SIZE_24BIT 0x03
200 
201 #define HDMI_AUDIO_SAMPLE_RATE_STREAM 0x00
202 #define HDMI_AUDIO_SAMPLE_RATE_32000 0x01
203 #define HDMI_AUDIO_SAMPLE_RATE_44100 0x02
204 #define HDMI_AUDIO_SAMPLE_RATE_48000 0x03
205 #define HDMI_AUDIO_SAMPLE_RATE_88200 0x04
206 #define HDMI_AUDIO_SAMPLE_RATE_96000 0x05
207 #define HDMI_AUDIO_SAMPLE_RATE_176400 0x06
208 #define HDMI_AUDIO_SAMPLE_RATE_192000 0x07
209 
211  uint8_t byChannelCount : 3; // +1 for channel count
212  uint8_t byReserved1 : 1;
213  uint8_t byAudioCodingType : 4;
214 
215  uint8_t bySampleSize : 2;
216  uint8_t bySampleFrequency : 3;
217  uint8_t byReserved2 : 3;
218 
219  uint8_t byAudioCodingExtensionType : 5;
220  uint8_t byReserved3 : 3;
221 
222  uint8_t byChannelAllocation;
223 
224  uint8_t byLFEPlaybackLevel : 2;
225  uint8_t byReserved4 : 1;
226  uint8_t byLevelShiftValue : 4;
227  uint8_t byDownMixInhibitFlag : 1;
229 
230 // SPD Infoframe
231 #define HDMI_SPD_SORUCE_UNKOWN 0x00
232 #define HDMI_SPD_SORUCE_DIGITAL_STB 0x01
233 #define HDMI_SPD_SORUCE_DVD_PLAYER 0x02
234 #define HDMI_SPD_SORUCE_D_VHS 0x03
235 #define HDMI_SPD_SORUCE_HDD_RECORDER 0x04
236 #define HDMI_SPD_SORUCE_DVC 0x05
237 #define HDMI_SPD_SORUCE_DSC 0x06
238 #define HDMI_SPD_SORUCE_VIDEO_CD 0x07
239 #define HDMI_SPD_SORUCE_GAME 0x08
240 #define HDMI_SPD_SORUCE_PC_GENERAL 0x09
241 #define HDMI_SPD_SORUCE_BLUE_RAY_DISC 0x0A
242 #define HDMI_SPD_SORUCE_SUPER_AUDIO_CD 0x0B
243 #define HDMI_SPD_SORUCE_HD_DVD 0x0C
244 #define HDMI_SPD_SORUCE_PMP 0x0D
245 
247  char achVendorName[8];
248  char achProductDescription[16];
249  uint8_t bySourceInformation;
251 
252 // HDMI 1.4b VS Infoframe
253 #define HDMI14B_VS_REGISTRATION_ID 0x000C03
254 
255 #define HDMI14B_VS_FORMAT_NONE 0x00
256 #define HDMI14B_VS_FORMAT_EXT_RES 0x01
257 #define HDMI14B_VS_FORMAT_3D_FORMAT 0x02
258 
259 // by3DStructure
260 #define HDMI14B_3DS_FRAME_PACKING 0x00
261 #define HDMI14B_3DS_FIELD_ALTERNATIVE 0x01
262 #define HDMI14B_3DS_LINE_ALTERNATIVE 0x02
263 #define HDMI14B_3DS_SIDE_BY_SIDE_FULL 0x03
264 #define HDMI14B_3DS_TOP_AND_BOTTOM 0x06
265 #define HDMI14B_3DS_SIDE_BY_SIDE_HALF 0x08
266 
267 // by3DExtData
268 #define HDMI_SUB_SAMPLING_HORIZONTAL_00 0x00
269 #define HDMI_SUB_SAMPLING_HORIZONTAL_01 0x01
270 #define HDMI_SUB_SAMPLING_HORIZONTAL_10 0x02
271 #define HDMI_SUB_SAMPLING_HORIZONTAL_11 0x03
272 #define HDMI_SUB_SAMPLING_QUINCUNX_ODD_ODD 0x04
273 #define HDMI_SUB_SAMPLING_QUINCUNX_ODD_EVEN 0x05
274 #define HDMI_SUB_SAMPLING_QUINCUNX_EVEN_ODD 0x06
275 #define HDMI_SUB_SAMPLING_QUINCUNX_EVEN_EVEN 0x07
276 
277 typedef struct _HDMI14B_VS_DATA_EXT_RES {
278  uint8_t byHDMI_VIC;
280 
282  uint8_t byReserved1 : 3;
283  uint8_t by3DMetaPresent : 1;
284  uint8_t by3DStructure : 4;
285 
286  uint8_t byReserved2 : 4;
287  uint8_t by3DExtData : 4;
288 
289  uint8_t by3DMetadataLength : 5;
290  uint8_t by3DMetadataType : 3;
292 
293 typedef struct _HDMI14B_VS_DATA {
294  uint8_t byReserved1 : 5;
295  uint8_t byHDMIVideoFormat : 3;
296 
297  union {
298  HDMI14B_VS_DATA_EXT_RES vsDataExtRes;
299  HDMI14B_VS_DATA_3D_FORMAT vsData3DFormat;
300  };
302 
303 // Generic VS Infoframe
305  uint8_t abyRegistrationId[3];
306 
307  union {
308  uint8_t abyVSData[24];
309  HDMI14B_VS_DATA vsDataHDMI14B;
310  };
311 
312 public:
313  uint32_t GetRegistrationId() {
314  return abyRegistrationId[0] | (abyRegistrationId[1] << 8) | (abyRegistrationId[2] << 16);
315  }
316 
318 
319 // Generic Infoframe
320 #define HDMI_INFOFRAME_TYPE_VS 0x81
321 #define HDMI_INFOFRAME_TYPE_AVI 0x82
322 #define HDMI_INFOFRAME_TYPE_SPD 0x83
323 #define HDMI_INFOFRAME_TYPE_AUDIO 0x84
324 #define HDMI_INFOFRAME_TYPE_MS 0x85
325 
326 typedef struct _HDMI_INFOFRAME_HEADER {
327  uint8_t byPacketType;
328  uint8_t byVersion;
329  uint8_t byLength : 5;
330  uint8_t byReservedZero : 3;
332 
333 typedef struct _HDMI_INFOFRAME_PACKET {
335  uint8_t byChecksum;
336 
337  union {
338  uint8_t abyPayload[27];
343  };
344 
345 public:
346  bool IsValid(
347  ) const {
348  uint8_t * pbyData = (uint8_t *)&header;
349  uint8_t cbData = header.byLength + sizeof(header) + 1;
350 
351  uint8_t bySum = 0;
352  while (cbData-- != 0)
353  bySum += *pbyData++;
354 
355  return (bySum == 0);
356  }
358 
359 #pragma pack(pop)
Definition: MWHDMIPackets.h:210
Definition: MWHDMIPackets.h:246
Definition: MWHDMIPackets.h:304
HDMI_INFOFRAME_PACKET.
Definition: MWHDMIPackets.h:333
HDMI_AUDIO_INFOFRAME_PAYLOAD audioInfoFramePayload
audio infoframe payload
Definition: MWHDMIPackets.h:340
HDMI_AVI_INFOFRAME_PAYLOAD aviInfoFramePayload
avi infoframe payload
Definition: MWHDMIPackets.h:339
Definition: MWHDMIPackets.h:277
Definition: MWHDMIPackets.h:281
struct _HDMI_INFOFRAME_PACKET HDMI_INFOFRAME_PACKET
HDMI_INFOFRAME_PACKET.
HDMI_INFOFRAME_HEADER.
Definition: MWHDMIPackets.h:326
struct _HDMI_INFOFRAME_HEADER HDMI_INFOFRAME_HEADER
HDMI_INFOFRAME_HEADER.
HDMI_SPD_INFOFRAME_PAYLOAD spdInfoFramePayload
spd infoframe payload
Definition: MWHDMIPackets.h:341
Definition: MWHDMIPackets.h:293
HDMI_VS_INFOFRAME_PAYLOAD vsInfoFramePayload
vs infoframe payload
Definition: MWHDMIPackets.h:342
HDMI_INFOFRAME_HEADER header
HDMI infoframe header.
Definition: MWHDMIPackets.h:334
Definition: MWHDMIPackets.h:28
HDMI_AVI_INFOFRAME_PAYLOAD.
Definition: MWHDMIPackets.h:153
struct _HDMI_AVI_INFOFRAME_PAYLOAD HDMI_AVI_INFOFRAME_PAYLOAD
HDMI_AVI_INFOFRAME_PAYLOAD.