Tag Parser  10.0.1
C++ library for reading and writing MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska tags
mp4ids.cpp
Go to the documentation of this file.
1 #include "./mp4ids.h"
2 
3 #include "../mediaformat.h"
4 
5 namespace TagParser {
6 
10 namespace Mp4AtomIds {
11 }
12 
17 namespace Mp4TagAtomIds {
18 }
19 
23 namespace Mp4TagExtendedMeanIds {
24 std::string_view iTunes = "com.apple.iTunes";
25 }
26 
30 namespace Mp4TagExtendedNameIds {
31 std::string_view cdec = "cdec";
32 std::string_view label = "LABEL";
33 } // namespace Mp4TagExtendedNameIds
34 
38 namespace Mp4MediaTypeIds {
39 }
40 
45 namespace FourccIds {
46 
47 MediaFormat fourccToMediaFormat(std::uint32_t fourccId)
48 {
49  switch (fourccId) {
50  case Mpeg:
52  case Mpeg2Imx30:
53  case Mpeg2Imx50:
55  case Mpeg4Video:
57  case Mpeg4TimedText:
59  case Hevc1:
60  case Hevc2:
62  case Avc1:
63  case Avc2:
64  case Avc3:
65  case Avc4:
66  case H264Decoder1:
67  case H264Decoder2:
68  case H264Decoder3:
69  case H264Decoder4:
70  case H264Decoder5:
71  case H264Decoder6:
73  case Av1_IVF:
74  case Av1_ISOBMFF:
76  case Divx4Decoder1:
77  case Divx4Decoder2:
78  case H263Quicktime:
79  case H2633GPP:
80  case XvidDecoder1:
81  case XvidDecoder2:
82  case XvidDecoder3:
83  case XvidDecoder4:
84  case XvidDecoder5:
85  case Divx5Decoder:
87  case Divx3Decoder1:
88  case Divx3Decoder2:
89  case Divx3Decoder3:
90  case Divx3Decoder4:
91  case Divx3Decoder5:
92  case Divx3Decoder6:
93  case Divx3Decoder7:
94  case Divx3Decoder8:
95  case Divx3Decoder9:
96  case Divx3Decoder10:
97  case Divx3Decoder11:
98  case Divx3Decoder12:
99  case Divx3Decoder13:
100  case Divx3Decoder14:
101  case Divx3Decoder15:
103  case Tiff:
105  case AppleTextAtsuiCodec:
107  case Raw:
109  case Jpeg:
111  case Gif:
113  case Png:
115  case AdpcmAcm:
117  case ImaadpcmAcm:
119  case Mp3CbrOnly:
120  case Mp3:
122  case Mpeg4Audio:
124  case Alac:
126  case Ac3:
128  case EAc3:
130  case DolbyMpl:
132  case Ac4:
134  case Rv20:
135  case Rv30:
136  case Rv40:
138  case Int24:
139  case Int32:
141  case Int16Be:
143  case Int16Le:
145  case FloatingPoint32Bit:
146  case FloatingPoint64Bit:
148  case Amr:
149  case AmrNarrowband:
151  case Dts:
152  case DtsH:
154  case DtsE:
156  case WindowsMediaAudio:
157  case WindowsMediaAudio7:
161  case MsMpeg4V1Decoder1:
162  case MsMpeg4V1Decoder2:
163  case MsMpeg4V1Decoder3:
164  case MsMpeg4V1Decoder4:
165  case MsMpeg4V1Decoder5:
166  case MsMpeg4V1Decoder6:
168  case MsMpeg4V2Decoder1:
169  case MsMpeg4V2Decoder2:
170  case MsMpeg4V2Decoder3:
171  case MsMpeg4V2Decoder4:
173  case MsMpeg4V3Decoder1:
174  case MsMpeg4V3Decoder2:
176  case Vp8:
178  case Vp9:
179  case Vp9_2:
181  case WavPack:
185  case WindowsMediaVideoV2:
186  case WindowsMediaVideoV8:
188  case Flac:
190  case Opus:
192  // TODO: map more FOURCCs
193  default:
195  }
196 }
197 
198 } // namespace FourccIds
199 
204 namespace Mp4FormatExtensionIds {
205 }
206 
210 namespace Mpeg4ElementaryStreamObjectIds {
211 
215 MediaFormat streamObjectTypeFormat(std::uint8_t streamObjectTypeId)
216 {
217  switch (streamObjectTypeId) {
218  case SystemsIso144961:
220  case SystemsIso144961v2:
222  case InteractionStream:
224  case AfxStream:
226  case FontDataStream:
230  case StreamingTextStream:
232  case Mpeg4Visual:
234  case Avc:
236  case ParameterSetsForAvc:
238  case Als:
240  case Sa0c:
242  case Aac:
256  case Mpeg2AacMainProfile:
262  case Mpeg2Audio:
264  case Mpeg1Video:
266  case Mpeg1Audio:
268  case Jpeg:
270  case Png:
272  case Evrc:
273  case PrivateEvrc:
275  case Smv:
277  case Gpp2Cmf:
279  case Vc1:
281  case Dirac:
283  case Ac3:
284  case PrivateAc3:
286  case EAc3:
288  case Dts:
289  case PrivateDts:
291  case DtsHdHighResolution:
293  case DtsHdMasterAudio:
295  case DtsHdExpress:
297  case PrivateOgg:
298  case PrivateOgg2:
300  case PrivateVobSub:
302  case PrivateQcelp:
304  default:
305  return MediaFormat();
306  }
307 }
308 
309 } // namespace Mpeg4ElementaryStreamObjectIds
310 
314 namespace Mpeg4DescriptorIds {
315 }
316 
320 namespace Mpeg4ElementaryStreamTypeIds {
321 
325 std::string_view streamTypeName(std::uint8_t streamTypeId)
326 {
327  switch (streamTypeId) {
328  case ObjectDescriptor:
329  return "object descriptor";
330  case ClockReference:
331  return "clock reference";
332  case SceneDescriptor:
333  return "scene descriptor";
334  case Visual:
335  return "visual";
336  case Audio:
337  return "audio";
338  case Mpeg7:
339  return "MPEG-7";
340  case Ipmps:
341  return "IMPS";
342  case ObjectContentInfo:
343  return "object content info";
344  case MpegJava:
345  return "MPEG Java";
346  case Interaction:
347  return "interaction";
348  case Ipmp:
349  return "IPMP";
350  case FontData:
351  return "font data";
352  case StreamingText:
353  return "streaming text";
354  default:
355  return "";
356  }
357 }
358 
359 } // namespace Mpeg4ElementaryStreamTypeIds
360 
365 namespace Mpeg4AudioObjectIds {
366 
367 TAG_PARSER_EXPORT MediaFormat idToMediaFormat(std::uint8_t mpeg4AudioObjectId, bool sbrPresent, bool psPresent)
368 {
369  MediaFormat fmt;
370  switch (mpeg4AudioObjectId) {
371  case AacMain:
373  break;
374  case AacLc:
376  break;
377  case AacSsr:
379  break;
380  case AacLtp:
382  break;
383  case Sbr:
385  break;
386  case AacScalable:
388  break;
389  case ErAacLc:
391  break;
392  case ErAacLtp:
394  break;
395  case ErAacLd:
397  break;
398  case Ps:
400  break;
401  case Layer1:
403  break;
404  case Layer2:
406  break;
407  case Layer3:
409  break;
410  default:;
411  }
412  if (sbrPresent) {
414  }
415  if (psPresent) {
417  }
418  return fmt;
419 }
420 
421 } // namespace Mpeg4AudioObjectIds
422 
423 std::uint32_t mpeg4SamplingFrequencyTable[] = { 96000, 88200, 64000, 48000, 44100, 32000, 24000, 22050, 16000, 12000, 11025, 8000, 7350 };
424 
428 namespace Mpeg4ChannelConfigs {
429 
433 std::string_view channelConfigString(std::uint8_t config)
434 {
435  switch (config) {
436  case AotSpecificConfig:
437  return "defined in AOT Specific Config";
438  case FrontCenter:
439  return "1 channel: front-center";
440  case FrontLeftFrontRight:
441  return "2 channels: front-left, front-right";
443  return "3 channels: front-center, front-left, front-right";
445  return "4 channels: front-center, front-left, front-right, back-center";
447  return "5 channels: front-center, front-left, front-right, back-left, back-right";
449  return "6 channels: front-center, front-left, front-right, back-left, back-right, LFE-channel";
451  return "8 channels: front-center, front-left, front-right, side-left, side-right, back-left, back-right, LFE-channel";
452  default:
453  return std::string_view();
454  }
455 }
456 
460 std::uint8_t channelCount(std::uint8_t config)
461 {
462  switch (config) {
463  case FrontCenter:
464  return 1;
465  case FrontLeftFrontRight:
466  return 2;
468  return 3;
470  return 4;
472  return 5;
474  return 6;
476  return 8;
477  default:
478  return 0;
479  }
480 }
481 
482 } // namespace Mpeg4ChannelConfigs
483 
487 namespace Mpeg4VideoCodes {
488 }
489 
493 namespace Mpeg2VideoCodes {
494 }
495 
496 } // namespace TagParser
The MediaFormat class specifies the format of media data.
Definition: mediaformat.h:246
unsigned char extension
Definition: mediaformat.h:261
#define TAG_PARSER_EXPORT
Marks the symbol to be exported by the tagparser library.
@ WindowsMediaAudio9Professional
Definition: mp4ids.h:393
@ WindowsMediaAudio9Standard
Definition: mp4ids.h:394
TAG_PARSER_EXPORT MediaFormat fourccToMediaFormat(std::uint32_t fourccId)
Definition: mp4ids.cpp:47
TAG_PARSER_EXPORT MediaFormat idToMediaFormat(std::uint8_t mpeg4AudioObjectId, bool sbrPresent=false, bool psPresent=false)
Definition: mp4ids.cpp:367
TAG_PARSER_EXPORT std::string_view channelConfigString(std::uint8_t config)
Returns the string representation for the specified MPEG-4 channel config.
Definition: mp4ids.cpp:433
@ FrontCenterFrontLeftFrontRightBackLeftBackRightLFEChannel
Definition: mp4ids.h:622
@ FrontCenterFrontLeftFrontRightSideLeftSideRightBackLeftBackRightLFEChannel
Definition: mp4ids.h:623
@ FrontCenterFrontLeftFrontRightBackLeftBackRight
Definition: mp4ids.h:621
TAG_PARSER_EXPORT std::uint8_t channelCount(std::uint8_t config)
Returns the channel count for the specified MPEG-4 channel config.
Definition: mp4ids.cpp:460
TAG_PARSER_EXPORT MediaFormat streamObjectTypeFormat(std::uint8_t streamObjectTypeId)
Returns the TagParser::MediaFormat denoted by the specified MPEG-4 stream ID.
Definition: mp4ids.cpp:215
TAG_PARSER_EXPORT std::string_view streamTypeName(std::uint8_t streamTypeId)
Returns the name of the stream type denoted by the specified MPEG-4 stream type ID.
Definition: mp4ids.cpp:325
Contains all classes and functions of the TagInfo library.
Definition: aaccodebook.h:10
std::uint32_t mpeg4SamplingFrequencyTable[13]
Definition: mp4ids.cpp:423