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-2014 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  WORD cx;
30  WORD cy;
31  BOOLEAN bInterlaced;
32  WORD wAspectX;
33  WORD wAspectY;
34  DWORD 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 };
104 
105 static const HDMI_VIC_FORMAT g_aHDMIExtVICFormats[] = {
106  /* 0 */ { 0, 0, FALSE, 0, 0, 0, },
107  /* 1 */ { 3840, 2160, FALSE, 16, 9, 333333, },
108  /* 2 */ { 3840, 2160, FALSE, 16, 9, 400000, },
109  /* 3 */ { 3840, 2160, FALSE, 16, 9, 416667, },
110  /* 4 */ { 4096, 2160, FALSE, 16, 9, 416667 },
111 };
112 
113 static const BYTE g_abyDefaultYUV709VICs[] = {
114  0, 1, 4, 5, 16, 19, 20, 31, 32, 33, 34, 39, 40, 46, 47, 60, 61, 62, 63, 64
115 };
116 
117 // byRGB_YCbCr
118 typedef enum _HDMI_PIXEL_ENCODING {
119  HDMI_ENCODING_RGB_444 = 0,
120  HDMI_ENCODING_YUV_422 = 1,
121  HDMI_ENCODING_YUV_444 = 2,
122  HDMI_ENCODING_YUV_420 = 3
123 } HDMI_PXIEL_ENCODING;
124 
130 typedef struct _HDMI_AVI_INFOFRAME_PAYLOAD {
131  BYTE byScanInfo : 2;
132  BYTE byBarDataPresent : 2;
133  BYTE byActiveFormatInfoPresent : 1;
134  BYTE byRGB_YCbCr : 2;
135  BYTE byFutureUseByte1 : 1;
136 
137  BYTE byActivePortionAspectRatio : 4;
138  BYTE byCodedFrameAspectRatio : 2;
139  BYTE byColorimetry : 2;
140 
141  BYTE byNonUniformPictureScaling : 2;
142  BYTE byRGBQuantizationRange : 2;
143  BYTE byExtendedColorimetry : 3;
144  BYTE byITContent : 1;
145 
146  BYTE byVIC : 7;
147  BYTE byFutureUseByte4 : 1;
148 
149  BYTE byPixelRepetitionFactor : 4;
150  BYTE byITContentType : 2;
151  BYTE byYCCQuantizationRange : 2;
152 
158 
160  BYTE byEOTF;
161  BYTE byMetadataDescriptorID;
162 
163  BYTE display_primaries_lsb_x0;
164  BYTE display_primaries_msb_x0;
165  BYTE display_primaries_lsb_y0;
166  BYTE display_primaries_msb_y0;
167 
168  BYTE display_primaries_lsb_x1;
169  BYTE display_primaries_msb_x1;
170  BYTE display_primaries_lsb_y1;
171  BYTE display_primaries_msb_y1;
172 
173  BYTE display_primaries_lsb_x2;
174  BYTE display_primaries_msb_x2;
175  BYTE display_primaries_lsb_y2;
176  BYTE display_primaries_msb_y2;
177 
178  BYTE white_point_lsb_x;
179  BYTE white_point_msb_x;
180  BYTE white_point_lsb_y;
181  BYTE white_point_msb_y;
182 
183  BYTE max_display_mastering_lsb_luminance;
184  BYTE max_display_mastering_msb_luminance;
185  BYTE min_display_mastering_lsb_luminance;
186  BYTE min_display_mastering_msb_luminance;
187 
188  BYTE maximum_content_light_level_lsb;
189  BYTE maximum_content_light_level_msb;
190 
191  BYTE maximum_frame_average_light_level_lsb;
192  BYTE maximum_frame_average_light_level_msb;
194 
195 
196 // Audio infoframe
197 #define HDMI_AUDIO_CODING_TYPE_STREAM 0x00
198 #define HDMI_AUDIO_CODING_TYPE_PCM 0x01
199 #define HDMI_AUDIO_CODING_TYPE_AC3 0x02
200 #define HDMI_AUDIO_CODING_TYPE_MPEG1 0x03
201 #define HDMI_AUDIO_CODING_TYPE_MP3 0x04
202 #define HDMI_AUDIO_CODING_TYPE_MPEG2 0x05
203 #define HDMI_AUDIO_CODING_TYPE_AAC_LC 0x06
204 #define HDMI_AUDIO_CODING_TYPE_DTS 0x07
205 #define HDMI_AUDIO_CODING_TYPE_ATRAC 0x08
206 #define HDMI_AUDIO_CODING_TYPE_DSD 0x09
207 #define HDMI_AUDIO_CODING_TYPE_EAC3 0x0A
208 #define HDMI_AUDIO_CODING_TYPE_DTS_HD 0x0B
209 
210 #define HDMI_AUDIO_SAMPLE_SIZE_STREAM 0x00
211 #define HDMI_AUDIO_SAMPLE_SIZE_16BIT 0x01
212 #define HDMI_AUDIO_SAMPLE_SIZE_20BIT 0x02
213 #define HDMI_AUDIO_SAMPLE_SIZE_24BIT 0x03
214 
215 #define HDMI_AUDIO_SAMPLE_RATE_STREAM 0x00
216 #define HDMI_AUDIO_SAMPLE_RATE_32000 0x01
217 #define HDMI_AUDIO_SAMPLE_RATE_44100 0x02
218 #define HDMI_AUDIO_SAMPLE_RATE_48000 0x03
219 #define HDMI_AUDIO_SAMPLE_RATE_88200 0x04
220 #define HDMI_AUDIO_SAMPLE_RATE_96000 0x05
221 #define HDMI_AUDIO_SAMPLE_RATE_176400 0x06
222 #define HDMI_AUDIO_SAMPLE_RATE_192000 0x07
223 
224 typedef struct _HDMI_AUDIO_INFOFRAME_PAYLOAD {
225  BYTE byChannelCount : 3; // +1 for channel count
226  BYTE byReserved1 : 1;
227  BYTE byAudioCodingType : 4;
228 
229  BYTE bySampleSize : 2;
230  BYTE bySampleFrequency : 3;
231  BYTE byReserved2 : 3;
232 
233  BYTE byAudioCodingExtensionType : 5;
234  BYTE byReserved3 : 3;
235 
236  BYTE byChannelAllocation;
237 
238  BYTE byLFEPlaybackLevel : 2;
239  BYTE byReserved4 : 1;
240  BYTE byLevelShiftValue : 4;
241  BYTE byDownMixInhibitFlag : 1;
243 
244 // SPD Infoframe
245 #define HDMI_SPD_SORUCE_UNKOWN 0x00
246 #define HDMI_SPD_SORUCE_DIGITAL_STB 0x01
247 #define HDMI_SPD_SORUCE_DVD_PLAYER 0x02
248 #define HDMI_SPD_SORUCE_D_VHS 0x03
249 #define HDMI_SPD_SORUCE_HDD_RECORDER 0x04
250 #define HDMI_SPD_SORUCE_DVC 0x05
251 #define HDMI_SPD_SORUCE_DSC 0x06
252 #define HDMI_SPD_SORUCE_VIDEO_CD 0x07
253 #define HDMI_SPD_SORUCE_GAME 0x08
254 #define HDMI_SPD_SORUCE_PC_GENERAL 0x09
255 #define HDMI_SPD_SORUCE_BLUE_RAY_DISC 0x0A
256 #define HDMI_SPD_SORUCE_SUPER_AUDIO_CD 0x0B
257 #define HDMI_SPD_SORUCE_HD_DVD 0x0C
258 #define HDMI_SPD_SORUCE_PMP 0x0D
259 
260 typedef struct _HDMI_SPD_INFOFRAME_PAYLOAD {
261  CHAR achVendorName[8];
262  CHAR achProductDescription[16];
263  BYTE bySourceInformation;
265 
266 // HDMI 1.4b VS Infoframe
267 #define HDMI14B_VS_REGISTRATION_ID 0x000C03
268 
269 #define HDMI14B_VS_FORMAT_NONE 0x00
270 #define HDMI14B_VS_FORMAT_EXT_RES 0x01
271 #define HDMI14B_VS_FORMAT_3D_FORMAT 0x02
272 
273 // by3DStructure
274 #define HDMI14B_3DS_FRAME_PACKING 0x00
275 #define HDMI14B_3DS_FIELD_ALTERNATIVE 0x01
276 #define HDMI14B_3DS_LINE_ALTERNATIVE 0x02
277 #define HDMI14B_3DS_SIDE_BY_SIDE_FULL 0x03
278 #define HDMI14B_3DS_TOP_AND_BOTTOM 0x06
279 #define HDMI14B_3DS_SIDE_BY_SIDE_HALF 0x08
280 
281 // by3DExtData
282 #define HDMI_SUB_SAMPLING_HORIZONTAL_00 0x00
283 #define HDMI_SUB_SAMPLING_HORIZONTAL_01 0x01
284 #define HDMI_SUB_SAMPLING_HORIZONTAL_10 0x02
285 #define HDMI_SUB_SAMPLING_HORIZONTAL_11 0x03
286 #define HDMI_SUB_SAMPLING_QUINCUNX_ODD_ODD 0x04
287 #define HDMI_SUB_SAMPLING_QUINCUNX_ODD_EVEN 0x05
288 #define HDMI_SUB_SAMPLING_QUINCUNX_EVEN_ODD 0x06
289 #define HDMI_SUB_SAMPLING_QUINCUNX_EVEN_EVEN 0x07
290 
291 typedef struct _HDMI14B_VS_DATA_EXT_RES {
292  BYTE byHDMI_VIC;
294 
295 typedef struct _HDMI14B_VS_DATA_3D_FORMAT {
296  BYTE byReserved1 : 3;
297  BYTE by3DMetaPresent : 1;
298  BYTE by3DStructure : 4;
299 
300  BYTE byReserved2 : 4;
301  BYTE by3DExtData : 4;
302 
303  BYTE by3DMetadataLength : 5;
304  BYTE by3DMetadataType : 3;
306 
307 typedef struct _HDMI14B_VS_DATA {
308  BYTE byReserved1 : 5;
309  BYTE byHDMIVideoFormat : 3;
310 
311  union {
312  HDMI14B_VS_DATA_EXT_RES vsDataExtRes;
313  HDMI14B_VS_DATA_3D_FORMAT vsData3DFormat;
314  };
316 
317 // Generic VS Infoframe
318 typedef struct _HDMI_VS_INFOFRAME_PAYLOAD {
319  BYTE abyRegistrationId[3];
320 
321  union {
322  BYTE abyVSData[24];
323  HDMI14B_VS_DATA vsDataHDMI14B;
324  };
326 
327 static inline DWORD hdmi_payload_GetRegistrationId(HDMI_VS_INFOFRAME_PAYLOAD *payload)
328 {
329  return payload->abyRegistrationId[0] | (payload->abyRegistrationId[1] << 8)
330  | (payload->abyRegistrationId[2] << 16);
331 }
332 
333 // Generic Infoframe
334 #define HDMI_INFOFRAME_TYPE_VS 0x81
335 #define HDMI_INFOFRAME_TYPE_AVI 0x82
336 #define HDMI_INFOFRAME_TYPE_SPD 0x83
337 #define HDMI_INFOFRAME_TYPE_AUDIO 0x84
338 #define HDMI_INFOFRAME_TYPE_MS 0x85
339 #define HDMI_INFOFRAME_TYPE_VBI 0x86
340 #define HDMI_INFOFRAME_TYPE_HDR 0x87
341 
348 typedef struct _HDMI_INFOFRAME_HEADER {
350  BYTE byVersion;
351  BYTE byLength : 5;
352  BYTE byReservedZero : 3;
354 
361 typedef struct _HDMI_INFOFRAME_PACKET {
362  HDMI_INFOFRAME_HEADER header;
363  BYTE byChecksum;
364 
365  union {
366  BYTE abyPayload[27];
367  HDMI_AVI_INFOFRAME_PAYLOAD aviInfoFramePayload;
368  HDMI_AUDIO_INFOFRAME_PAYLOAD audioInfoFramePayload;
369  HDMI_SPD_INFOFRAME_PAYLOAD spdInfoFramePayload;
370  HDMI_VS_INFOFRAME_PAYLOAD vsInfoFramePayload;
372  };
374 
375 static inline BOOLEAN hdmi_info_IsValid(HDMI_INFOFRAME_PACKET *info)
376 {
377  unsigned char *pbyData = (unsigned char *)&info->header;
378  BYTE cbData = info->header.byLength + sizeof(info->header) + 1;
379 
380  BYTE bySum = 0;
381  while (cbData-- != 0)
382  bySum += *pbyData++;
383 
384  return (bySum == 0);
385 }
386 
387 #pragma pack(pop)
388 
Definition: MWHDMIPackets.h:210
Definition: MWHDMIPackets.h:246
Definition: MWHDMIPackets.h:304
HDMI_INFOFRAME_PACKET.
Definition: MWHDMIPackets.h:333
Definition: MWHDMIPackets.h:277
Definition: MWHDMIPackets.h:281
Definition: MWHDMIPackets.h:159
struct _HDMI_INFOFRAME_PACKET HDMI_INFOFRAME_PACKET
HDMI_INFOFRAME_PACKET.
WORD wEndOfLeftBar
Unsigned integer, representing the last pixel of the vertical letterbox bar on the left...
Definition: MWHDMIPackets.h:155
HDMI_INFOFRAME_HEADER.
Definition: MWHDMIPackets.h:326
BYTE byChecksum
checksum
Definition: MWHDMIPackets.h:363
struct _HDMI_INFOFRAME_HEADER HDMI_INFOFRAME_HEADER
HDMI_INFOFRAME_HEADER.
Definition: MWHDMIPackets.h:293
BYTE byPacketType
HDMI infoframe type.
Definition: MWHDMIPackets.h:349
HDMI_HDR_INFOFRAME_PAYLOAD hdrInfoFramePayload
hdr infoframe payload
Definition: MWHDMIPackets.h:371
HDMI_INFOFRAME_HEADER header
HDMI infoframe header.
Definition: MWHDMIPackets.h:334
WORD wStartOfBottomBar
Unsigned integers represent the first line of the letterbox bar at the bottom of the horizontal scree...
Definition: MWHDMIPackets.h:154
Definition: MWHDMIPackets.h:28
BYTE byVersion
HDMI version.
Definition: MWHDMIPackets.h:350
WORD wStartOfRightBar
Unsigned integer, representing the first pixel of the vertical letterbox bar on the right...
Definition: MWHDMIPackets.h:156
WORD wEndOfTopBar
Unsigned integers represent the last line of the letterbox bar area at the top of the screen...
Definition: MWHDMIPackets.h:153
HDMI_AVI_INFOFRAME_PAYLOAD.
Definition: MWHDMIPackets.h:153
struct _HDMI_AVI_INFOFRAME_PAYLOAD HDMI_AVI_INFOFRAME_PAYLOAD
HDMI_AVI_INFOFRAME_PAYLOAD.