1 /* Copyright (c) MediaArea.net SARL. All Rights Reserved.
2 *
3 * Use of this source code is governed by a BSD-style license that can
4 * be found in the License.html file in the root of the source tree.
5 */
6
7 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
8 //
9 // Descriptors part
10 //
11 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
12
13 //---------------------------------------------------------------------------
14 // Pre-compilation
15 #include "MediaInfo/PreComp.h"
16 #ifdef __BORLANDC__
17 #pragma hdrstop
18 #endif
19 //---------------------------------------------------------------------------
20
21 //---------------------------------------------------------------------------
22 #include "MediaInfo/Setup.h"
23 //---------------------------------------------------------------------------
24
25 //---------------------------------------------------------------------------
26 #ifdef MEDIAINFO_MPEG4_YES
27 //---------------------------------------------------------------------------
28
29 //---------------------------------------------------------------------------
30 #include "MediaInfo/Multiple/File_Mpeg4_Descriptors.h"
31 #include <cstring>
32 #if defined(MEDIAINFO_OGG_YES)
33 #include "MediaInfo/Multiple/File_Ogg.h"
34 #endif
35 #if defined(MEDIAINFO_AVC_YES)
36 #include "MediaInfo/Video/File_Avc.h"
37 #endif
38 #if defined(MEDIAINFO_VC1_YES)
39 #include "MediaInfo/Video/File_Vc1.h"
40 #endif
41 #if defined(MEDIAINFO_DIRAC_YES)
42 #include "MediaInfo/Video/File_Dirac.h"
43 #endif
44 #if defined(MEDIAINFO_MPEG4V_YES)
45 #include "MediaInfo/Video/File_Mpeg4v.h"
46 #endif
47 #if defined(MEDIAINFO_MPEGV_YES)
48 #include "MediaInfo/Video/File_Mpegv.h"
49 #endif
50 #if defined(MEDIAINFO_JPEG_YES)
51 #include "MediaInfo/Image/File_Jpeg.h"
52 #endif
53 #if defined(MEDIAINFO_PNG_YES)
54 #include "MediaInfo/Image/File_Png.h"
55 #endif
56 #if defined(MEDIAINFO_AAC_YES)
57 #include "MediaInfo/Audio/File_Aac.h"
58 #endif
59 #if defined(MEDIAINFO_AC3_YES)
60 #include "MediaInfo/Audio/File_Ac3.h"
61 #endif
62 #if defined(MEDIAINFO_DTS_YES)
63 #include "MediaInfo/Audio/File_Dts.h"
64 #endif
65 #if defined(MEDIAINFO_MPEGA_YES)
66 #include "MediaInfo/Audio/File_Mpega.h"
67 #endif
68 #if MEDIAINFO_DEMUX
69 #include "MediaInfo/MediaInfo_Config_MediaInfo.h"
70 #include "ThirdParty/base64/base64.h"
71 #endif //MEDIAINFO_DEMUX
72 //---------------------------------------------------------------------------
73
74 namespace MediaInfoLib
75 {
76
77 //---------------------------------------------------------------------------
78 #ifdef MEDIAINFO_MPEG4V_YES
79 const char* Mpeg4v_Profile_Level(int32u Profile_Level);
80 #endif //MEDIAINFO_MPEG4V_YES
81 //---------------------------------------------------------------------------
82
83 //***************************************************************************
84 // Constants
85 //***************************************************************************
86
87 //---------------------------------------------------------------------------
Mpeg4_Descriptors_Predefined(int8u ID)88 static const char* Mpeg4_Descriptors_Predefined(int8u ID)
89 {
90 switch (ID)
91 {
92 case 0x00 : return "Custom";
93 case 0x01 : return "null SL packet header";
94 case 0x02 : return "Reserved for use in MP4 files";
95 default : return "";
96 }
97 }
98
99 //---------------------------------------------------------------------------
Mpeg4_Descriptors_ObjectTypeIndication(int8u ID)100 static const char* Mpeg4_Descriptors_ObjectTypeIndication(int8u ID)
101 {
102 switch (ID)
103 {
104 case 0x01 : return "Systems ISO/IEC 14496-1";
105 case 0x02 : return "Systems ISO/IEC 14496-1 (v2)";
106 case 0x03 : return "Interaction Stream";
107 case 0x05 : return "AFX Stream";
108 case 0x06 : return "Font Data Stream";
109 case 0x07 : return "Synthesized Texture Stream";
110 case 0x08 : return "Streaming Text Stream";
111 case 0x20 : return "Visual ISO/IEC 14496-2 (MPEG-4 Visual)";
112 case 0x21 : return "Visual ISO/IEC 14496-10 (AVC)";
113 case 0x22 : return "Parameter Sets for Visual ISO/IEC 14496-10 (AVC)";
114 case 0x24 : return "ALS"; //Not sure
115 case 0x2B : return "SAOC"; //Not sure
116 case 0x40 : return "Audio ISO/IEC 14496-3 (AAC)";
117 case 0x60 : return "Visual ISO/IEC 13818-2 Simple Profile (MPEG Video)";
118 case 0x61 : return "Visual ISO/IEC 13818-2 Main Profile (MPEG Video)";
119 case 0x62 : return "Visual ISO/IEC 13818-2 SNR Profile (MPEG Video)";
120 case 0x63 : return "Visual ISO/IEC 13818-2 Spatial Profile (MPEG Video)";
121 case 0x64 : return "Visual ISO/IEC 13818-2 High Profile (MPEG Video)";
122 case 0x65 : return "Visual ISO/IEC 13818-2 422 Profile (MPEG Video)";
123 case 0x66 : return "Audio ISO/IEC 13818-7 Main Profile (AAC)";
124 case 0x67 : return "Audio ISO/IEC 13818-7 Low Complexity Profile (AAC)";
125 case 0x68 : return "Audio ISO/IEC 13818-7 Scaleable Sampling Rate Profile (AAC)";
126 case 0x69 : return "Audio ISO/IEC 13818-3 (MPEG Audio)";
127 case 0x6A : return "Visual ISO/IEC 11172-2 (MPEG Video)";
128 case 0x6B : return "Audio ISO/IEC 11172-3 (MPEG Audio)";
129 case 0x6C : return "Visual ISO/IEC 10918-1 (JPEG)";
130 case 0x6D : return "PNG";
131 case 0xA0 : return "EVRC";
132 case 0xA1 : return "SMV";
133 case 0xA2 : return "3GPP2 Compact Multimedia Format (CMF)";
134 case 0xA3 : return "VC-1";
135 case 0xA4 : return "Dirac";
136 case 0xA5 : return "AC-3";
137 case 0xA6 : return "E-AC-3";
138 case 0xA9 : return "DTS";
139 case 0xAA : return "DTS-HD High Resolution";
140 case 0xAB : return "DTS-HD Master Audio";
141 case 0xAC : return "DTS-HD Express";
142 case 0xD1 : return "Private - EVRC";
143 case 0xD3 : return "Private - AC-3";
144 case 0xD4 : return "Private - DTS";
145 case 0xDD : return "Private - Ogg";
146 case 0xDE : return "Private - Ogg";
147 case 0xE0 : return "Private - VobSub";
148 case 0xE1 : return "Private - QCELP";
149 default : return "";
150 }
151 }
152
153 //---------------------------------------------------------------------------
Mpeg4_Descriptors_StreamType(int8u ID)154 static const char* Mpeg4_Descriptors_StreamType(int8u ID)
155 {
156 switch (ID)
157 {
158 case 0x01 : return "ObjectDescriptorStream";
159 case 0x02 : return "ClockReferenceStream";
160 case 0x03 : return "SceneDescriptionStream";
161 case 0x04 : return "VisualStream";
162 case 0x05 : return "AudioStream";
163 case 0x06 : return "MPEG7Stream";
164 case 0x07 : return "IPMPStream";
165 case 0x08 : return "ObjectContentInfoStream";
166 case 0x09 : return "MPEGJStream";
167 case 0x0A : return "Interaction Stream";
168 case 0x0B : return "IPMPToolStream";
169 case 0x0C : return "FontDataStream";
170 case 0x0D : return "StreamingText";
171 default : return "";
172 }
173 }
174
175 //---------------------------------------------------------------------------
Mpeg4_Descriptors_ODProfileLevelIndication(int8u)176 static const char* Mpeg4_Descriptors_ODProfileLevelIndication(int8u /*ID*/)
177 {
178 return "";
179 }
180
181 //---------------------------------------------------------------------------
Mpeg4_Descriptors_SceneProfileLevelIndication(int8u ID)182 static const char* Mpeg4_Descriptors_SceneProfileLevelIndication(int8u ID)
183 {
184 switch (ID)
185 {
186 case 1 : return "Simple2D@L1";
187 case 2 : return "Simple2D@L2";
188 case 11 : return "Basic2D@L1";
189 case 12 : return "Core2D@L1";
190 case 13 : return "Core2D@L2";
191 case 14 : return "Advanced2D@L1";
192 case 15 : return "Advanced2D@L2";
193 case 16 : return "Advanced2D@L3";
194 case 17 : return "Main2D@L1";
195 case 18 : return "Main2D@L2";
196 case 19 : return "Main2D@L3";
197 default : return "";
198 }
199 }
200
201 //---------------------------------------------------------------------------
202 static const char* Mpeg4_Descriptors_AudioProfileLevelIndication_Profile[]=
203 {
204 "",
205 "Main Audio",
206 "Scalable Audio",
207 "Speech Audio",
208 "Synthesis Audio",
209 "High Quality Audio",
210 "Low Delay Audio",
211 "Natural Audio",
212 "Mobile Audio Internetworking",
213 "AAC",
214 "High Efficiency AAC",
215 "High Efficiency AAC v2",
216 "Low Delay AAC",
217 "Baseline MPEG Surround",
218 "High Definition AAC",
219 "ALS Simple",
220 "Baseline USAC",
221 "Extended HE AAC",
222 };
223 enum profile
224 {
225 NoProfile,
226 Main_Audio,
227 Scalable_Audio,
228 Speech_Audio,
229 Synthesis_Audio,
230 High_Quality_Audio,
231 Low_Delay_Audio,
232 Natural_Audio,
233 Mobile_Audio_Internetworking,
234 AAC,
235 High_Efficiency_AAC,
236 High_Efficiency_AAC_v2,
237 Low_Delay_AAC,
238 Baseline_MPEG_Surround,
239 High_Definition_AAC,
240 ALS_Simple,
241 Baseline_USAC,
242 Extended_HE_AAC,
243 };
244 struct profilelevel_struct
245 {
246 int8u profile;
247 int8u level;
248 };
249 static const size_t Mpeg4_Descriptors_AudioProfileLevelIndication_Size=0x58;
250 static const profilelevel_struct Mpeg4_Descriptors_AudioProfileLevelIndication_Mapping[Mpeg4_Descriptors_AudioProfileLevelIndication_Size]=
251 {
252 { NoProfile, 0 },
253 { Main_Audio, 1 },
254 { Main_Audio, 2 },
255 { Main_Audio, 3 },
256 { Main_Audio, 4 },
257 { Scalable_Audio, 1 },
258 { Scalable_Audio, 2 },
259 { Scalable_Audio, 3 },
260 { Scalable_Audio, 4 },
261 { Speech_Audio, 1 },
262 { Speech_Audio, 2 },
263 { Synthesis_Audio, 1 },
264 { Synthesis_Audio, 2 },
265 { Synthesis_Audio, 3 },
266 { High_Quality_Audio, 1 },
267 { High_Quality_Audio, 2 },
268 { High_Quality_Audio, 3 },
269 { High_Quality_Audio, 4 },
270 { High_Quality_Audio, 5 },
271 { High_Quality_Audio, 6 },
272 { High_Quality_Audio, 7 },
273 { High_Quality_Audio, 8 },
274 { Low_Delay_Audio, 1 },
275 { Low_Delay_Audio, 2 },
276 { Low_Delay_Audio, 3 },
277 { Low_Delay_Audio, 4 },
278 { Low_Delay_Audio, 5 },
279 { Low_Delay_Audio, 6 },
280 { Low_Delay_Audio, 7 },
281 { Low_Delay_Audio, 8 },
282 { Natural_Audio, 1 },
283 { Natural_Audio, 2 },
284 { Natural_Audio, 3 },
285 { Natural_Audio, 4 },
286 { Mobile_Audio_Internetworking, 1 },
287 { Mobile_Audio_Internetworking, 2 },
288 { Mobile_Audio_Internetworking, 3 },
289 { Mobile_Audio_Internetworking, 4 },
290 { Mobile_Audio_Internetworking, 5 },
291 { Mobile_Audio_Internetworking, 6 },
292 { AAC, 1 },
293 { AAC, 2 },
294 { AAC, 4 },
295 { AAC, 5 },
296 { High_Efficiency_AAC, 2 },
297 { High_Efficiency_AAC, 3 },
298 { High_Efficiency_AAC, 4 },
299 { High_Efficiency_AAC, 5 },
300 { High_Efficiency_AAC_v2, 2 },
301 { High_Efficiency_AAC_v2, 3 },
302 { High_Efficiency_AAC_v2, 4 },
303 { High_Efficiency_AAC_v2, 5 },
304 { Low_Delay_AAC, 1 },
305 { Baseline_MPEG_Surround, 1 },
306 { Baseline_MPEG_Surround, 2 },
307 { Baseline_MPEG_Surround, 3 },
308 { Baseline_MPEG_Surround, 4 },
309 { Baseline_MPEG_Surround, 5 },
310 { Baseline_MPEG_Surround, 6 },
311 { High_Definition_AAC, 1 },
312 { ALS_Simple, 1 },
313 { NoProfile, 0 },
314 { NoProfile, 0 },
315 { NoProfile, 0 },
316 { NoProfile, 0 },
317 { NoProfile, 0 },
318 { NoProfile, 0 },
319 { NoProfile, 0 },
320 { Baseline_USAC, 1 },
321 { Baseline_USAC, 2 },
322 { Baseline_USAC, 3 },
323 { Baseline_USAC, 4 },
324 { Extended_HE_AAC, 1 },
325 { Extended_HE_AAC, 2 },
326 { Extended_HE_AAC, 3 },
327 { Extended_HE_AAC, 4 },
328 { NoProfile, 0 },
329 { NoProfile, 0 },
330 { NoProfile, 0 },
331 { NoProfile, 0 },
332 { AAC, 6 },
333 { AAC, 7 },
334 { High_Efficiency_AAC, 6 },
335 { High_Efficiency_AAC, 7 },
336 { High_Efficiency_AAC_v2, 6 },
337 { High_Efficiency_AAC_v2, 7 },
338 { Extended_HE_AAC, 6 },
339 { Extended_HE_AAC, 7 },
340 };
Mpeg4_Descriptors_AudioProfileLevelIndication(int8u AudioProfileLevelIndication)341 static const Ztring Mpeg4_Descriptors_AudioProfileLevelIndication(int8u AudioProfileLevelIndication)
342 {
343 if (AudioProfileLevelIndication>=Mpeg4_Descriptors_AudioProfileLevelIndication_Size || Mpeg4_Descriptors_AudioProfileLevelIndication_Mapping[AudioProfileLevelIndication].profile==NoProfile)
344 return Ztring();
345 Ztring ToReturn;
346 ToReturn.From_UTF8(Mpeg4_Descriptors_AudioProfileLevelIndication_Profile[Mpeg4_Descriptors_AudioProfileLevelIndication_Mapping[AudioProfileLevelIndication].profile]);
347 ToReturn+=__T("@L");
348 ToReturn+=Ztring().From_Number(Mpeg4_Descriptors_AudioProfileLevelIndication_Mapping[AudioProfileLevelIndication].level);
349 return ToReturn;
350 }
351
352 //---------------------------------------------------------------------------
353 extern const char* Mpeg4v_Profile_Level(int32u Profile_Level);
354
355 //---------------------------------------------------------------------------
Mpeg4_Descriptors_GraphicsProfileLevelIndication(int8u ID)356 static const char* Mpeg4_Descriptors_GraphicsProfileLevelIndication(int8u ID)
357 {
358 switch (ID)
359 {
360 case 1 : return "Simple2D@L1";
361 case 2 : return "Simple2D+Text@L1";
362 case 3 : return "Simple2D+Text@L2";
363 case 4 : return "Core2D@L1";
364 case 5 : return "Core2D@L2";
365 case 6 : return "Advanced2D@L1";
366 case 7 : return "Advanced2D@L2";
367 default : return "";
368 }
369 }
370
371 //***************************************************************************
372 // Constructor/Destructor
373 //***************************************************************************
374
375 //---------------------------------------------------------------------------
File_Mpeg4_Descriptors()376 File_Mpeg4_Descriptors::File_Mpeg4_Descriptors()
377 :File__Analyze()
378 {
379 //Configuration
380 ParserName="MPEG-4 Descriptor";
381 #if MEDIAINFO_EVENTS
382 ParserIDs[0]=MediaInfo_Parser_Mpeg4_Desc;
383 StreamIDs_Width[0]=0;
384 #endif //MEDIAINFO_EVENTS
385 StreamSource=IsStream;
386
387 //In
388 KindOfStream=Stream_Max;
389 PosOfStream=(size_t)-1;
390 Parser_DoNotFreeIt=false;
391 SLConfig_DoNotFreeIt=false;
392
393 //Out
394 Parser=NULL;
395 ES_ID=0x0000;
396 SLConfig=NULL;
397
398 //Temp
399 ObjectTypeId=0x00;
400 }
401
402 //---------------------------------------------------------------------------
~File_Mpeg4_Descriptors()403 File_Mpeg4_Descriptors::~File_Mpeg4_Descriptors()
404 {
405 if (!Parser_DoNotFreeIt)
406 delete Parser;// Parser=NULL;
407 if (!SLConfig_DoNotFreeIt)
408 delete SLConfig;// SLConfig=NULL;
409 }
410
411 //***************************************************************************
412 // Buffer
413 //***************************************************************************
414
415 //---------------------------------------------------------------------------
Header_Parse()416 void File_Mpeg4_Descriptors::Header_Parse()
417 {
418 //Parsing
419 size_t Size=0;
420 int8u type, Size_ToAdd;
421 Get_B1(type, "type");
422 if (type==0)
423 {
424 Header_Fill_Code(0x00, "Padding");
425 Header_Fill_Size(1);
426 return;
427 }
428 do
429 {
430 Get_B1(Size_ToAdd, "size");
431 Size=(Size<<7) | (Size_ToAdd&0x7F);
432 }
433 while (Size_ToAdd&0x80);
434
435 //Filling
436 Header_Fill_Code(type, Ztring().From_CC1(type));
437 if (Element_Offset+Size>=Element_Size)
438 Size=(size_t)(Element_Size-Element_Offset); //Found one file with too big size but content is OK, cutting the block
439 Header_Fill_Size(Element_Offset+Size);
440 }
441
442
443 //---------------------------------------------------------------------------
Data_Parse()444 void File_Mpeg4_Descriptors::Data_Parse()
445 {
446 //Preparing
447 Status[IsAccepted]=true;
448
449 #define ELEMENT_CASE(_NAME, _DETAIL) \
450 case 0x##_NAME : Element_Name(_DETAIL); Descriptor_##_NAME(); break;
451
452 //Parsing
453 switch (Element_Code)
454 {
455 ELEMENT_CASE(00, "Forbidden");
456 ELEMENT_CASE(01, "ObjectDescrTag");
457 ELEMENT_CASE(02, "InitialObjectDescrTag");
458 ELEMENT_CASE(03, "ES_DescrTag");
459 ELEMENT_CASE(04, "DecoderConfigDescrTag");
460 ELEMENT_CASE(05, "DecSpecificInfoTag");
461 ELEMENT_CASE(06, "SLConfigDescrTag");
462 ELEMENT_CASE(07, "ContentIdentDescrTag");
463 ELEMENT_CASE(08, "SupplContentIdentDescrTag");
464 ELEMENT_CASE(09, "IPI_DescrPointerTag");
465 ELEMENT_CASE(0A, "IPMP_DescrPointerTag");
466 ELEMENT_CASE(0B, "IPMP_DescrTag");
467 ELEMENT_CASE(0C, "QoS_DescrTag");
468 ELEMENT_CASE(0D, "RegistrationDescrTag");
469 ELEMENT_CASE(0E, "ES_ID_IncTag");
470 ELEMENT_CASE(0F, "ES_ID_RefTag");
471 ELEMENT_CASE(10, "MP4_IOD_Tag");
472 ELEMENT_CASE(11, "MP4_OD_Tag");
473 ELEMENT_CASE(12, "IPL_DescrPointerRefTag");
474 ELEMENT_CASE(13, "ExtendedProfileLevelDescrTag");
475 ELEMENT_CASE(14, "profileLevelIndicationIndexDescrTag");
476 ELEMENT_CASE(40, "ContentClassificationDescrTag");
477 ELEMENT_CASE(41, "KeyWordDescrTag");
478 ELEMENT_CASE(42, "RatingDescrTag");
479 ELEMENT_CASE(43, "LanguageDescrTag");
480 ELEMENT_CASE(44, "ShortTextualDescrTag");
481 ELEMENT_CASE(45, "ExpandedTextualDescrTag");
482 ELEMENT_CASE(46, "ContentCreatorNameDescrTag");
483 ELEMENT_CASE(47, "ContentCreationDateDescrTag");
484 ELEMENT_CASE(48, "OCICreatorNameDescrTag");
485 ELEMENT_CASE(49, "OCICreationDateDescrTag");
486 ELEMENT_CASE(4A, "SmpteCameraPositionDescrTag");
487 ELEMENT_CASE(4B, "SegmentDescrTag");
488 ELEMENT_CASE(4C, "MediaTimeDescrTag");
489 ELEMENT_CASE(60, "IPMP_ToolsListDescrTag");
490 ELEMENT_CASE(61, "IPMP_ToolTag");
491 ELEMENT_CASE(62, "FLEXmuxTimingDescrTag");
492 ELEMENT_CASE(63, "FLEXmuxCodeTableDescrTag");
493 ELEMENT_CASE(64, "ExtSLConfigDescrTag");
494 ELEMENT_CASE(65, "FLEXmuxBufferSizeDescrTag");
495 ELEMENT_CASE(66, "FLEXmuxIdentDescrTag");
496 ELEMENT_CASE(67, "DependencyPointerTag");
497 ELEMENT_CASE(68, "DependencyMarkerTag");
498 ELEMENT_CASE(69, "FLEXmuxChannelDescrTag");
499 default: if (Element_Code>=0xC0)
500 Element_Name("user private");
501 else
502 Element_Name("unknown");
503 Skip_XX(Element_Size, "Data");
504 break;
505 }
506 }
507
508 //***************************************************************************
509 // Elements
510 //***************************************************************************
511
512 //---------------------------------------------------------------------------
Descriptor_01()513 void File_Mpeg4_Descriptors::Descriptor_01()
514 {
515 //Parsing
516 int8u ProfileLevel[5];
517 bool URL_Flag;
518 BS_Begin();
519 Skip_S2(10, "ObjectDescriptorID");
520 Get_SB ( URL_Flag, "URL_Flag");
521 Skip_SB( "includeInlineProfileLevelFlag");
522 Skip_S1( 4, "reserved");
523 BS_End();
524 if (URL_Flag)
525 {
526 int8u URLlength;
527 Get_B1 (URLlength, "URLlength");
528 Skip_UTF8(URLlength, "URLstring");
529 }
530 else if (Element_Code==0x02 || Element_Code==0x10)
531 {
532 Get_B1 (ProfileLevel[0], "ODProfileLevelIndication"); Param_Info1(Mpeg4_Descriptors_ODProfileLevelIndication(ProfileLevel[0]));
533 Get_B1 (ProfileLevel[1], "sceneProfileLevelIndication"); Param_Info1(Mpeg4_Descriptors_SceneProfileLevelIndication(ProfileLevel[1]));
534 Get_B1 (ProfileLevel[2], "audioProfileLevelIndication"); Param_Info1(Mpeg4_Descriptors_AudioProfileLevelIndication(ProfileLevel[2]));
535 Get_B1 (ProfileLevel[3], "visualProfileLevelIndication"); Param_Info1(Mpeg4v_Profile_Level(ProfileLevel[3]));
536 Get_B1 (ProfileLevel[4], "graphicsProfileLevelIndication"); Param_Info1(Mpeg4_Descriptors_GraphicsProfileLevelIndication(ProfileLevel[4]));
537 }
538
539 FILLING_BEGIN();
540 if (Element_Code==0x10)
541 {
542 //Clear
543 ES_ID_Infos.clear();
544
545 //Fill
546 int8u ProfileLevel_Count=0;
547 for (int8u i=0; i<5; i++)
548 if (ProfileLevel[i]!=0xFF)
549 ProfileLevel_Count++;
550 if (ProfileLevel_Count==1)
551 {
552 for (int8u i=0; i<5; i++)
553 {
554 if (ProfileLevel[i]!=0xFF)
555 {
556 es_id_info& ES_ID_Info=ES_ID_Infos[(int32u)-1];
557 switch (i)
558 {
559 case 2 : ES_ID_Info.StreamKind=Stream_Audio;
560 ES_ID_Info.ProfileLevel=Mpeg4_Descriptors_AudioProfileLevelIndication(ProfileLevel[i]);
561 break;
562 case 3 :
563 ES_ID_Info.StreamKind=Stream_Video;
564 ES_ID_Info.ProfileLevel=Mpeg4v_Profile_Level(ProfileLevel[i]);
565 break;
566 default : ;
567 }
568 if (ES_ID_Info.ProfileLevel.empty() && ProfileLevel[i]!=0xFE)
569 ES_ID_Info.ProfileLevel.From_Number(ProfileLevel[i]);
570 }
571 }
572 }
573 }
574 Element_ThisIsAList();
575 FILLING_END();
576 }
577
578 //---------------------------------------------------------------------------
Descriptor_03()579 void File_Mpeg4_Descriptors::Descriptor_03()
580 {
581 //Parsing
582 bool streamDependenceFlag, URL_Flag, OCRstreamFlag;
583 Get_B2 (ES_ID, "ES_ID");
584 BS_Begin();
585 Get_SB ( streamDependenceFlag, "streamDependenceFlag");
586 Get_SB ( URL_Flag, "URL_Flag");
587 Get_SB ( OCRstreamFlag, "OCRstreamFlag");
588 Skip_S1(5, "streamPriority");
589 BS_End();
590 if (streamDependenceFlag)
591 Skip_B2( "dependsOn_ES_ID");
592 if (URL_Flag)
593 {
594 int8u URLlength;
595 Get_B1 (URLlength, "URLlength");
596 Skip_UTF8(URLlength, "URLstring");
597 }
598 if (OCRstreamFlag)
599 Skip_B2( "OCR_ES_Id");
600
601 FILLING_BEGIN();
602 Element_ThisIsAList();
603 FILLING_END();
604 }
605
606 //---------------------------------------------------------------------------
Descriptor_04()607 void File_Mpeg4_Descriptors::Descriptor_04()
608 {
609 //Parsing
610 int32u bufferSizeDB, MaxBitrate, AvgBitrate;
611 int8u streamType;
612 Get_B1 (ObjectTypeId, "objectTypeIndication"); Param_Info1(Mpeg4_Descriptors_ObjectTypeIndication(ObjectTypeId));
613 BS_Begin();
614 Get_S1 (6, streamType, "streamType"); Param_Info1(Mpeg4_Descriptors_StreamType(streamType));
615 Skip_SB( "upStream");
616 Skip_SB( "reserved");
617 BS_End();
618 Get_B3 (bufferSizeDB, "bufferSizeDB");
619 Get_B4 (MaxBitrate, "maxBitrate");
620 Get_B4 (AvgBitrate, "avgBitrate");
621
622 FILLING_BEGIN();
623 if (KindOfStream==Stream_Max)
624 switch (ObjectTypeId)
625 {
626 case 0x20 :
627 case 0x21 :
628 case 0x60 :
629 case 0x61 :
630 case 0x62 :
631 case 0x63 :
632 case 0x64 :
633 case 0x65 :
634 case 0x6A :
635 case 0x6C :
636 case 0x6D :
637 case 0x6E :
638 case 0xA3 :
639 case 0xA4 :
640 KindOfStream=Stream_Video; break;
641 case 0x40 :
642 case 0x66 :
643 case 0x67 :
644 case 0x68 :
645 case 0x69 :
646 case 0x6B :
647 case 0xA0 :
648 case 0xA1 :
649 case 0xA5 :
650 case 0xA6 :
651 case 0xA9 :
652 case 0xAA :
653 case 0xAB :
654 case 0xAC :
655 case 0xD1 :
656 case 0xD3 :
657 case 0xD4 :
658 case 0xE1 :
659 KindOfStream=Stream_Audio; break;
660 case 0x08 :
661 case 0xE0 :
662 KindOfStream=Stream_Text; break;
663 default: ;
664 }
665 if (Count_Get(KindOfStream)==0)
666 Stream_Prepare(KindOfStream);
667 switch (ObjectTypeId)
668 {
669 case 0x01 : Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_Format), "System", Unlimited, true, true); break;
670 case 0x02 : Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_Format), "System Core", Unlimited, true, true); break;
671 //case 0x03 Interaction Stream
672 //case 0x05 AFX
673 //case 0x06 Font Data
674 //case 0x07 Synthesized Texture Stream
675 case 0x08 : Fill(Stream_Text , StreamPos_Last, Text_Format, "Streaming Text", Unlimited, true, true); break;
676 case 0x20 : Fill(Stream_Video , StreamPos_Last, Video_Format, "MPEG-4 Visual", Unlimited, true, true); break;
677 case 0x21 : Fill(Stream_Video , StreamPos_Last, Video_Format, "AVC", Unlimited, true, true); break;
678 //case 0x22 Parameter Sets for AVC
679 case 0x40 : break; //MPEG-4 Audio (several formats are possible)
680 case 0x60 : Fill(Stream_Video , StreamPos_Last, Video_Format, "MPEG Video", Unlimited, true, true); Fill(Stream_Video, StreamPos_Last, Video_Format_Profile, "Simple" , Unlimited, true, true); Fill(Stream_Video, StreamPos_Last, Video_Format_Version, "Version 2", Unlimited, true, true); break; //MPEG-2V Simple
681 case 0x61 : Fill(Stream_Video , StreamPos_Last, Video_Format, "MPEG Video", Unlimited, true, true); Fill(Stream_Video, StreamPos_Last, Video_Format_Profile, "Main" , Unlimited, true, true); Fill(Stream_Video, StreamPos_Last, Video_Format_Version, "Version 2", Unlimited, true, true); break; //MPEG-2V Main
682 case 0x62 : Fill(Stream_Video , StreamPos_Last, Video_Format, "MPEG Video", Unlimited, true, true); Fill(Stream_Video, StreamPos_Last, Video_Format_Profile, "SNR" , Unlimited, true, true); Fill(Stream_Video, StreamPos_Last, Video_Format_Version, "Version 2", Unlimited, true, true); break; //MPEG-2V SNR
683 case 0x63 : Fill(Stream_Video , StreamPos_Last, Video_Format, "MPEG Video", Unlimited, true, true); Fill(Stream_Video, StreamPos_Last, Video_Format_Profile, "Spatial", Unlimited, true, true); Fill(Stream_Video, StreamPos_Last, Video_Format_Version, "Version 2", Unlimited, true, true); break; //MPEG-2V Spatial
684 case 0x64 : Fill(Stream_Video , StreamPos_Last, Video_Format, "MPEG Video", Unlimited, true, true); Fill(Stream_Video, StreamPos_Last, Video_Format_Profile, "High" , Unlimited, true, true); Fill(Stream_Video, StreamPos_Last, Video_Format_Version, "Version 2", Unlimited, true, true); break; //MPEG-2V High
685 case 0x65 : Fill(Stream_Video , StreamPos_Last, Video_Format, "MPEG Video", Unlimited, true, true); Fill(Stream_Video, StreamPos_Last, Video_Format_Profile, "4:2:2" , Unlimited, true, true); Fill(Stream_Video, StreamPos_Last, Video_Format_Version, "Version 2", Unlimited, true, true); break; //MPEG-2V 4:2:2
686 case 0x66 : Fill(Stream_Audio , StreamPos_Last, Audio_Format, "AAC", Unlimited, true, true); Fill(Stream_Audio, StreamPos_Last, Audio_Format_Profile, "Main", Unlimited, true, true); break; //MPEG-2 AAC Main
687 case 0x67 : Fill(Stream_Audio , StreamPos_Last, Audio_Format, "AAC", Unlimited, true, true); Fill(Stream_Audio, StreamPos_Last, Audio_Format_Profile, "LC", Unlimited, true, true); break; //MPEG-2 AAC LC
688 case 0x68 : Fill(Stream_Audio , StreamPos_Last, Audio_Format, "AAC", Unlimited, true, true); Fill(Stream_Audio, StreamPos_Last, Audio_Format_Profile, "SSR", Unlimited, true, true); break; //MPEG-2 AAC SSR
689 case 0x69 : Fill(Stream_Audio , StreamPos_Last, Audio_Format, "MPEG Audio", Unlimited, true, true); Fill(Stream_Audio, StreamPos_Last, Audio_Format_Version, "Version 2", Unlimited, true, true); Fill(Stream_Audio, StreamPos_Last, Audio_Format_Profile, "Layer 3", Unlimited, true, true); break;
690 case 0x6A : Fill(Stream_Video , StreamPos_Last, Video_Format, "MPEG Video", Unlimited, true, true); Fill(Stream_Video, StreamPos_Last, Video_Format_Version, "Version 1", Unlimited, true, true); break;
691 case 0x6B : Fill(Stream_Audio , StreamPos_Last, Audio_Format, "MPEG Audio", Unlimited, true, true); Fill(Stream_Audio, StreamPos_Last, Audio_Format_Version, "Version 1", Unlimited, true, true); break;
692 case 0x6C : Fill(Stream_Video , StreamPos_Last, Video_Format, "JPEG", Unlimited, true, true); break;
693 case 0x6D : Fill(Stream_Video , StreamPos_Last, Video_Format, "PNG", Unlimited, true, true); break;
694 case 0x6E : Fill(Stream_Video , StreamPos_Last, Video_Format, "MPEG Video", Unlimited, true, true); break;
695 case 0xA0 : Fill(Stream_Audio , StreamPos_Last, Audio_Format, "EVRC", Unlimited, true, true); Fill(Stream_Audio, StreamPos_Last, Audio_SamplingRate, 8000, 10, true); Fill(Stream_Audio, StreamPos_Last, Audio_Channel_s_, 1, 10, true); break;
696 case 0xA1 : Fill(Stream_Audio , StreamPos_Last, Audio_Format, "SMV", Unlimited, true, true); Fill(Stream_Audio, StreamPos_Last, Audio_SamplingRate, 8000, 10, true); Fill(Stream_Audio, StreamPos_Last, Audio_Channel_s_, 1, 10, true); break;
697 case 0xA2 : Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_Format), "3GPP2", Unlimited, true, true); break;
698 case 0xA3 : Fill(Stream_Video , StreamPos_Last, Video_Format, "VC-1", Unlimited, true, true); break;
699 case 0xA4 : Fill(Stream_Video , StreamPos_Last, Video_Format, "Dirac", Unlimited, true, true); break;
700 case 0xA5 : Fill(Stream_Audio , StreamPos_Last, Audio_Format, "AC-3", Unlimited, true, true); break;
701 case 0xA6 : Fill(Stream_Audio , StreamPos_Last, Audio_Format, "E-AC-3", Unlimited, true, true); break;
702 case 0xA9 : Fill(Stream_Audio , StreamPos_Last, Audio_Format, "DTS", Unlimited, true, true); break;
703 case 0xAA : Fill(Stream_Audio , StreamPos_Last, Audio_Format, "DTS", Unlimited, true, true); Fill(Stream_Audio, StreamPos_Last, Audio_Format_Profile, "HRA", Unlimited, true, true); break; // DTS-HD High Resolution
704 case 0xAB : Fill(Stream_Audio , StreamPos_Last, Audio_Format, "DTS", Unlimited, true, true); Fill(Stream_Audio, StreamPos_Last, Audio_Format_Profile, "MA", Unlimited, true, true); break; // DTS-HD Master Audio
705 case 0xAC : Fill(Stream_Audio , StreamPos_Last, Audio_Format, "DTS", Unlimited, true, true); Fill(Stream_Audio, StreamPos_Last, Audio_Format_Profile, "Express", Unlimited, true, true); break; // DTS Express a.k.a. LBR
706 case 0xD1 : Fill(Stream_Audio , StreamPos_Last, Audio_Format, "EVRC", Unlimited, true, true); Fill(Stream_Audio, StreamPos_Last, Audio_SamplingRate, 8000, 10, true); Fill(Stream_Audio, StreamPos_Last, Audio_Channel_s_, 1, 10, true); break;
707 case 0xD3 : Fill(Stream_Audio , StreamPos_Last, Audio_Format, "AC-3", Unlimited, true, true); break;
708 case 0xD4 : Fill(Stream_Audio , StreamPos_Last, Audio_Format, "DTS", Unlimited, true, true); break;
709 case 0xDD : Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_Format), "Ogg", Unlimited, true, true); break;
710 case 0xDE : Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_Format), "Ogg", Unlimited, true, true); break;
711 case 0xE0 : Fill(Stream_Text, StreamPos_Last, Text_Format, "VobSub", Unlimited, true, true); CodecID_Fill(__T("subp"), Stream_Text, StreamPos_Last, InfoCodecID_Format_Mpeg4); break;
712 case 0xE1 : Fill(Stream_Audio , StreamPos_Last, Audio_Format, "QCELP", Unlimited, true, true); Fill(Stream_Audio, StreamPos_Last, Audio_SamplingRate, 8000, 10, true); Fill(Stream_Audio, StreamPos_Last, Audio_Channel_s_, 1, 10, true); break;
713 default: ;
714 }
715 switch (ObjectTypeId)
716 {
717 case 0x01 : Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_Codec), "System", Unlimited, true, true); break;
718 case 0x02 : Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_Codec), "System Core", Unlimited, true, true); break;
719 case 0x20 : Fill(Stream_Video , StreamPos_Last, Video_Codec, "MPEG-4V", Unlimited, true, true); break;
720 case 0x21 : Fill(Stream_Video , StreamPos_Last, Video_Codec, "H264", Unlimited, true, true); break;
721 case 0x40 : Fill(Stream_Audio , StreamPos_Last, Audio_Codec, "AAC", Unlimited, true, true); break; //MPEG-4 AAC
722 case 0x60 : Fill(Stream_Video , StreamPos_Last, Video_Codec, "MPEG-2V", Unlimited, true, true); break; //MPEG-2V Simple
723 case 0x61 : Fill(Stream_Video , StreamPos_Last, Video_Codec, "MPEG-2V", Unlimited, true, true); break; //MPEG-2V Main
724 case 0x62 : Fill(Stream_Video , StreamPos_Last, Video_Codec, "MPEG-2V", Unlimited, true, true); break; //MPEG-2V SNR
725 case 0x63 : Fill(Stream_Video , StreamPos_Last, Video_Codec, "MPEG-2V", Unlimited, true, true); break; //MPEG-2V Spatial
726 case 0x64 : Fill(Stream_Video , StreamPos_Last, Video_Codec, "MPEG-2V", Unlimited, true, true); break; //MPEG-2V High
727 case 0x65 : Fill(Stream_Video , StreamPos_Last, Video_Codec, "MPEG-2V", Unlimited, true, true); break; //MPEG-2V 4:2:2
728 case 0x66 : Fill(Stream_Audio , StreamPos_Last, Audio_Codec, "AAC", Unlimited, true, true); break; //MPEG-2 AAC Main
729 case 0x67 : Fill(Stream_Audio , StreamPos_Last, Audio_Codec, "AAC", Unlimited, true, true); break; //MPEG-2 AAC LC
730 case 0x68 : Fill(Stream_Audio , StreamPos_Last, Audio_Codec, "AAC", Unlimited, true, true); break; //MPEG-2 AAC SSR
731 case 0x69 : Fill(Stream_Audio , StreamPos_Last, Audio_Codec, "MPEG-2A L3", Unlimited, true, true); break;
732 case 0x6A : Fill(Stream_Video , StreamPos_Last, Video_Codec, "MPEG-1V", Unlimited, true, true); break;
733 case 0x6B : Fill(Stream_Audio , StreamPos_Last, Audio_Codec, "MPEG-1A", Unlimited, true, true); break;
734 case 0x6C : Fill(Stream_Video , StreamPos_Last, Video_Codec, "JPEG", Unlimited, true, true); break;
735 case 0x6D : Fill(Stream_Video , StreamPos_Last, Video_Codec, "PNG", Unlimited, true, true); break;
736 case 0x6E : Fill(Stream_Video , StreamPos_Last, Video_Codec, "MPEG-4V", Unlimited, true, true); break;
737 case 0xA0 : Fill(Stream_Video , StreamPos_Last, Video_Codec, "EVRC", Unlimited, true, true); break;
738 case 0xA1 : Fill(Stream_Video , StreamPos_Last, Video_Codec, "SMV", Unlimited, true, true); break;
739 case 0xA2 : Fill(Stream_Video , StreamPos_Last, Video_Codec, "MPEG-4V", Unlimited, true, true); break;
740 case 0xA3 : Fill(Stream_Audio , StreamPos_Last, Audio_Codec, "VC-1", Unlimited, true, true); break;
741 case 0xA4 : Fill(Stream_Audio , StreamPos_Last, Audio_Codec, "Dirac", Unlimited, true, true); break;
742 case 0xA5 : Fill(Stream_Audio , StreamPos_Last, Audio_Codec, "AC3", Unlimited, true, true); break;
743 case 0xA6 : Fill(Stream_Audio , StreamPos_Last, Audio_Codec, "AC3+", Unlimited, true, true); break;
744 case 0xA9 : Fill(Stream_Audio , StreamPos_Last, Audio_Codec, "DTS", Unlimited, true, true); break;
745 case 0xAA :
746 case 0xAB : Fill(Stream_Audio , StreamPos_Last, Audio_Codec, "DTS-HD", Unlimited, true, true); break;
747 case 0xAC : Fill(Stream_Audio , StreamPos_Last, Audio_Codec, "DTS Express", Unlimited, true, true); break;
748 case 0xD1 : Fill(Stream_Audio , StreamPos_Last, Audio_Codec, "EVRC", Unlimited, true, true); break;
749 case 0xD3 : Fill(Stream_Audio , StreamPos_Last, Audio_Codec, "AC3", Unlimited, true, true); break;
750 case 0xD4 : Fill(Stream_Audio , StreamPos_Last, Audio_Codec, "DTS", Unlimited, true, true); break;
751 case 0xDD : Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_Codec), "Ogg", Unlimited, true, true); break;
752 case 0xDE : Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_Codec), "Ogg", Unlimited, true, true); break;
753 case 0xE0 : Fill(Stream_Text , StreamPos_Last, Text_Codec, "subp", Unlimited, true, true); break;
754 case 0xE1 : Fill(Stream_Audio , StreamPos_Last, Audio_Codec, "QCELP", Unlimited, true, true); break;
755 default: ;
756 }
757 Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_CodecID), Ztring().From_CC1(ObjectTypeId), true);
758 Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_Codec_CC), ObjectTypeId, 16, true);
759
760 //Bitrate mode
761 if (AvgBitrate>0
762 && !(bufferSizeDB==AvgBitrate && bufferSizeDB==MaxBitrate && bufferSizeDB==0x1000)) //Some buggy data were found
763 {
764 Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_BitRate_Nominal), AvgBitrate);
765 if (!MaxBitrate || (MaxBitrate>=AvgBitrate && MaxBitrate<=AvgBitrate*1.005))
766 {
767 Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_BitRate_Mode), "CBR");
768 }
769 else
770 {
771 Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_BitRate_Mode), "VBR");
772 Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_BitRate_Maximum), MaxBitrate);
773 }
774 }
775
776 //Creating parser
777 delete Parser; Parser=NULL;
778 switch (ObjectTypeId)
779 {
780 case 0x01 : switch (streamType)
781 {
782 case 0x01 : Parser=new File_Mpeg4_Descriptors; break;
783 default : ;
784 }
785 break;
786 case 0x20 : //MPEG-4 Visual
787 #if defined(MEDIAINFO_MPEG4V_YES)
788 Parser=new File_Mpeg4v;
789 ((File_Mpeg4v*)Parser)->Frame_Count_Valid=1;
790 ((File_Mpeg4v*)Parser)->FrameIsAlwaysComplete=true;
791 #endif
792 break;
793 case 0x21 : //AVC
794 #if defined(MEDIAINFO_AVC_YES)
795 Parser=new File_Avc;
796 ((File_Avc*)Parser)->MustParse_SPS_PPS=true;
797 ((File_Avc*)Parser)->MustSynchronize=false;
798 ((File_Avc*)Parser)->SizedBlocks=true;
799 #endif
800 break;
801 case 0x40 : //MPEG-4 AAC
802 case 0x66 :
803 case 0x67 :
804 case 0x68 : //MPEG-2 AAC
805 #if defined(MEDIAINFO_AAC_YES)
806 Parser=new File_Aac;
807 ((File_Aac*)Parser)->Mode=File_Aac::Mode_AudioSpecificConfig;
808 ((File_Aac*)Parser)->FrameIsAlwaysComplete=true;
809 #endif
810 break;
811 case 0x60 :
812 case 0x61 :
813 case 0x62 :
814 case 0x63 :
815 case 0x64 :
816 case 0x65 :
817 case 0x6A : //MPEG Video
818 #if defined(MEDIAINFO_MPEGV_YES)
819 Parser=new File_Mpegv;
820 ((File_Mpegv*)Parser)->FrameIsAlwaysComplete=true;
821 #endif
822 break;
823 case 0x69 :
824 case 0x6B : //MPEG Audio
825 #if defined(MEDIAINFO_MPEGA_YES)
826 Parser=new File_Mpega;
827 #endif
828 break;
829 case 0x6C : //JPEG
830 #if defined(MEDIAINFO_JPEG_YES)
831 Parser=new File_Jpeg;
832 ((File_Jpeg*)Parser)->StreamKind=Stream_Video;
833 #endif
834 break;
835 case 0x6D : //PNG
836 #if defined(MEDIAINFO_PNG_YES)
837 Parser=new File_Png;
838 #endif
839 break;
840 case 0xA3 : //VC-1
841 #if defined(MEDIAINFO_VC1_YES)
842 Parser=new File_Vc1;
843 #endif
844 break;
845 case 0xA4 : //Dirac
846 #if defined(MEDIAINFO_DIRAC_YES)
847 Parser=new File_Dirac;
848 #endif
849 break;
850 case 0xA5 : //AC-3
851 case 0xA6 : //E-AC-3
852 case 0xD3 : //AC-3
853 #if defined(MEDIAINFO_AC3_YES)
854 Parser=new File_Ac3;
855 #endif
856 break;
857 case 0xA9 : //DTS
858 case 0xAA : //DTS HRA
859 case 0xAB : //DTS MA
860 case 0xAC : //DTS Express
861 case 0xD4 : //DTS
862 #if defined(MEDIAINFO_DTS_YES)
863 Parser=new File_Dts;
864 #endif
865 break;
866 case 0xDD :
867 case 0xDE : //OGG
868 #if defined(MEDIAINFO_OGG_YES)
869 Parser=new File_Ogg;
870 Parser->MustSynchronize=false;
871 ((File_Ogg*)Parser)->SizedBlocks=true;
872 #endif
873 break;
874 default: ;
875 }
876
877 Element_Code=(int64u)-1;
878 Open_Buffer_Init(Parser);
879
880 Element_ThisIsAList();
881 FILLING_END();
882 }
883
884 //---------------------------------------------------------------------------
Descriptor_05()885 void File_Mpeg4_Descriptors::Descriptor_05()
886 {
887 if (ObjectTypeId==0x00 && Parser==NULL) //If no ObjectTypeId detected
888 {
889 switch (KindOfStream)
890 {
891 case Stream_Video :
892 #if defined(MEDIAINFO_MPEG4V_YES)
893 delete Parser; Parser=new File_Mpeg4v;
894 ((File_Mpeg4v*)Parser)->FrameIsAlwaysComplete=true;
895 #endif
896 break;
897 case Stream_Audio :
898 #if defined(MEDIAINFO_AAC_YES)
899 delete Parser; Parser=new File_Aac;
900 ((File_Aac*)Parser)->Mode=File_Aac::Mode_AudioSpecificConfig;
901 #endif
902 break;
903 default: ;
904 }
905
906 Element_Code=(int64u)-1;
907 Open_Buffer_Init(Parser);
908 }
909
910 if (Parser==NULL)
911 {
912 Skip_XX(Element_Size, "Unknown");
913 return;
914 }
915
916 //Parser configuration before the parsing
917 switch (ObjectTypeId)
918 {
919 case 0x60 :
920 case 0x61 :
921 case 0x62 :
922 case 0x63 :
923 case 0x64 :
924 case 0x65 :
925 case 0x6A : //MPEG Video
926 #if defined(MEDIAINFO_MPEGV_YES)
927 ((File_Mpegv*)Parser)->TimeCodeIsNotTrustable=true;
928 #endif
929 break;
930 default: ;
931 }
932
933 //Parsing
934 Open_Buffer_Continue(Parser);
935
936 //Demux
937 #if MEDIAINFO_DEMUX
938 if (ObjectTypeId!=0x21 || !Config->Demux_Avc_Transcode_Iso14496_15_to_Iso14496_10_Get()) //0x21 is AVC
939 switch (Config->Demux_InitData_Get())
940 {
941 case 0 : //In demux event
942 Demux_Level=2; //Container
943 Demux(Buffer+Buffer_Offset, (size_t)Element_Size, ContentType_Header);
944 break;
945 case 1 : //In field
946 {
947 std::string Data_Raw((const char*)(Buffer+Buffer_Offset), (size_t)Element_Size);
948 std::string Data_Base64(Base64::encode(Data_Raw));
949 Parser->Fill(KindOfStream, PosOfStream, "Demux_InitBytes", Data_Base64);
950 Parser->Fill_SetOptions(KindOfStream, PosOfStream, "Demux_InitBytes", "N NT");
951 }
952 break;
953 default : ;
954 }
955 #endif //MEDIAINFO_DEMUX
956
957 //Parser configuration after the parsing
958 switch (ObjectTypeId)
959 {
960 case 0x60 :
961 case 0x61 :
962 case 0x62 :
963 case 0x63 :
964 case 0x64 :
965 case 0x65 :
966 case 0x6A : //MPEG Video
967 #if defined(MEDIAINFO_MPEGV_YES)
968 ((File_Mpegv*)Parser)->TimeCodeIsNotTrustable=false;
969 #endif
970 break;
971 default: ;
972 }
973
974 //Positionning
975 Element_Offset=Element_Size;
976 }
977
978 //---------------------------------------------------------------------------
Descriptor_06()979 void File_Mpeg4_Descriptors::Descriptor_06()
980 {
981 delete SLConfig; SLConfig=new slconfig;
982
983 //Parsing
984 int8u predefined;
985 Get_B1 (predefined, "predefined"); Param_Info1(Mpeg4_Descriptors_Predefined(predefined));
986 switch (predefined)
987 {
988 case 0x00 :
989 {
990 BS_Begin();
991 Get_SB (SLConfig->useAccessUnitStartFlag, "useAccessUnitStartFlag");
992 Get_SB (SLConfig->useAccessUnitEndFlag, "useAccessUnitEndFlag");
993 Get_SB (SLConfig->useRandomAccessPointFlag, "useRandomAccessPointFlag");
994 Get_SB (SLConfig->hasRandomAccessUnitsOnlyFlag, "hasRandomAccessUnitsOnlyFlag");
995 Get_SB (SLConfig->usePaddingFlag, "usePaddingFlag");
996 Get_SB (SLConfig->useTimeStampsFlag, "useTimeStampsFlag");
997 Get_SB (SLConfig->useIdleFlag, "useIdleFlag");
998 Get_SB (SLConfig->durationFlag, "durationFlag");
999 BS_End();
1000 Get_B4 (SLConfig->timeStampResolution, "timeStampResolution");
1001 Get_B4( SLConfig->OCRResolution, "OCRResolution");
1002 Get_B1 (SLConfig->timeStampLength, "timeStampLength");
1003 Get_B1 (SLConfig->OCRLength, "OCRLength");
1004 Get_B1 (SLConfig->AU_Length, "AU_Length");
1005 Get_B1 (SLConfig->instantBitrateLength, "instantBitrateLength");
1006 BS_Begin();
1007 Get_S1 (4, SLConfig->degradationPriorityLength, "degradationPriorityLength");
1008 Get_S1 (5, SLConfig->AU_seqNumLength, "AU_seqNumLength");
1009 Get_S1 (5, SLConfig->packetSeqNumLength, "packetSeqNumLength");
1010 Skip_S1(2, "reserved");
1011 BS_End();
1012 }
1013 break;
1014 case 0x01 :
1015 SLConfig->useAccessUnitStartFlag =false;
1016 SLConfig->useAccessUnitEndFlag =false;
1017 SLConfig->useRandomAccessPointFlag =false;
1018 SLConfig->hasRandomAccessUnitsOnlyFlag =false;
1019 SLConfig->usePaddingFlag =false;
1020 SLConfig->useTimeStampsFlag =false;
1021 SLConfig->useIdleFlag =false;
1022 SLConfig->durationFlag =false; //-
1023 SLConfig->timeStampResolution =1000;
1024 SLConfig->OCRResolution =0; //-
1025 SLConfig->timeStampLength =32;
1026 SLConfig->OCRLength =0; //-
1027 SLConfig->AU_Length =0;
1028 SLConfig->instantBitrateLength =0; //-
1029 SLConfig->degradationPriorityLength =0;
1030 SLConfig->AU_seqNumLength =0;
1031 SLConfig->packetSeqNumLength =0;
1032 break;
1033 case 0x02 :
1034 SLConfig->useAccessUnitStartFlag =false;
1035 SLConfig->useAccessUnitEndFlag =false;
1036 SLConfig->useRandomAccessPointFlag =false;
1037 SLConfig->hasRandomAccessUnitsOnlyFlag =false;
1038 SLConfig->usePaddingFlag =false;
1039 SLConfig->useTimeStampsFlag =true;
1040 SLConfig->useIdleFlag =false;
1041 SLConfig->durationFlag =false;
1042 SLConfig->timeStampResolution =0; //-
1043 SLConfig->OCRResolution =0; //-
1044 SLConfig->timeStampLength =0;
1045 SLConfig->OCRLength =0;
1046 SLConfig->AU_Length =0;
1047 SLConfig->instantBitrateLength =0;
1048 SLConfig->degradationPriorityLength =0;
1049 SLConfig->AU_seqNumLength =0;
1050 SLConfig->packetSeqNumLength =0;
1051 break;
1052 default :
1053 SLConfig->useAccessUnitStartFlag =false;
1054 SLConfig->useAccessUnitEndFlag =false;
1055 SLConfig->useRandomAccessPointFlag =false;
1056 SLConfig->hasRandomAccessUnitsOnlyFlag =false;
1057 SLConfig->usePaddingFlag =false;
1058 SLConfig->useTimeStampsFlag =false;
1059 SLConfig->useIdleFlag =false;
1060 SLConfig->durationFlag =false;
1061 SLConfig->timeStampResolution =0;
1062 SLConfig->OCRResolution =0;
1063 SLConfig->timeStampLength =0;
1064 SLConfig->AU_Length =0;
1065 SLConfig->instantBitrateLength =0;
1066 SLConfig->degradationPriorityLength =0;
1067 SLConfig->AU_seqNumLength =0;
1068 SLConfig->packetSeqNumLength =0;
1069 }
1070 if (SLConfig->durationFlag)
1071 {
1072 Get_B4 (SLConfig->timeScale, "timeScale");
1073 Get_B2 (SLConfig->accessUnitDuration, "accessUnitDuration");
1074 Get_B2 (SLConfig->compositionUnitDuration, "compositionUnitDuration");
1075 }
1076 else
1077 {
1078 SLConfig->timeScale =0; //-
1079 SLConfig->accessUnitDuration =0; //-
1080 SLConfig->compositionUnitDuration =0; //-
1081 }
1082 if (!SLConfig->useTimeStampsFlag)
1083 {
1084 BS_Begin();
1085 Get_S8 (SLConfig->timeStampLength, SLConfig->startDecodingTimeStamp, "startDecodingTimeStamp");
1086 Get_S8 (SLConfig->timeStampLength, SLConfig->startCompositionTimeStamp, "startCompositionTimeStamp");
1087 BS_End();
1088 }
1089 else
1090 {
1091 SLConfig->startDecodingTimeStamp =0; //-
1092 SLConfig->startCompositionTimeStamp =0; //-
1093 }
1094 }
1095
1096 //---------------------------------------------------------------------------
Descriptor_09()1097 void File_Mpeg4_Descriptors::Descriptor_09()
1098 {
1099 //Parsing
1100 Skip_B2( "IPI_ES_Id");
1101 }
1102
1103 //---------------------------------------------------------------------------
Descriptor_0E()1104 void File_Mpeg4_Descriptors::Descriptor_0E()
1105 {
1106 //Parsing
1107 int32u Track_ID;
1108 Get_B4 (Track_ID, "Track_ID"); //ID of the track to use
1109
1110 FILLING_BEGIN();
1111 es_id_infos::iterator ES_ID_Info=ES_ID_Infos.find((int32u)-1);
1112 if (ES_ID_Info!=ES_ID_Infos.end())
1113 ES_ID_Infos[Track_ID]=ES_ID_Info->second;
1114 FILLING_END();
1115 }
1116
1117 //---------------------------------------------------------------------------
Descriptor_0F()1118 void File_Mpeg4_Descriptors::Descriptor_0F()
1119 {
1120 //Parsing
1121 Skip_B2( "ref_index"); //track ref. index of the track to use
1122 }
1123
1124 //---------------------------------------------------------------------------
Descriptor_10()1125 void File_Mpeg4_Descriptors::Descriptor_10()
1126 {
1127 Descriptor_02();
1128 }
1129
1130 //---------------------------------------------------------------------------
Descriptor_11()1131 void File_Mpeg4_Descriptors::Descriptor_11()
1132 {
1133 Descriptor_01();
1134 }
1135
1136 //***************************************************************************
1137 // C++
1138 //***************************************************************************
1139
1140 } //NameSpace
1141
1142 #endif //MEDIAINFO_MPEG4_YES
1143