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 // Pre-compilation
9 #include "MediaInfo/PreComp.h"
10 #ifdef __BORLANDC__
11     #pragma hdrstop
12 #endif
13 //---------------------------------------------------------------------------
14 
15 //---------------------------------------------------------------------------
16 #include "MediaInfo/Setup.h"
17 //---------------------------------------------------------------------------
18 
19 //---------------------------------------------------------------------------
20 #if defined(MEDIAINFO_SWF_YES)
21 //---------------------------------------------------------------------------
22 
23 //---------------------------------------------------------------------------
24 #include "MediaInfo/Multiple/File_Swf.h"
25 #include <zlib.h>
26 using namespace ZenLib;
27 //---------------------------------------------------------------------------
28 
29 namespace MediaInfoLib
30 {
31 
32 //***************************************************************************
33 // Infos
34 //***************************************************************************
35 
36 //---------------------------------------------------------------------------
37 static const int8u  Swf_SoundType[]=
38 {
39     1,
40     2,
41 };
42 
43 //---------------------------------------------------------------------------
44 static const int8u  Swf_SoundSize[]=
45 {
46      8,
47     16,
48 };
49 
50 //---------------------------------------------------------------------------
51 static const int16u Swf_SoundRate[]=
52 {
53      5500,
54     11025,
55     22050,
56     44100,
57 };
58 
59 //---------------------------------------------------------------------------
60 static const char* Swf_Format_Audio[]=
61 {
62     "PCM",
63     "ADPCM",
64     "MPEG Audio",
65     "PCM",
66     "Nellymoser",
67     "Nellymoser",
68     "Nellymoser",
69     "",
70     "",
71     "",
72     "",
73     "Speex",
74     "",
75     "",
76     "",
77     "",
78 };
79 
80 //---------------------------------------------------------------------------
81 static const char* Swf_Format_Version_Audio[]=
82 {
83     "",
84     "",
85     "Version 1",
86     "",
87     "",
88     "",
89     "",
90     "",
91     "",
92     "",
93     "",
94     "",
95     "",
96     "",
97     "",
98     "",
99 };
100 
101 //---------------------------------------------------------------------------
102 static const char* Swf_Format_Profile_Audio[]=
103 {
104     "",
105     "",
106     "Layer 3",
107     "",
108     "",
109     "",
110     "",
111     "",
112     "",
113     "",
114     "",
115     "",
116     "",
117     "",
118     "",
119     "",
120 };
121 
122 //---------------------------------------------------------------------------
123 static const char* Swf_SoundFormat[]=
124 {
125     "Uncompressed",
126     "SWF ADPCM",
127     "MPEG-1L3",
128     "Uncompressed Little Endian",
129     "",
130     "",
131     "Nellymoser",
132     "",
133     "",
134     "",
135     "",
136     "",
137     "",
138     "",
139     "",
140     "",
141 };
142 
143 //---------------------------------------------------------------------------
144 static const char* Swf_Format_Video[]=
145 {
146     "",
147     "",
148     "H.263",
149     "Screen video",
150     "VP6",
151     "VP6",
152     "Screen video 2",
153     "AVC",
154     "",
155     "",
156     "",
157     "",
158     "",
159     "",
160     "",
161     "",
162 };
163 
164 //---------------------------------------------------------------------------
165 static const char* Swf_Format_Profile_Video[]=
166 {
167     "",
168     "",
169     "",
170     "",
171     "",
172     "Alpha channel",
173     "",
174     "",
175     "",
176     "",
177     "",
178     "",
179     "",
180     "",
181     "",
182     "",
183 };
184 
185 //---------------------------------------------------------------------------
186 static const char* Swf_Codec_Video[]=
187 {
188     "",
189     "",
190     "Sorenson H263",
191     "Screen video",
192     "On2 VP6",
193     "On2 VP6 with alpha channel",
194     "Screen video 2",
195     "AVC",
196     "",
197     "",
198     "",
199     "",
200     "",
201     "",
202     "",
203     "",
204 };
205 
206 //***************************************************************************
207 // Constants
208 //***************************************************************************
209 
210 namespace Elements
211 {
212     const int16u End                            =  0; //V1+
213     const int16u ShowFrame                      =  1; //V1+
214     const int16u DefineShape                    =  2; //V1+
215     const int16u PlaceObject                    =  4; //V1+
216     const int16u RemoveObject                   =  5; //V1+
217     const int16u DefineBits                     =  6; //V1+
218     const int16u DefineButton                   =  7; //V1+
219     const int16u JPEGTables                     =  8; //V1+
220     const int16u SetBackgroundColor             =  9; //V1+
221     const int16u DefineFont                     = 10; //V1+
222     const int16u DefineText                     = 11; //V1+
223     const int16u DoAction                       = 12; //V3+
224     const int16u DefineFontInfo                 = 13; //V1+
225     const int16u DefineSound                    = 14; //V1+
226     const int16u StartSound                     = 15; //V1+
227     const int16u DefineButtonSound              = 17; //V2+
228     const int16u SoundStreamHead                = 18; //V1+
229     const int16u SoundStreamBlock               = 19; //V1+
230     const int16u DefineBitsLossless             = 20; //V2+
231     const int16u DefineBitsJPEG2                = 21; //V2+
232     const int16u DefineShape2                   = 22; //V2+
233     const int16u DefineCxform                   = 23; //V2+
234     const int16u Protect                        = 24; //V2+
235     const int16u PlaceObject2                   = 26; //V3+
236     const int16u RemoveObject2                  = 28; //V3+
237     const int16u DefineShape3                   = 32; //V3+
238     const int16u DefineText2                    = 33; //V3+
239     const int16u DefineButton2                  = 34; //V3+
240     const int16u DefineBitsJPEG3                = 35; //V3+
241     const int16u DefineBitsLossless2            = 36; //V3+
242     const int16u DefineEditText                 = 37; //V4+
243     const int16u DefineSprite                   = 39; //V3+
244     const int16u FrameLabel                     = 43; //V3+
245     const int16u SoundStreamHead2               = 45; //V3+
246     const int16u DefineMorphShape               = 46; //V3+
247     const int16u DefineFont2                    = 48; //V3+
248     const int16u ExportAssets                   = 56; //V5+
249     const int16u ImportAssets                   = 57; //V5+
250     const int16u EnableDebugger                 = 58; //V5
251     const int16u DoInitAction                   = 59; //V6+
252     const int16u DefineVideoStream              = 60; //V6+
253     const int16u DefineVideoFrame               = 61; //V6+
254     const int16u DefineFontInfo2                = 62; //V6+
255     const int16u EnableDebugger2                = 64; //V6+
256     const int16u ScriptLimits                   = 65; //V6+
257     const int16u SetTabIndex                    = 66; //V7+
258     const int16u FileAttributes                 = 69; //V1+
259     const int16u PlaceObject3                   = 70; //V8+
260     const int16u ImportAssets2                  = 71; //V8+
261     const int16u DefineFontAlignZones           = 73; //V8+
262     const int16u CSMTextSettings                = 74; //V8+
263     const int16u DefineFont3                    = 75; //V8+
264     const int16u SymbolClass                    = 76; //V9+
265     const int16u Metadata                       = 77; //V1+
266     const int16u DefineScalingGrid              = 78; //V8+
267     const int16u DoABC                          = 82; //V9+
268     const int16u DefineShape4                   = 83; //V8+
269     const int16u DefineMorphShape2              = 84; //V8+
270     const int16u DefineSceneAndFrameLabelData   = 86; //V9+
271     const int16u DefineBinaryData               = 87; //V9+
272     const int16u DefineFontName                 = 88; //V9+
273     const int16u StartSound2                    = 89; //V9+
274 }
275 
276 //***************************************************************************
277 // Constructor/Destructor
278 //***************************************************************************
279 
280 //---------------------------------------------------------------------------
File_Swf()281 File_Swf::File_Swf()
282 :File__Analyze()
283 {
284     //In
285     Frame_Count_Valid=1024;
286     FileLength=0;
287     Version=0;
288 }
289 
290 //***************************************************************************
291 // Buffer
292 //***************************************************************************
293 
294 //---------------------------------------------------------------------------
FileHeader_Begin()295 bool File_Swf::FileHeader_Begin()
296 {
297     //Parsing
298     if (Buffer_Size<8)
299         return false;
300 
301     if (CC3(Buffer)!=0x435753) //CWS
302         return true;
303 
304     //Compressed file
305     if (File_Size>16*1024*1024)
306         return true; //The file is too big, we will not parse all, only say this is SWF
307     if (CC4(Buffer+4)<4*16*1024*1024) //FileLength
308         return true; //The file is too big, we will not parse all, only say this is SWF
309     Buffer_MaximumSize=(size_t)File_Size;
310     if (Buffer_Size!=File_Size)
311         return false;
312     return true;
313 }
314 
315 //---------------------------------------------------------------------------
FileHeader_Parse()316 void File_Swf::FileHeader_Parse()
317 {
318     //Parsing
319     int32u Signature;
320     if (FileLength==0 && Version==0)
321     {
322         Element_Begin1("SWF header");
323             Get_C3 (Signature,                                  "Signature");
324             Get_L1 (Version,                                    "Version");
325             Get_L4 (FileLength,                                 "FileLength");
326         Element_End0();
327     }
328     else
329     {
330         //Was already done by compressed file handling
331         Signature=0x465753;
332     }
333 
334     //Compressed file handling
335     if (Signature==0x435753) //CWS
336     {
337         Decompress();
338         return;
339     }
340 
341     //Parsing
342     //Parsing - BitStream
343     float32 FrameRate;
344     int32u Xmin, Xmax, Ymin, Ymax;
345     int16u FrameCount;
346     int8u  Nbits;
347     BS_Begin();
348     Get_S1 (5, Nbits,                                           "Nbits");
349     Get_BS (Nbits, Xmin,                                        "Xmin");
350     Get_BS (Nbits, Xmax,                                        "Xmax"); Param_Info2((Xmax-Xmin)/20, " pixels");
351     Get_BS (Nbits, Ymin,                                        "Ymin");
352     Get_BS (Nbits, Ymax,                                        "Ymax"); Param_Info2((Ymax-Ymin)/20, " pixels");
353     BS_End();
354     if (Version<=7)
355     {
356         int8u FrameRate_8;
357         Skip_L1(                                                "Ignored");
358         Get_L1 (FrameRate_8,                                    "FrameRate");
359         FrameRate=FrameRate_8;
360     }
361     else
362     {
363         int16u FrameRate_8_8;
364         Get_L2(FrameRate_8_8,                                   "FrameRate");
365         FrameRate=((float32)FrameRate_8_8)/0x0100+(((float32)(FrameRate_8_8&0x00FF))/0x0100); //8.8 format
366         Param_Info1(FrameRate);
367     }
368     Get_L2 (FrameCount,                                         "FrameCount");
369 
370     FILLING_BEGIN();
371         //Integrity
372         if (Signature!=0x465753 && Signature!=0x435753) //FWS or CWS
373         {
374             Reject("SWF");
375             return;
376         }
377 
378         //Filling
379         Accept("SWF");
380 
381         if (!IsSub)
382             Fill(Stream_General, 0, General_Format, "ShockWave");
383 
384         Stream_Prepare(Stream_Video);
385         Fill(Stream_Video, 0, Video_Width, (Xmax-Xmin)/20);
386         Fill(Stream_Video, 0, Video_Height, (Ymax-Ymin)/20);
387         if (FrameRate)
388             Fill(Stream_Video, 0, Video_FrameRate, FrameRate);
389         if (FrameCount)
390             Fill(Stream_Video, 0, Video_FrameCount, FrameCount);
391     FILLING_END();
392 }
393 
394 //---------------------------------------------------------------------------
Header_Parse()395 void File_Swf::Header_Parse()
396 {
397     //Parsing
398     int16u TagCodeAndLength;
399     Get_L2 (TagCodeAndLength,                                   "TagCodeAndLength");
400 
401     //Filling
402     int16u Tag=(TagCodeAndLength&0xFFC0)>>6; Param_Info1(Tag);
403     Header_Fill_Code(Tag, Ztring().From_Number(Tag, 16));
404 
405     //Size
406     int16u Length=TagCodeAndLength&0x003F;
407     if (Length<0x003F)
408     {
409         Param_Info2(Length, " bytes");
410 
411         //Filling
412         Header_Fill_Size(Element_Offset+Length);
413     }
414     else
415     {
416         int32u Length2;
417         Get_L4(Length2,                                          "Length"); Param_Info2(Length2, " bytes");
418 
419         //Filling
420         Header_Fill_Size(Element_Offset+Length2);
421     }
422 }
423 
424 //---------------------------------------------------------------------------
Data_Parse()425 void File_Swf::Data_Parse()
426 {
427     #define LIS2(_ATOM, _NAME) \
428         case Elements::_ATOM : \
429                 if (Level==Element_Level) \
430                 { \
431                     Element_Name(_NAME); \
432                     _ATOM(); \
433                     Element_ThisIsAList(); \
434                 } \
435 
436     #define ATO2(_ATOM, _NAME) \
437                 case Elements::_ATOM : \
438                         if (Level==Element_Level) \
439                         { \
440                             if (Element_IsComplete_Get()) \
441                             { \
442                                 Element_Name(_NAME); \
443                                 _ATOM(); \
444                             } \
445                             else \
446                             { \
447                                 Element_WaitForMoreData(); \
448                                 return; \
449                             } \
450                         } \
451                         break; \
452 
453     //Parsing
454     DATA_BEGIN
455     ATO2(End,                           "End");
456     ATO2(ShowFrame,                     "ShowFrame");
457     ATO2(DefineShape,                   "DefineShape");
458     ATO2(PlaceObject,                   "PlaceObject");
459     ATO2(RemoveObject,                  "RemoveObject");
460     ATO2(DefineBits,                    "DefineBits");
461     ATO2(DefineButton,                  "DefineButton");
462     ATO2(JPEGTables,                    "JPEGTables");
463     ATO2(SetBackgroundColor,            "SetBackgroundColor");
464     ATO2(DefineFont,                    "DefineFont");
465     ATO2(DefineText,                    "DefineText");
466     ATO2(DoAction,                      "DoAction");
467     ATO2(DefineFontInfo,                "DefineFontInfo");
468     ATO2(DefineSound,                   "DefineSound");
469     ATO2(StartSound,                    "StartSound");
470     ATO2(DefineButtonSound,             "DefineButtonSound");
471     ATO2(SoundStreamHead,               "SoundStreamHead");
472     ATO2(SoundStreamBlock,              "SoundStreamBlock");
473     ATO2(DefineBitsLossless,            "DefineBitsLossless");
474     ATO2(DefineBitsJPEG2,               "DefineBitsJPEG2");
475     ATO2(DefineShape2,                  "DefineShape2");
476     ATO2(DefineCxform,                  "DefineCxform");
477     ATO2(Protect,                       "Protect");
478     ATO2(PlaceObject2,                  "PlaceObject2");
479     ATO2(RemoveObject2,                 "RemoveObject2");
480     ATO2(DefineShape3,                  "DefineShape3");
481     ATO2(DefineText2,                   "DefineText2");
482     ATO2(DefineButton2,                 "DefineButton2");
483     ATO2(DefineBitsJPEG3,               "DefineBitsJPEG3");
484     ATO2(DefineBitsLossless2,           "DefineBitsLossless2");
485     ATO2(DefineEditText,                "DefineEditText");
486     LIS2(DefineSprite,                  "DefineSprite");
487         ATOM_BEGIN
488         ATO2(ShowFrame,                     "ShowFrame");
489         ATO2(PlaceObject,                   "PlaceObject");
490         ATO2(RemoveObject,                  "RemoveObject");
491         ATO2(StartSound,                    "StartSound");
492         ATO2(SoundStreamHead,               "SoundStreamHead");
493         ATO2(SoundStreamBlock,              "SoundStreamBlock");
494         ATO2(PlaceObject2,                  "PlaceObject2");
495         ATO2(RemoveObject2,                 "RemoveObject2");
496         ATO2(FrameLabel,                    "FrameLabel");
497         ATO2(SoundStreamHead2,              "SoundStreamHead2");
498         ATO2(End,                           "End");
499         ATOM_END
500     ATO2(FrameLabel,                    "FrameLabel");
501     ATO2(DefineMorphShape,              "DefineMorphShape");
502     ATO2(SoundStreamHead2,              "SoundStreamHead2");
503     ATO2(DefineFont2,                   "DefineFont2");
504     ATO2(ExportAssets,                  "ExportAssets");
505     ATO2(ImportAssets,                  "ImportAssets");
506     ATO2(EnableDebugger,                "EnableDebugger");
507     ATO2(DoInitAction,                  "DoInitAction");
508     ATO2(DefineVideoStream,             "DefineVideoStream");
509     ATO2(DefineVideoFrame,              "DefineVideoFrame");
510     ATO2(DefineFontInfo2,               "DefineFontInfo2");
511     ATO2(EnableDebugger2,               "EnableDebugger2");
512     ATO2(ScriptLimits,                  "ScriptLimits");
513     ATO2(SetTabIndex,                   "SetTabIndex");
514     ATO2(FileAttributes,                "FileAttributes");
515     ATO2(PlaceObject3,                  "PlaceObject3");
516     ATO2(ImportAssets2,                 "ImportAssets2");
517     ATO2(DefineFontAlignZones,          "DefineFontAlignZones");
518     ATO2(CSMTextSettings,               "CSMTextSettings");
519     ATO2(DefineFont3,                   "DefineFont3");
520     ATO2(SymbolClass,                   "SymbolClass");
521     ATO2(Metadata,                      "Metadata");
522     ATO2(DefineScalingGrid,             "DefineScalingGrid");
523     ATO2(DoABC,                         "DoABC");
524     ATO2(DefineShape4,                  "DefineShape4");
525     ATO2(DefineMorphShape2,             "DefineMorphShape2");
526     ATO2(DefineSceneAndFrameLabelData,  "DefineSceneAndFrameLabelData");
527     ATO2(DefineBinaryData,              "DefineBinaryData");
528     ATO2(DefineFontName,                "DefineFontName");
529     ATO2(StartSound2,                   "StartSound2");
530     DATA_END
531 
532     Frame_Count++;
533     if (Frame_Count>=Frame_Count_Valid)
534         Data_Finish("SWF");
535 }
536 
537 //***************************************************************************
538 // Elements
539 //***************************************************************************
540 
541 //---------------------------------------------------------------------------
DefineSound()542 void File_Swf::DefineSound()
543 {
544     //Parsing
545     int16u SoundId;
546     int8u  SoundFormat, SoundRate, SoundSize, SoundType;
547     Get_L2 (SoundId,                                            "SoundId");
548     BS_Begin();
549     Get_S1 (4, SoundFormat,                                     "SoundFormat"); Param_Info1(Swf_SoundFormat[SoundFormat]);
550     Get_S1 (2, SoundRate,                                       "SoundRate"); Param_Info2(Swf_SoundRate[SoundRate], " Hz");
551     Get_S1 (1, SoundSize,                                       "SoundSize"); Param_Info2(Swf_SoundSize[SoundSize], " bits");
552     Get_S1 (1, SoundType,                                       "SoundType"); Param_Info2(Swf_SoundType[SoundType], " channel(s)");
553     BS_End();
554     Skip_L4(                                                    "SoundSampleCount");
555     Skip_XX(Element_Size-Element_Offset,                        "SoundData");
556 
557     Stream_Prepare(Stream_Audio);
558     Fill(Stream_Audio, StreamPos_Last, Audio_ID, SoundId);
559     Fill(Stream_Audio, StreamPos_Last, Audio_Format, Swf_Format_Audio[SoundFormat]);
560     Fill(Stream_Audio, StreamPos_Last, Audio_Format_Version, Swf_Format_Version_Audio[SoundFormat]);
561     Fill(Stream_Audio, StreamPos_Last, Audio_Format_Profile, Swf_Format_Profile_Audio[SoundFormat]);
562     Fill(Stream_Audio, StreamPos_Last, Audio_Codec, Swf_SoundFormat[SoundFormat]);
563     Fill(Stream_Audio, StreamPos_Last, Audio_SamplingRate, Swf_SoundRate[SoundRate]);
564     if (SoundFormat!=2) //SoundSize is not valid for MPEG Audio
565         Fill(Stream_Audio, StreamPos_Last, Audio_BitDepth, Swf_SoundSize[SoundSize]);
566     Fill(Stream_Audio, StreamPos_Last, Audio_Channel_s_, Swf_SoundType[SoundType]);
567 }
568 
569 //---------------------------------------------------------------------------
SoundStreamHead()570 void File_Swf::SoundStreamHead()
571 {
572     //Parsing
573     int16u StreamSoundSampleCount;
574     int8u  StreamSoundCompression, StreamSoundRate, StreamSoundType, StreamSoundSize;
575     BS_Begin();
576     Skip_S1(4,                                                  "Reserved");
577     Info_S1(2, PlaybackSoundRate,                               "PlaybackSoundRate"); Param_Info2(Swf_SoundRate[PlaybackSoundRate], " Hz");
578     Info_S1(1, PlaybackSoundSize,                               "PlaybackSoundSize"); Param_Info2(Swf_SoundSize[PlaybackSoundSize], " bits");
579     Info_S1(1, PlaybackSoundType,                               "PlaybackSoundType"); Param_Info2(Swf_SoundType[PlaybackSoundType], " channel(s)");
580     Get_S1 (4, StreamSoundCompression,                          "StreamSoundCompression"); Param_Info1(Swf_SoundFormat[StreamSoundCompression]);
581     Get_S1 (2, StreamSoundRate,                                 "StreamSoundRate"); Param_Info2(Swf_SoundRate[StreamSoundRate], " Hz");
582     Get_S1 (1, StreamSoundSize,                                 "StreamSoundSize"); Param_Info2(Swf_SoundSize[StreamSoundSize], " bits");
583     Get_S1 (1, StreamSoundType,                                 "StreamSoundType"); Param_Info2(Swf_SoundType[StreamSoundType], " channel(s)");
584     BS_End();
585     Get_L2 (StreamSoundSampleCount,                             "StreamSoundSampleCount");
586     if (StreamSoundCompression==2)
587         Skip_L2(                                                "LatencySeek");
588 
589     if (StreamSoundSampleCount>0)
590     {
591         Stream_Prepare(Stream_Audio);
592         Fill(Stream_Audio, StreamPos_Last, Audio_Format, Swf_Format_Audio[StreamSoundCompression]);
593         Fill(Stream_Audio, StreamPos_Last, Audio_Format_Version, Swf_Format_Version_Audio[StreamSoundCompression]);
594         Fill(Stream_Audio, StreamPos_Last, Audio_Format_Profile, Swf_Format_Profile_Audio[StreamSoundCompression]);
595         Fill(Stream_Audio, StreamPos_Last, Audio_Codec, Swf_SoundFormat[StreamSoundCompression]);
596         Fill(Stream_Audio, StreamPos_Last, Audio_SamplingRate, Swf_SoundRate[StreamSoundRate]);
597         if (StreamSoundCompression!=2) //SoundSize is not valid for MPEG Audio
598             Fill(Stream_Audio, StreamPos_Last, Audio_BitDepth, Swf_SoundSize[StreamSoundSize]);
599         Fill(Stream_Audio, StreamPos_Last, Audio_Channel_s_, Swf_SoundType[StreamSoundType]);
600     }
601 }
602 
603 //---------------------------------------------------------------------------
DefineSprite()604 void File_Swf::DefineSprite()
605 {
606     //Parsing
607     Skip_B2(                                                    "Character ID of sprite");
608     Skip_B2(                                                    "Number of frames in sprite");
609 }
610 
611 //---------------------------------------------------------------------------
DefineVideoStream()612 void File_Swf::DefineVideoStream()
613 {
614     //Parsing
615     int16u CharacterID, NumFrames, Width, Height;
616     int8u  CodecID;
617     Get_L2 (CharacterID,                                        "CharacterID");
618     Get_L2 (NumFrames,                                          "NumFrames");
619     Get_L2 (Width,                                              "Width");
620     Get_L2 (Height,                                             "Height");
621     BS_Begin();
622     Skip_BS(4,                                                  "VideoFlagsReserved");
623     Skip_BS(3,                                                  "VideoFlagsDeblocking");
624     Skip_BS(1,                                                  "VideoFlagsSmoothing");
625     BS_End();
626     Get_L1 (CodecID,                                            "CodecID"); Param_Info1C((CodecID<16), Swf_Format_Video[CodecID]);
627 
628     Stream_Prepare(Stream_Video);
629     Fill(Stream_Video, StreamPos_Last, Video_ID, CharacterID);
630     Fill(Stream_Video, StreamPos_Last, Video_Width, Width);
631     Fill(Stream_Video, StreamPos_Last, Video_Height, Height);
632     if (CodecID<16)
633     {
634         Fill(Stream_Video, StreamPos_Last, Video_Format, Swf_Format_Video[CodecID]);
635         Fill(Stream_Video, StreamPos_Last, Video_Format_Profile, Swf_Format_Profile_Video[CodecID]);
636         Fill(Stream_Video, StreamPos_Last, Video_Codec, Swf_Codec_Video[CodecID]);
637     }
638     Fill(Stream_Video, StreamPos_Last, Video_FrameCount, NumFrames);
639 }
640 
641 //***************************************************************************
642 // Helpers
643 //***************************************************************************
644 
645 //---------------------------------------------------------------------------
Decompress()646 bool File_Swf::Decompress()
647 {
648     if (Buffer_Size!=File_Size)
649     {
650         //We must have the complete file in memory, but this is too big (not handled by FileHeader_Begin()), only saying this is SWF
651         Fill(Stream_General, 0, General_Format, "ShockWave");
652 
653         Stream_Prepare(Stream_Video);
654 
655         Finish("SWF");
656         return true;
657     }
658 
659     //Sizes
660     unsigned long Source_Size=(unsigned long)(File_Size-8);
661     unsigned long Dest_Size=(unsigned long)(FileLength-8);
662 
663     //Uncompressing
664     int8u* Dest=new int8u[Dest_Size];
665     if (uncompress((Bytef*)Dest, &Dest_Size, (const Bytef*)Buffer+Buffer_Offset+8, Source_Size)<0)
666     {
667         delete[] Dest; //Dest=NULL
668         Trusted_IsNot("Error while decompressing");
669         Reject("SWF");
670         return false;
671     }
672 
673     Accept("SWF");
674 
675     Fill(Stream_General, 0, General_Format, "ShockWave");
676 
677     File_Swf MI;
678     MI.FileLength=FileLength;
679     MI.Version=Version;
680     Open_Buffer_Init(&MI);
681     MI.Open_Buffer_Continue(Dest, FileLength-8);
682     MI.Open_Buffer_Finalize();
683     Merge(MI, Stream_General, 0, 0);
684     Merge(MI);
685     delete[] Dest; //Dest=NULL;
686 
687     Finish("SWF");
688     return true;
689 }
690 
691 } //NameSpace
692 
693 #endif //MEDIAINFO_SWF_*
694 
695