-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathmediaformat.h
318 lines (289 loc) · 9.53 KB
/
mediaformat.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
#ifndef TAG_PARSER_MEDIAFORMAT_H
#define TAG_PARSER_MEDIAFORMAT_H
#include "./global.h"
#include <string_view>
#include <utility>
namespace TagParser {
/*!
* \brief The MediaType enum specifies the type of media data (audio, video, text, ...).
*/
enum class MediaType : unsigned int {
Unknown, /**< the type is unknown */
Audio, /**< audio/sound */
Video, /**< video */
Text, /**< text/subtitle */
Buttons, /**< buttons */
Control, /**< control */
Hint, /**< hint */
Meta, /**< (timed) metadata */
};
TAG_PARSER_EXPORT std::string_view mediaTypeName(MediaType mediaType);
/*!
* \brief The GeneralMediaFormat enum specifies the general format of media data (PCM, MPEG-4, PNG, ...).
*/
enum class GeneralMediaFormat : unsigned int {
Unknown, /**< the format is unknown */
Aac, /**< Advanced Video Coding */
Ac3, /**< Dolby Digital */
Ac4, /**< AC-4 */
AdpcmAcm, /**< ADPCM ACM */
AfxStream, /**< AFX Stream */
Alac, /**< Apple Lossless Audio Codec */
Als, /**< ALS */
Amr, /**< AMR */
Avc, /**< Advanced Video Coding */
Av1, /**< AOMedia Video 1 (AV1) */
Bitmap, /**< Windows Bitmap */
Daala, /**< Daala ("next-generation video codec" by Xiph) */
Dirac, /**< Dirac */
DolbyMlp, /**< Dolby MLP */
Dts, /**< DTS */
DtsHd, /**< DTS-HD */
DvbSub, /**< DVBSUB */
EAc3, /**< Dolby Digital Plus */
Evrc, /**< EVRC */
Flac, /**< FLAC */
FontDataStream, /**< Font Data Stream */
Gif, /**< GIF */
Gpp2Cmf, /**< 3GPP2 Compact Multimedia Format (CMF) */
Hevc, /**< H.265/High Efficiency Video Coding */
ImaadpcmAcm, /**< IMAADPCM ACM */
ImageSubtitle, /**< Image subtitle */
InteractionStream, /**< Interaction Stream */
Jpeg, /**< JPEG */
MicrosoftAudioCodecManager, /**< Microsoft Audio Codec Manager (ACM) */
MicrosoftMpeg4, /**< Microsoft MPEG-4 */
MicrosoftVideoCodecManager, /**< Microsoft Video Codec Manager (VCM) */
MonkeysAudio, /**< Monkey's Audio */
Mpc, /**< Musepack */
Mpeg1Audio, /**< MPEG-1 Audio */
Mpeg1Video, /**< MPEG-1 Vudio */
Mpeg2Audio, /**< MPEG-2 Audio */
Mpeg2Video, /**< MPEG-2 Video */
Mpeg4TimedText, /**< MPEG-4 Timed Text / Streaming text format / Part 17 */
Mpeg4Video, /**< MPEG-4 Video */
OggKate, /**< Karaoke And Text Encapsulation */
Opus, /**< Opus */
Pcm, /**< Pulse Code Modulation */
Png, /**< PNG */
ProRes, /**< ProRes */
Qcelp, /**< QCELP */
QuicktimeAudio, /**< Quicktime Audio */
QuicktimeVideo, /**< Quicktime Video */
RealAudio, /**< Real Audio */
RealVideo, /**< Real Video */
Sa0c, /**< SAOC */
Smv, /**< SMV */
Speex, /**< Speex */
StreamingTextStream, /**< Streaming Text Stream */
SynthesizedTextureStream, /**< Synthesized Texture Stream */
Systems, /**< Systems */
TextSubtitle, /**< Text subtitle */
Theora, /**< Theora */
Tiff, /**< TIFF */
TimedText, /**< Timed Text */
Tta, /**< The True Audio lessles audio compressor */
UncompressedVideoFrames, /**< uncompressed RGB or YCbCr */
Vc1, /**< VC-1 */
VobBtn, /**< VobBtn */
VobSub, /**< VobSub */
Vorbis, /**< Vorbis */
Vp8, /**< VP8 */
Vp9, /**< VP9 */
WavPack, /**< WavPack */
WindowsMediaAudio, /**< Windows Media Audio */
WindowsMediaVideo, /**< Windows Media Video */
Vcc, /**< H.266/Versatile Video Coding */
};
/*!
* \brief Encapsulates sub formats.
*
* For instance "Layer 3" is a sub format of MPEG-1 audio.
*/
namespace SubFormats {
enum : unsigned char { None };
enum Mpeg1AudioLayer : unsigned char { Mpeg1Layer1 = 1, Mpeg1Layer2, Mpeg1Layer3 };
enum AacProfile : unsigned char {
AacMpeg2MainProfile = 1,
AacMpeg2LowComplexityProfile,
AacMpeg2ScalableSamplingRateProfile,
AacMpeg4MainProfile,
AacMpeg4LowComplexityProfile,
AacMpeg4ScalableSamplingRateProfile,
AacMpeg4LongTermPrediction,
AacMpeg4ERLowComplecityProfile,
AacMpeg4ERScalableSampingRateProfile,
AacMpeg4ERLongTermPrediction,
AacMpeg4ERLowDelay,
AacMpeg4EREnhancedLowDelay
};
enum Mpeg2VideoProfile : unsigned char {
Mpeg2SimpleProfile = 1,
Mpeg2MainProfile,
Mpeg2SnrProfile,
Mpeg2SpatialProfile,
Mpeg2HighProfile,
Mpeg2422Profile
};
enum Mpeg4VideoProfile : unsigned char {
Mpeg4SimpleProfile1 = 0x01,
Mpeg4SimpleProfile2 = 0x02,
Mpeg4SimpleProfile3 = 0x03,
Mpeg4SimpleProfile0 = 0x08,
Mpeg4SimpleScalableProfile0 = 0x10,
Mpeg4SimpleScalableProfile1 = 0x11,
Mpeg4SimpleScalableProfile2 = 0x12,
Mpeg4CoreProfile1 = 0x21,
Mpeg4CoreProfiel2 = 0x22,
Mpeg4MainProfile2 = 0x32,
Mpeg4MainProfile3 = 0x33,
Mpeg4MainProfile4 = 0x34,
Mpeg4NBitPrifle2 = 0x42,
Mpeg4ScalableTextureProfile1 = 0x51,
Mpeg4SimpleFaceAnimationProfile1 = 0x61,
Mpeg4SimpleFaceAnimationProfile2 = 0x62,
Mpeg4SimpleFbaProfile1 = 0x63,
Mpeg4SimpleFbaProfile2 = 0x64,
Mpeg4BasicAnimatedTextureProfiel1 = 0x71,
Mpeg4BasicAnimatedTextureProfiel2 = 0x72,
Mpeg4AvcProfile = 0x7F,
Mpeg4HybridProfile1 = 0x81,
Mpeg4HybridProfile2 = 0x82,
Mpeg4AdvancedRealTimeSimpleProfile1 = 0x91,
Mpeg4AdvancedRealTimeSimpleProfile2 = 0x92,
Mpeg4AdvancedRealTimeSimpleProfile3 = 0x93,
Mpeg4AdvancedRealTimeSimpleProfile4 = 0x94,
Mpeg4CoreScalableProfile1 = 0xA1,
Mpeg4CoreScalableProfile2 = 0xA2,
Mpeg4CoreScalableProfile3 = 0xA3,
Mpeg4AdvancedCodingEfficiencyProfile1 = 0xB1,
Mpeg4AdvancedCodingEfficiencyProfile2 = 0xB2,
Mpeg4AdvancedCodingEfficiencyProfile3 = 0xB3,
Mpeg4AdvancedCodingEfficiencyProfile4 = 0xB4,
Mpeg4AdvancedCoreProfile1 = 0xC1,
Mpeg4AdvancedCoreProfile2 = 0xC2,
Mpeg4AdvancedScalableTexture1 = 0xD1,
Mpeg4AdvancedScalableTexture2 = 0xD2,
Mpeg4SimpleStudioProfile1 = 0xE1,
Mpeg4SimpleStudioProfile2 = 0xE2,
Mpeg4SimpleStudioProfile3 = 0xE3,
Mpeg4SimpleStudioProfile4 = 0xE4,
Mpeg4CoreStudioProfile1 = 0xE5,
Mpeg4CoreStudioProfile2 = 0xE6,
Mpeg4CoreStudioProfile3 = 0xE7,
Mpeg4CoreStudioProfile4 = 0xE8,
Mpeg4AdvancedSimpleProfile0 = 0xF0,
Mpeg4AdvancedSimpleProfile1 = 0xF1,
Mpeg4AdvancedSimpleProfile2 = 0xF2,
Mpeg4AdvancedSimpleProfile3 = 0xF3,
Mpeg4AdvancedSimpleProfile4 = 0xF4,
Mpeg4AdvancedSimpleProfile5 = 0xF5,
Mpeg4AdvancedSimpleProfile3b = 0xF7,
Mpeg4FineGranularityScalableProfile0 = 0xF8,
Mpeg4FineGranularityScalableProfile1 = 0xF9,
Mpeg4FineGranularityScalableProfile2 = 0xFA,
Mpeg4FineGranularityScalableProfile3 = 0xFB,
Mpeg4FineGranularityScalableProfile4 = 0xFC,
Mpeg4FineGranularityScalableProfile5 = 0xFD
};
enum AvcProfile : unsigned char {
AvcCavlc444IntraProfile = 0x2C,
AvcBaselineProfile = 0x42,
AvcMainProfile = 0x4D,
AvcScalableBaselineProfile = 0x53,
AvcScalableHighProfile = 0x56,
AvcExtendedProfile = 0x58,
AvcHighProfile = 0x64,
AvcHigh10Profile = 0x6E,
AvcHighMultiviewProfile = 0x76,
AvcHigh422Profile = 0x7A,
AvcStereoHighProfile = 0x80,
AvcHighMultiviewDepthProfile = 0x8A,
AvcHigh444Profile = 0x90,
AvcHigh444PredictiveProfile = 0xF4
};
enum DtsSpecifier : unsigned char {
DtsExpress = 1,
DtsLossless,
DtsHdHighResolution,
DtsHdMasterAudio,
};
enum PcmVersion : unsigned char { PcmIntBe = 1, PcmIntLe, PcmFloatIeee };
enum TextSubtitle : unsigned char {
PlainUtf8Subtitle = 1,
SubStationAlpha,
AdvancedSubStationAlpha,
UniversalSubtitleFormat,
WebVideoTextTracksFormat
};
enum ImageSubtitle : unsigned char { ImgSubBmp = 1 };
} // namespace SubFormats
/*!
* \brief Encapsulates extension formats.
*/
namespace ExtensionFormats {
enum AudioFormatExtensions : unsigned char { SpectralBandReplication = 1, ParametricStereo = 2 };
}
class TAG_PARSER_EXPORT MediaFormat {
public:
constexpr MediaFormat(GeneralMediaFormat general = GeneralMediaFormat::Unknown, unsigned char sub = 0, unsigned char extension = 0);
std::string_view name() const;
std::string_view abbreviation() const;
std::string_view shortAbbreviation() const;
std::string_view extensionName() const;
constexpr operator bool() const;
constexpr MediaFormat &operator+=(const MediaFormat &other);
constexpr bool operator==(GeneralMediaFormat general) const;
constexpr bool operator!=(GeneralMediaFormat general) const;
GeneralMediaFormat general;
unsigned char sub;
unsigned char extension;
};
/*!
* \brief Constructs a new media format.
*/
constexpr MediaFormat::MediaFormat(GeneralMediaFormat general, unsigned char sub, unsigned char extension)
: general(general)
, sub(sub)
, extension(extension)
{
}
/*!
* \brief "Adds" information from another instance to the object.
*/
constexpr MediaFormat &MediaFormat::operator+=(const MediaFormat &other)
{
if (other) {
general = other.general;
if (other.sub) {
sub = other.sub;
}
if (other.extension) {
extension = other.extension;
}
}
return *this;
}
/*!
* \brief Returns whether the media format is the specified general media format.
*/
constexpr bool MediaFormat::operator==(GeneralMediaFormat general) const
{
return this->general == general;
}
/*!
* \brief Returns whether the media format is not the specified general media format.
*/
constexpr bool MediaFormat::operator!=(GeneralMediaFormat general) const
{
return this->general != general;
}
/*!
* \brief Returns whether the media format is known.
*/
constexpr MediaFormat::operator bool() const
{
return general != GeneralMediaFormat::Unknown;
}
} // namespace TagParser
#endif // TAG_PARSER_MEDIAFORMAT_H