MWCapture SDK Mac 3.4.62314

- Home
- Development Library
- Release Notes

MWIEC60958.h
1
2// 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 typedef union _IEC60958_CHANNEL_STATUS {
14 BYTE abyData[24];
15 WORD awData[12];
16 DWORD adwData[6];
17
18 struct {
19 BYTE byProfessional : 1;
20 BYTE byNotLPCM : 1;
21 BYTE byEncodedAudioSignalEmphasis : 3; // 000: Emphasis not indicated, 001: No emphasis, 011: 50/15 us emphasis, 111: CCITT J.17 emphasis
22 BYTE bySourceSamplingFreqUnlocked : 1;
23 BYTE byEncodedSamplingFreq : 2; // 00: Not indicated, 10: 48, 01: 44.1, 11: 32
24
25 BYTE byEncodedChannelMode : 4;
26 BYTE byEncodedUserBitsManagement : 4;
27
28 BYTE byZero : 1;
29 BYTE bySingleCoordinationSignal : 1;
30 BYTE byWordLength : 4; // 0010: 16, 1100: 17, 0100: 18, 1000: 19, 1010: 20, 0011: 20, 1101: 21, 0101: 22, 1001: 23, 1011: 24
31 BYTE byAlignmentLevel : 2; // 00: Not indicated, 10: 20 dB, 01: 18.06 dB, 11: Reserved
32
33 BYTE byChannelNumberOrMultiChannelMode : 7;
34 BYTE byDefinedMultiChannelMode : 1;
35
36 BYTE byReferenceSignal : 2; // 00: Not a reference signal, 10: Grade 1, 01: Grade 2, 11: Reserved
37 BYTE byReserved1 : 1;
38 BYTE bySamplingFreq : 4; // 0000: Not indicated, 0001: 24, 0010: 96, 0011: 192, 1001: 22.05, 1010: 88.2, 1011: 176.4, 1111: User defined
39 BYTE bySamplingFreqScaling : 1;
40
41 BYTE byReserved2;
42
43 BYTE achChannelOrigin[4];
44 BYTE achChannelDestination[4];
45 DWORD dwLocalSampleAddress;
46 DWORD dwTimeOfDaySampleAddress;
47 BYTE byReliabilityFlags;
48
49 BYTE byCRC;
50 } Professional;
51
52 struct {
53 BYTE byProfessional : 1;
54 BYTE byNotLPCM : 1;
55 BYTE byNoCopyright : 1;
56 BYTE byAdditionalFormatInfo : 3;
57 BYTE byMode : 2;
58
59 BYTE byCategoryCode;
60
61 BYTE bySourceNumber : 4;
62 BYTE byChannelNumber : 4;
63
64 BYTE bySamplingFreq : 4; // 0100: 22.05, 0000: 44.1, 1000: 88.2, 1100: 176.4, 0110: 24, 0010: 48, 1010: 96, 1110: 192, 0011: 32, 0001: Not indicated, 1001: 768
65 BYTE byClockAccuracy : 2; // 00: Level II, 10: Level I, 01: Level III, 11: Not matched
66 BYTE byReserved1 : 2;
67
68 BYTE byWordLength : 4; // 0010: 16, 1100: 17, 0100: 18, 1000: 19, 1010: 20, 0011: 20, 1101: 21, 0101: 22, 1001: 23, 1011: 24
69 BYTE byOrigSamplingFreq : 4; // 1111: 44.1, 0111: 88.2, 1011: 22.05, 0011: 176.4, 1101: 48, 0101: 96, 1001: 24, 0001: 192, 0110: 8, 1010: 11.025, 0010: 12, 1100: 32, 1000: 16, 0000: Not indicated
70
71 BYTE byCGMS_A; // 00: Copying permitted, 10: Condition not be used, 01: One generation only, 11: No copying is permitted
72 } Consumer;
73} IEC60958_CHANNEL_STATUS;
74
75 static inline int IEC60958_GetBitsPerSample(BYTE byWordLength)
76{
77 switch (byWordLength) {
78 case 2: return 16;
79 case 3: return 20;
80 case 4: return 18;
81 case 5: return 22;
82 case 8: return 19;
83 case 9: return 23;
84 case 10: return 20;
85 case 11: return 24;
86 case 12: return 17;
87 case 13: return 21;
88 default: return 16;
89 }
90}
91
92 static inline DWORD IEC60958P_GetSampleRate(IEC60958_CHANNEL_STATUS * pStatus)
93{
94 switch (pStatus->Professional.byEncodedSamplingFreq) {
95 case 0:
96 switch (pStatus->Professional.bySamplingFreq) {
97 case 1: return 24000;
98 case 2: return 96000;
99 case 3: return 192000;
100 case 5: return 22050;
101 case 6: return 88200;
102 case 7: return 176400;
103 }
104 break;
105
106 case 1:
107 return 44100;
108
109 case 2:
110 return 48000;
111
112 case 3:
113 return 32000;
114 }
115
116 return 48000;
117}
118
119 static inline DWORD IEC60958C_GetSampleRate(IEC60958_CHANNEL_STATUS * pStatus)
120{
121 switch (pStatus->Consumer.bySamplingFreq) {
122 case 0: return 44100;
123 case 2: return 48000;
124 case 3: return 32000;
125 case 4: return 22050;
126 case 6: return 24000;
127 case 8: return 88200;
128 case 9: return 768000;
129 case 10: return 96000;
130 case 12: return 176400;
131 case 14: return 192000;
132 }
133
134 return 44100;
135}
136
137 static inline BOOLEAN IEC60958_ParseChannelStatus(IEC60958_CHANNEL_STATUS * pStatus, BOOLEAN * pbLPCM, DWORD * pdwSampleRate, int * pnBitsPerSample)
138{
139 BOOLEAN bLPCM;
140 DWORD dwSampleRate = 48000;
141 int nBitsPerSample = 16;
142
143 if (pStatus->Professional.byProfessional) {
144 bLPCM = !pStatus->Professional.byNotLPCM;
145 dwSampleRate = IEC60958P_GetSampleRate(pStatus);
146 nBitsPerSample = IEC60958_GetBitsPerSample(pStatus->Professional.byWordLength);
147 }
148 else {
149 bLPCM = !pStatus->Consumer.byNotLPCM;
150 dwSampleRate = IEC60958C_GetSampleRate(pStatus);
151 nBitsPerSample = IEC60958_GetBitsPerSample(pStatus->Consumer.byWordLength);
152 }
153
154 if (pbLPCM) *pbLPCM = bLPCM;
155 if (pdwSampleRate) *pdwSampleRate = dwSampleRate;
156 if (pnBitsPerSample) *pnBitsPerSample = nBitsPerSample;
157
158 return TRUE;
159}
160
161#pragma pack(pop)
_IEC60958_CHANNEL_STATUS
Definition: MWIEC60958.h:13